:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5c667a;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #f4f7fb;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #9a3412;
  --ok: #166534;
  --touch: 56px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  background: var(--ink);
  color: white;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8bd3cc;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.15rem;
}

.brand-home {
  display: grid;
  gap: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  padding: 0 12px;
  font-weight: 800;
}

.status-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 0 10px;
  color: #e8fff8;
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-badge.offline {
  color: #ffe8d0;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 1.4rem;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 14px 32px rgba(20, 33, 61, 0.08);
}

.section-heading p {
  color: var(--muted);
  line-height: 1.45;
}

.exercise-note {
  display: grid;
  gap: 6px;
  margin: 14px 0 16px;
  border: 1px solid #b7ddd8;
  border-radius: 8px;
  padding: 12px;
  background: #edf7f6;
}

.exercise-note h2 {
  margin: 0;
}

.exercise-note p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.settings {
  display: grid;
  gap: 12px;
}

.settings label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.settings input,
.settings select {
  min-height: var(--touch);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 1.05rem;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-row input {
  width: 26px;
  height: 26px;
  min-height: 26px;
}

.primary-button,
.secondary-button {
  min-height: var(--touch);
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: white;
}

.primary-button:active {
  background: var(--accent-strong);
}

.primary-button:disabled {
  background: #a6b8b6;
}

.secondary-button {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.history-block,
.dashboard-block {
  margin-top: 24px;
}

.dashboard-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.dashboard-grid article {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcff;
}

.dashboard-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dashboard-grid strong {
  font-size: 1.35rem;
}

.history-list,
.round-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.history-list li,
.round-list li {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcff;
}

small {
  color: var(--muted);
}

.practice-panel {
  display: grid;
  gap: 14px;
}

.round-topline,
.listen-card,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.round-topline {
  color: var(--muted);
  font-weight: 700;
}

.listen-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #edf7f6;
  color: var(--accent-strong);
  font-weight: 800;
}

.answer-box {
  position: relative;
  min-height: 76px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  background: white;
}

#answer-display {
  display: block;
  min-width: 100%;
  font-size: 2rem;
  line-height: 1.2;
  word-break: break-all;
}

#answer-display:empty::before {
  content: attr(data-placeholder);
  color: #8b96a8;
  font-size: 1.1rem;
}

#paste-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad button {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(20, 33, 61, 0.08);
  touch-action: manipulation;
  will-change: transform;
}

.keypad button:active {
  transform: translateY(1px);
  background: #eef3fa;
}

.feedback {
  display: grid;
  gap: 8px;
  border-radius: 8px;
  padding: 12px;
}

.feedback.success {
  border: 1px solid #86efac;
  background: #f0fdf4;
  color: var(--ok);
}

.feedback.warning {
  border: 1px solid #fdba74;
  background: #fff7ed;
  color: var(--warn);
}

.feedback dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.feedback div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
}

.feedback dt {
  color: var(--muted);
}

.feedback dd {
  margin: 0;
  word-break: break-all;
}

.action-row .primary-button,
.action-row .secondary-button {
  flex: 1;
  margin-top: 0;
}

.results-actions {
  margin-top: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.summary-grid article {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.summary-grid span {
  color: var(--muted);
  font-weight: 700;
}

.summary-grid strong {
  font-size: 1.5rem;
}

@media (min-width: 720px) {
  .app-header {
    padding-inline: calc((100% - 760px) / 2 + 18px);
  }

  .app-shell {
    padding-block: 24px;
  }

  .settings {
    grid-template-columns: repeat(2, 1fr);
  }

  .keypad button {
    min-height: 74px;
  }
}
