:root {
  --bg: #0a0b0f;
  --bg2: #101218;
  --card: #14161e;
  --card2: #191c26;
  --line: #262a36;
  --text: #e8eaf0;
  --dim: #898fa3;
  --accent: #6ee7b7;
  --accent2: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(110,231,183,0.09), transparent 60%),
    radial-gradient(800px 400px at 90% 0%, rgba(96,165,250,0.07), transparent 60%);
}

/* ── top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,11,15,0.82);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 14px; }

.mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #3b82f6);
  box-shadow: 0 0 24px rgba(110,231,183,0.35);
  flex-shrink: 0;
}

.brand h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.brand p { font-size: 12px; color: var(--dim); margin-top: 2px; }

.tabs { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 10px; border: 1px solid var(--line); }

.tab {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--card2); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }

/* ── layout ── */
main { position: relative; z-index: 1; padding: 26px 28px 60px; max-width: 1320px; margin: 0 auto; }

.panel { display: none; }
.panel.active { display: block; animation: fade 0.22s ease; }

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

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 940px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.card h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── fields ── */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--dim); margin-bottom: 6px; }
.field em { font-style: normal; color: #5b6176; font-weight: 400; }

textarea, input[type=text], input[type=number], input[type=search], select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.12);
}

.field small { display: block; text-align: right; font-size: 11px; color: #5b6176; margin-top: 5px; }
.field small.over { color: var(--danger); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── chips ── */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }

.chip {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent2); color: var(--accent); }

/* ── buttons ── */
.primary {
  width: 100%;
  background: linear-gradient(145deg, var(--accent), var(--accent2));
  border: 0;
  color: #06231a;
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.primary:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(110,231,183,0.28); transform: translateY(-1px); }
.primary:disabled { opacity: 0.55; cursor: not-allowed; }

.ghost {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.15s;
}
.ghost:hover { border-color: var(--accent2); }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(6,35,26,0.28);
  border-top-color: #06231a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.hint { font-size: 11.5px; color: #5b6176; margin-top: 10px; line-height: 1.5; }

/* ── result ── */
.empty {
  border: 1px dashed var(--line);
  border-radius: 11px;
  padding: 40px 20px;
  text-align: center;
  color: #5b6176;
  font-size: 12.5px;
}
.wave-placeholder {
  height: 44px;
  margin-bottom: 16px;
  border-radius: 6px;
  background: repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 8px);
  opacity: 0.45;
}

audio { width: 100%; margin-bottom: 16px; border-radius: 9px; }

.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.meta > div { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.meta dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #5b6176; margin-bottom: 4px; }
.meta dd { font-size: 13px; font-weight: 550; }

.actions { display: flex; gap: 9px; margin-bottom: 16px; }

details { border-top: 1px solid var(--line); padding-top: 14px; }
summary { font-size: 12px; color: var(--dim); cursor: pointer; }
pre {
  margin-top: 10px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 11px;
  color: #9fb3c8;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.55;
}

.error {
  background: rgba(248,113,113,0.09);
  border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5;
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-word;
}

/* ── history ── */
.history-card { margin-top: 20px; }

.history { display: flex; flex-direction: column; gap: 9px; }

.hist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 12.5px;
}
.hist-item .txt { flex: 1; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-item .ms { color: #5b6176; font-size: 11px; font-variant-numeric: tabular-nums; }

.badge {
  background: var(--card2);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}

/* ── library ── */
.lib-controls { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.lib-controls input { flex: 1; }
.lib-controls select { width: 180px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

.voice-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  transition: border-color 0.16s, transform 0.16s;
  cursor: pointer;
}
.voice-card:hover { border-color: var(--accent2); transform: translateY(-2px); }
.voice-card .vn { font-size: 13px; font-weight: 580; margin-bottom: 5px; }
.voice-card .vm { font-size: 11px; color: #5b6176; display: flex; gap: 7px; flex-wrap: wrap; }
.voice-card .tag {
  background: var(--card2);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── tests ── */
.test-results { display: flex; flex-direction: column; gap: 9px; max-height: 420px; overflow-y: auto; }

.test-row {
  display: grid;
  grid-template-columns: 62px 1fr 74px;
  gap: 11px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 12px;
}
.test-row.ok { border-color: rgba(110,231,183,0.32); }
.test-row.bad { border-color: rgba(248,113,113,0.32); }
.test-row .c { color: var(--dim); font-variant-numeric: tabular-nums; }
.test-row .bar { height: 6px; background: var(--card2); border-radius: 3px; overflow: hidden; }
.test-row .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.test-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

table.limits { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.limits th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #5b6176;
  font-weight: 500;
  padding: 0 12px 9px 0;
  border-bottom: 1px solid var(--line);
}
table.limits td { padding: 10px 12px 10px 0; border-bottom: 1px solid rgba(38,42,54,0.55); color: var(--dim); }
table.limits td:first-child { color: var(--text); font-weight: 520; }
table.limits tr:last-child td { border-bottom: 0; }
