:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2939;
  --muted: #5d6b7e;
  --line: #d0d5dd;
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --primary-soft: #e6f4f2;
  --error: #b42318;
  --error-bg: #fef3f2;
  --error-line: #fecdca;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --radius: 14px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.top {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
}

.step-indicator {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgb(16 24 40 / 10%), 0 1px 2px rgb(16 24 40 / 6%);
  padding: 1.75rem 1.5rem;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
  line-height: 1.25;
}

h2:focus {
  outline: none;
}

p {
  margin: 0 0 1rem;
}

strong {
  font-weight: 650;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

.steps {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
}

.steps li {
  margin-bottom: 0.6rem;
  padding-left: 0.25rem;
}

.steps li::marker {
  font-weight: 700;
  color: var(--primary);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  min-height: 56px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}

.code-input {
  font-size: 1.6rem;
  text-transform: uppercase;
  text-align: center;
  max-width: 16rem;
}

.code-input::placeholder {
  color: #b5bcc7;
}

textarea {
  resize: vertical;
  min-height: 7rem;
  font-size: 1.2rem;
}

select {
  appearance: auto;
}

.field {
  margin-top: 1.25rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.25rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid transparent;
  min-height: 56px;
  padding: 0.7rem 1.5rem;
  font-weight: 600;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

button.primary {
  background: var(--primary);
  color: #fff;
  font-size: 1.1rem;
  min-width: 12rem;
}

button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

button.secondary {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary);
}

button.secondary:hover:not(:disabled) {
  background: var(--primary-soft);
}

button.link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding-inline: 0.5rem;
  font-weight: 500;
}

button.small {
  min-height: 40px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0;
  font-weight: 600;
}

.spinner {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  border-radius: 10px;
  color: var(--error);
}

.error p {
  margin: 0;
  font-weight: 600;
}

.error .actions {
  margin-top: 1rem;
}

.field-error {
  margin: 0.6rem 0 0;
  color: var(--error);
  font-weight: 600;
}

.progress-box {
  margin-top: 0.5rem;
}

progress {
  display: block;
  width: 100%;
  height: 1.25rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--primary-soft);
}

progress::-webkit-progress-bar {
  background: var(--primary-soft);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--primary);
  border-radius: 999px;
}

.progress-text {
  margin: 0.6rem 0 0.4rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.layout-help {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: var(--primary-soft);
  border-radius: 10px;
}

.layout-help p {
  margin: 0 0 0.5rem;
}

.layout-help p:last-child {
  margin-bottom: 0;
}

.layout-help .path {
  font-weight: 600;
}

/* Wi-Fi network list */

fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  font-weight: 600;
  margin-bottom: 0.6rem;
  padding: 0;
}

.net-list {
  border: 2px solid var(--line);
  border-radius: 10px;
  max-height: 22rem;
  overflow-y: auto;
}

.net {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.8rem 0.9rem;
  min-height: 56px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.net:last-child {
  border-bottom: none;
}

.net:hover {
  background: #f9fafb;
}

.net:has(input:checked) {
  background: var(--primary-soft);
}

.net input {
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  margin: 0;
  accent-color: var(--primary);
}

.net-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.net-meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.net-open {
  font-size: 0.8rem;
  color: var(--muted);
}

.bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 1rem;
}

.bars span {
  width: 4px;
  background: var(--line);
  border-radius: 1px;
}

.bars span:nth-child(1) {
  height: 25%;
}

.bars span:nth-child(2) {
  height: 50%;
}

.bars span:nth-child(3) {
  height: 75%;
}

.bars span:nth-child(4) {
  height: 100%;
}

.bars[data-level="1"] span:nth-child(-n + 1),
.bars[data-level="2"] span:nth-child(-n + 2),
.bars[data-level="3"] span:nth-child(-n + 3),
.bars[data-level="4"] span:nth-child(-n + 4) {
  background: var(--primary);
}

.pass {
  display: flex;
  gap: 0.5rem;
}

.pass input {
  flex: 1;
  min-width: 0;
}

.pass button {
  flex: none;
  min-width: 6rem;
}

/* test + done */

.phrase {
  font-size: 1.15em;
  color: var(--primary-dark);
}

.result {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-weight: 600;
}

.result p {
  margin: 0;
}

.result[data-kind="ok"] {
  background: var(--ok-bg);
  color: var(--ok);
}

.result[data-kind="bad"] {
  background: var(--error-bg);
  color: var(--error);
}

.result[data-kind="hint"] {
  background: var(--primary-soft);
  color: var(--text);
}

.result .layout-help {
  background: #fff;
  color: var(--text);
  font-weight: 400;
}

.result .layout-help p {
  margin: 0 0 0.5rem;
}

.result .layout-help p:last-child {
  margin-bottom: 0;
}

.done-list {
  margin: 0 0 1.25rem;
  padding-left: 1.4rem;
  font-size: 1.1rem;
}

.done-list li {
  margin-bottom: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* footer / debug */

.foot {
  max-width: 40rem;
  margin: 2rem auto 2rem;
  padding: 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.foot summary {
  cursor: pointer;
}

.foot pre {
  max-height: 18rem;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.75rem;
}

@media (max-width: 30rem) {
  .card {
    padding: 1.25rem 1rem;
  }

  button.primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}
