/* Kokoro TTS · dark studio console
   Shape rule: panels 16px, controls 10px, chips pill. One accent: amber. */

:root {
  --bg: #111110;
  --panel: #181715;
  --panel-2: #141311;
  --border: #2b2926;
  --border-strong: #3d3a35;
  --text: #eae7e1;
  --muted: #9b958b;
  --muted-2: #7d776e;
  --accent: #e0a25c;
  --accent-hover: #e8ad67;
  --accent-ink: #1d1408;
  --accent-soft: rgba(224, 162, 92, 0.12);
  --ok: #7dbd94;
  --err: #e08585;
  --r-panel: 16px;
  --r-ctl: 10px;
  --r-pill: 999px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 20px 72px;
}

/* Masthead */
.masthead {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand-mark {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.brand-mark .brand-accent { color: var(--accent); }

.brand-sub {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  max-width: 60ch;
}

/* Workspace grid */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.console { padding: 20px; }

/* Compose */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  min-height: 156px;
  resize: vertical;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 12px 14px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
textarea::placeholder { color: #8a847a; }
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.count {
  text-align: right;
  color: var(--muted-2);
  font-size: 0.75rem;
  font-family: var(--mono);
  margin-top: 6px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

select {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 9px 10px;
  font: inherit;
  font-size: 0.88rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
}
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}
input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#submit {
  width: 100%;
  white-space: nowrap;
  padding: 11px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--r-ctl);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
#submit:hover { background: var(--accent-hover); }
#submit:active { transform: scale(0.985); }
#submit:disabled { opacity: 0.45; cursor: not-allowed; }

/* Result */
.result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hidden { display: none; }

.status {
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.86rem;
}

audio { width: 100%; }

.btn-ghost {
  align-self: flex-start;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Monitor */
.monitor {
  padding: 16px 18px 10px;
  position: sticky;
  top: 18px;
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-meta {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: nowrap;
}

.monitor-body {
  overflow-y: auto;
  margin: 0 -6px;
  padding: 0 6px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.m-group {
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 14px 0 2px;
}
.m-group:first-child { margin-top: 2px; }

.m-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.m-row:first-of-type { border-top: none; }

.m-main { min-width: 0; }

.m-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.m-sub {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46ch;
}

.m-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  white-space: nowrap;
  font-size: 0.78rem;
}

.m-actions { display: flex; gap: 6px; }

.num { font-family: var(--mono); font-size: 0.75rem; color: var(--muted-2); }

.chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.chip-run { background: var(--accent-soft); color: var(--accent); }
.chip-queue { background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.chip-done { background: rgba(125, 189, 148, 0.14); color: var(--ok); }
.chip-error { background: rgba(224, 133, 133, 0.14); color: var(--err); }

.m-progress {
  grid-column: 1 / -1;
  height: 2px;
  border-radius: 1px;
  background: var(--border);
  overflow: hidden;
  margin-top: -4px;
}
.m-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.6s var(--ease);
}

.mini {
  font: inherit;
  font-size: 0.76rem;
  line-height: 1.1;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.mini:hover { border-color: var(--accent); color: var(--accent); }

.m-empty {
  padding: 22px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Skeleton */
.sk-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 72px;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
}
.sk {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #1f1e1b 25%, #2a2824 50%, #1f1e1b 75%);
  background-size: 200% 100%;
  animation: sk 1.4s linear infinite;
}
@keyframes sk { to { background-position: -200% 0; } }

/* Docs */
.docs { margin-top: 18px; padding: 18px 20px; }

summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
summary::-webkit-details-marker { display: none; }
summary h2 { margin: 0; font-size: 0.95rem; font-weight: 600; display: inline; }

.docs-body { margin-top: 16px; }
.docs-body p { margin: 10px 0; color: var(--muted); font-size: 0.86rem; max-width: 72ch; }
.docs-body h3 { margin: 20px 0 8px; font-size: 0.88rem; font-weight: 600; }

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin-top: 12px;
}
.docs-table th {
  text-align: left;
  padding: 0 12px 8px 0;
  color: var(--muted-2);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.docs-table td { padding: 9px 12px 9px 0; vertical-align: top; }

.docs code {
  font-family: var(--mono);
  font-size: 0.76rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

.docs pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-ctl);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0 0;
}
.docs pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.76rem;
  line-height: 1.7;
  white-space: pre;
}

.m-get { font-family: var(--mono); font-size: 0.72rem; font-weight: 600; color: var(--ok); }
.m-post { font-family: var(--mono); font-size: 0.72rem; font-weight: 600; color: var(--accent); }

/* Motion (motivated only, reduced-motion safe) */
@media (prefers-reduced-motion: no-preference) {
  .panel { animation: rise 0.5s var(--ease) backwards; }
  .grid .panel:nth-child(1) { animation-delay: 0.03s; }
  .grid .panel:nth-child(2) { animation-delay: 0.09s; }
  .docs { animation: rise 0.5s var(--ease) 0.15s backwards; }
  .chip-run { animation: pulse 2.2s ease-in-out infinite; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}
@keyframes pulse {
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

/* Responsive */
@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .monitor {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
  .shell { padding: 20px 14px 56px; }
  .m-sub { max-width: 34ch; }
}

/* PIN Gate & Auth */
.pinGate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 50%),
    linear-gradient(180deg, var(--bg), #080807);
}

.pinGate[hidden] {
  display: none !important;
}

.pinBox {
  width: min(400px, 100%);
  padding: 36px 30px;
  border-radius: var(--r-panel);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.pinBox .kicker {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
}

.pinBox h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}

.pinBox p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.pinBox label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
}

.pinBox input {
  width: 100%;
  min-height: 48px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 16px;
  outline: none;
  font-size: 22px;
  letter-spacing: 0.35em;
  text-align: center;
  font-family: var(--mono);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.pinBox input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pin-btn {
  width: 100%;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--r-ctl);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s var(--ease), transform 0.14s var(--ease);
}

.pin-btn:hover {
  background: var(--accent-hover);
}

.pin-btn:active {
  transform: scale(0.985);
}

.pinError {
  min-height: 20px;
  color: var(--err) !important;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  margin: 0 !important;
}
