/* ============================================================
   York Voices — "audio studio console"
   Warm near-black · gold accent · Manrope / JetBrains Mono
   ============================================================ */

:root {
  --bg: #0d1210;
  --bg-2: #101613;
  --panel: #141b17;
  --panel-2: #19231d;
  --panel-3: #202d25;
  --border: #29392f;
  --border-soft: #202c25;

  --text: #e8efe9;
  --muted: #8fa197;
  --faint: #62746a;

  --accent: #3fc07f;      /* emerald green */
  --accent-hi: #57d497;
  --accent-ink: #05130c;  /* text on green */
  --accent-glow: rgba(63, 192, 127, 0.28);
  --teal: #d3a24e;        /* warm secondary accent */
  --err: #e97a6d;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-lift: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 1px rgba(232, 176, 75, 0.25), 0 8px 30px -8px var(--accent-glow);
  --font: "Manrope", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(1100px 600px at 78% -10%, rgba(63, 192, 127, 0.10), transparent 60%),
    radial-gradient(900px 500px at 8% 8%, rgba(63, 192, 127, 0.05), transparent 55%),
    var(--bg);
  min-height: 100vh;
  letter-spacing: 0.005em;
}

/* film grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.82rem; }
.err { color: var(--err); font-size: 0.82rem; margin-top: 6px; min-height: 1em; font-weight: 500; }
.mt { margin-top: 30px; }
code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--accent-hi);
}

/* ---------- login ---------- */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 34px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lift);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.login-card h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.login-card h1::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(19, 17, 16, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand-dot { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* main navigation */
.mainnav { display: flex; gap: 4px; padding: 4px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 11px; }
.navtab {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 0.86rem; font-weight: 600;
  transition: 0.18s;
}
.navtab:hover { color: var(--text); }
.navtab.active { background: var(--panel-3); color: var(--accent-hi); box-shadow: inset 0 0 0 1px var(--border); }
@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; gap: 12px; }
  .mainnav { order: 3; width: 100%; }
  .navtab { flex: 1; }
}

.view { animation: rise 0.4s ease both; }
.grid-single { max-width: 760px; margin: 0 auto; padding: 28px; }
@media (max-width: 880px) { .grid-single { padding: 18px; } }
.pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 5px 11px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* animated equalizer mark */
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.eq i {
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  animation: eq 1.1s ease-in-out infinite;
}
.eq i:nth-child(1) { height: 40%; animation-delay: -0.9s; }
.eq i:nth-child(2) { height: 90%; animation-delay: -0.5s; }
.eq i:nth-child(3) { height: 60%; animation-delay: -0.2s; }
.eq i:nth-child(4) { height: 100%; animation-delay: -0.7s; }
.eq i:nth-child(5) { height: 50%; animation-delay: -0.35s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }

/* ---------- layout ---------- */
.grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
  padding: 28px;
  max-width: 1240px;
  margin: 0 auto;
}
@media (max-width: 880px) { .grid { grid-template-columns: 1fr; padding: 18px; } }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lift);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.panel:nth-child(2) { animation-delay: 0.08s; }
.panel h2 {
  margin: 0 0 18px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }
.field.small { flex: 1; }

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: inherit;
  font-size: 0.95rem;
  width: 100%;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
textarea { resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--panel-3);
}
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238fa197' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.row { display: flex; gap: 11px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row select, .row input { flex: 1; }

/* mono for technical selects (model / voices) */
#model, #presetVoice, #libraryVoice, #style { font-family: var(--mono); font-size: 0.86rem; }

/* range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 5px; padding: 0; border: none; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 50%, var(--panel-3) 50%);
  box-shadow: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--accent-hi); border: 3px solid var(--bg-2);
  box-shadow: 0 0 0 1px var(--accent), 0 2px 8px var(--accent-glow); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent-hi);
  border: 3px solid var(--bg-2); cursor: pointer;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 5px; margin: 4px 0 18px; padding: 5px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 12px; }
.tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 9px 8px; border-radius: 8px; cursor: pointer; font-size: 0.84rem; font-weight: 600;
  transition: 0.18s; letter-spacing: 0.01em;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink); box-shadow: 0 4px 14px -4px var(--accent-glow);
}

/* ---------- buttons ---------- */
button {
  cursor: pointer; border: none; border-radius: var(--radius-sm);
  padding: 11px 17px; font: inherit; font-weight: 600;
  background: var(--panel-3); color: var(--text);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

button.primary, button[type="submit"] {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 6px 20px -6px var(--accent-glow);
}
button.primary:hover, button[type="submit"]:hover {
  box-shadow: 0 10px 28px -6px var(--accent-glow); filter: brightness(1.04);
}
button.primary {
  width: 100%; padding: 15px; margin-top: 8px; font-size: 1rem;
  letter-spacing: 0.01em; border-radius: 12px;
}
button.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent-hi); background: var(--panel-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: grayscale(0.3); }

#reloadModels { flex: 0 0 auto; width: 44px; height: 44px; padding: 0; font-size: 1.1rem; display: grid; place-items: center; }

/* ---------- style box ---------- */
.style-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 16px; background: var(--bg-2);
}
.style-box summary {
  cursor: pointer; color: var(--muted); font-size: 0.86rem; font-weight: 600;
  user-select: none; list-style: none; display: flex; align-items: center; gap: 8px;
}
.style-box summary::before { content: "▸"; color: var(--accent); transition: transform 0.2s; }
.style-box[open] summary::before { transform: rotate(90deg); }
.style-box[open] summary { margin-bottom: 14px; color: var(--text); }
.style-box summary::-webkit-details-marker { display: none; }

/* ---------- add voice ---------- */
.add-voice { display: flex; flex-direction: column; gap: 11px; margin-bottom: 20px; }
input[type="file"] { padding: 9px 12px; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: 0.82rem;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; margin-right: 12px; cursor: pointer; transition: 0.18s;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent-hi); }
#recBtn.recording { background: var(--err); color: #fff; border-color: var(--err); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(233, 122, 109, 0.5); } 50% { box-shadow: 0 0 0 6px rgba(233, 122, 109, 0); } }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 11px; }
.card {
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 14px 16px;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  animation: rise 0.45s ease both;
}
.card:hover { transform: translateY(-2px); border-color: var(--border); box-shadow: var(--shadow-lift); }
.card .card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card .name { font-weight: 700; font-size: 0.95rem; line-height: 1.35; }
.card .sub { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); margin-top: 4px; letter-spacing: 0.01em; }
.card-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.card-actions button { padding: 6px 11px; font-size: 0.78rem; }
.card audio { width: 100%; margin-top: 12px; height: 38px; border-radius: 8px; }
.card audio::-webkit-media-controls-panel { background: var(--panel-3); }
.link {
  color: var(--accent-hi); text-decoration: none; font-size: 0.9rem; font-weight: 700;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; transition: 0.18s;
}
.link:hover { border-color: var(--accent); background: var(--panel-3); }
.empty { color: var(--faint); font-size: 0.85rem; padding: 14px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--panel-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
