:root {
  --bg: #0b0e14;
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #4cc38a;
  --accent-2: #3fbf9b;
  --danger: #ff6b6b;
  --chip: #121725;
  --chip-current: #1b2436;
  --chip-good: #0f2f21;
  --chip-bad: #351717;
  --panel: #0f1421;
  --border: #263147;
  --radius: 12px;
  --radius-sm: 10px;
  --shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .18);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 1px rgba(0, 0, 0, .12);
  --focus: 0 0 0 2px rgba(76, 195, 138, .35);
}

.theme-light {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #2f855a;
  --accent-2: #2b7a78;
  --chip: #f2f5f9;
  --chip-current: #e8eef7;
  --chip-good: #e6f6ef;
  --chip-bad: #fdecea;
  --panel: #fafbfc;
  --border: #dce3ea;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: radial-gradient(1200px 800px at 20% -10%, #0f1626 0%, transparent 60%),
    radial-gradient(800px 600px at 100% 0%, #101a28 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
}

.app-header,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(120%) blur(6px);
}

.app-footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
  justify-content: center;
}

.app-header h1 {
  margin: 0;
  font-size: 1.2rem;
}

.header-actions button {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, box-shadow .2s;
}

.header-actions button:hover {
  background: #182036;
  border-color: #3b4763;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
  min-height: 100vh;
  align-content: center;
}

.loader {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  height: max-content;
}

.loader h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  letter-spacing: .02em;
}

.loader textarea {
  width: 100%;
  background: #0f1320;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  box-shadow: var(--shadow-soft);
}

.loader textarea:focus-visible {
  border-color: #3a4e73;
  box-shadow: var(--focus);
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: .01em;
}

h1 {
  font-size: 1.15rem;
}

h2 {
  font-size: 1.05rem;
  color: var(--fg);
}

h3 {
  font-size: 1rem;
  color: var(--fg);
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.row .input{ flex:1; background:#0f1320; color:var(--fg); border:1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.file input{ display:none; }
.file span{ display:inline-block; padding:9px 14px; border:1px solid var(--border); border-radius: var(--radius-sm); background:#161d2e; cursor:pointer; }

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 1rem;
}

.practice {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.stats {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, .01);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.stat .label {
  color: var(--muted);
  font-weight: 500;
}

.stat .value {
  color: var(--fg);
  font-weight: 600;
  min-width: 2em;
  text-align: center;
}

.controls .status {
  margin-left: auto;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.controls .status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #7a7f88;
  box-shadow: 0 0 0 2px rgba(122, 127, 136, .15);
}

.controls .status.on::before {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(76, 195, 138, .25);
}

button {
  background: #161d2e;
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: background-color .2s, border-color .2s, box-shadow .2s, transform .04s;
}

button.primary {
  background: linear-gradient(180deg, #2a3e61, #21304a);
  border-color: #34496f;
}

button.secondary {
  background: #161d2e;
}

button:hover {
  background: #1a2438;
  border-color: #3a4e73;
  box-shadow: var(--shadow);
}

button.primary:hover {
  background: linear-gradient(180deg, #31476d, #273857);
}

button:active {
  transform: translateY(0.5px);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), rgba(255, 255, 255, 0)), #0f1320;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 86px;
  max-height: 300px;
  overflow: auto;
  box-shadow: var(--shadow-soft);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 12px, black calc(100% - 12px), transparent);
  mask-image: linear-gradient(to bottom, transparent, black 12px, black calc(100% - 12px), transparent);
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 1px rgba(0, 0, 0, .2);
  font-size: 0.95rem;
  letter-spacing: .01em;
  transition: background-color .2s, border-color .2s, box-shadow .2s;
}

.chip.punct {
  opacity: 0.7;
}

.chip.current {
  background: var(--chip-current);
  border-color: #3e5176;
  box-shadow: 0 0 0 2px rgba(76, 195, 138, .15);
}

.chip.good {
  background: var(--chip-good);
  border-color: #1e6b4f;
}

.chip.bad {
  background: var(--chip-bad);
  border-color: #6b1e1e;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.transcript {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 90px;
  max-height: 200px;
  overflow: auto;
  line-height: 1.4;
  word-wrap: break-word;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 8px, black calc(100% - 8px), transparent);
  mask-image: linear-gradient(to bottom, transparent, black 8px, black calc(100% - 8px), transparent);
}

.transcript .interim {
  color: var(--muted);
  font-style: italic;
}

/* Modal */
.modal { border:none; border-radius: var(--radius); padding:0; background: transparent; }
.modal::backdrop{ background: rgba(0,0,0,.5); }
.modal .modal-body{ background: var(--panel); border:1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 320px; box-shadow: var(--shadow); }
.modal label{ display:block; margin:8px 0; }

/* Colour-blind palette */
.cb {
  --accent: #1277b0;
  --chip-good: #0f2b3b; /* teal-blue */
  --chip-bad: #3b0f13;  /* deep red */
}
.chip.good::after{ content:" ✓"; color: var(--accent); }
.chip.bad::after{ content:" ✕"; color: #e76f51; }

@media (prefers-reduced-motion: no-preference) {
  .chip.current {
    animation: halo 2.2s ease-in-out infinite;
  }

  @keyframes halo {

    0%,
    100% {
      box-shadow: 0 0 0 2px rgba(76, 195, 138, .15);
    }

    50% {
      box-shadow: 0 0 0 4px rgba(76, 195, 138, .08);
    }
  }
}

/* sticky header with accent line */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(0, 0, 0, .12);
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(76, 195, 138, .6), transparent);
}

/* nicer scrollbars (webkit) */
.chips::-webkit-scrollbar,
.transcript::-webkit-scrollbar,
.loader textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.chips::-webkit-scrollbar-thumb,
.transcript::-webkit-scrollbar-thumb,
.loader textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .12);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.chips::-webkit-scrollbar-track,
.transcript::-webkit-scrollbar-track,
.loader textarea::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 900px) {
  .practice {
    grid-template-columns: 1fr;
  }
}
