:root {
  --bg: #0e0f12;
  --bg-2: #17181d;
  --bg-3: #1f2128;
  --bg-4: #282b34;
  --border: #2a2d36;
  --text: #e9eaee;
  --text-dim: #9aa0ae;
  --accent: #ff7a3c;
  --accent-dim: #8f4722;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --err: #f0526b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button {
  font-family: inherit; font-size: 15px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 10px;
  cursor: pointer; transition: all .15s;
  min-height: 44px;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary {
  background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600;
}
button.primary:hover:not(:disabled) { background: #ff8f5a; }
button.danger { border-color: #5a1a25; color: var(--err); }
button.big {
  padding: 16px 24px; font-size: 16px; font-weight: 600;
}
input, textarea {
  font-family: inherit; font-size: 16px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 14px 16px; border-radius: 10px;
  width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }

.login {
  max-width: 380px; margin: 15vh auto; padding: 32px 24px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
}
.login h1 { margin: 0 0 8px; font-size: 22px; }
.login p { color: var(--text-dim); font-size: 14px; margin: 0 0 24px; }
.login form { display: flex; gap: 8px; flex-direction: column; }
.login .err { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ============ Layout ============ */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

/* Top bar on mobile only */
.topbar { display: none; }

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-header {
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sidebar-header h1 {
  margin: 0 0 6px; font-size: 16px; font-weight: 700; letter-spacing: -.01em;
}
.progress-wrap {
  margin-top: 10px;
}
.progress-label {
  font-size: 12px; color: var(--text-dim); margin-bottom: 6px;
  display: flex; justify-content: space-between;
}
.progress-bar {
  height: 6px; background: var(--bg-4); border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--ok); transition: width .4s ease;
}
.cat { margin-bottom: 10px; }
.cat-title {
  padding: 10px 20px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-dim); font-weight: 700;
}
.q-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; cursor: pointer; font-size: 14px;
  color: var(--text-dim); border-left: 3px solid transparent;
  min-height: 44px;
  user-select: none;
}
.q-item:hover { color: var(--text); background: #ffffff05; }
.q-item.active {
  color: var(--text); background: #ffffff08; border-left-color: var(--accent);
}
.q-item.done { color: var(--text); }
.q-item .dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--border);
  box-shadow: 0 0 0 0 transparent;
}
.q-item .dot.filled { background: var(--ok); box-shadow: 0 0 0 2px rgba(62,207,142,.15); }
.q-item .dot.partial { background: var(--warn); box-shadow: 0 0 0 2px rgba(245,165,36,.15); }
.q-num {
  font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-dim);
  font-weight: 600; min-width: 32px;
}
.q-item.active .q-num { color: var(--accent); }
.q-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.sidebar-footer button { flex: 1; min-width: 0; padding: 10px 12px; font-size: 13px; }

/* ============ Main content ============ */
.main {
  padding: 44px 56px 100px;
  max-width: 880px;
  width: 100%;
}
.cat-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); font-weight: 700; margin: 0 0 10px;
}
.cat-desc {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-line;
}
.q-title {
  font-size: 28px; margin: 0 0 14px; line-height: 1.2; font-weight: 700;
  letter-spacing: -.02em;
}
.q-context {
  background: linear-gradient(180deg, #2a1d14 0%, #1e1811 100%);
  border: 1px solid #3d2517;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.55;
}
.q-context-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.q-hint {
  color: var(--text-dim); font-size: 14px; margin: 0 0 30px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-left: 3px solid var(--accent-dim);
  border-radius: 6px;
  line-height: 1.55;
}
.q-hint b { color: var(--text); }
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-dim); font-weight: 700; margin: 0 0 10px;
}
.status { font-size: 12px; color: var(--text-dim); margin-top: 6px; min-height: 16px; }
.status.saved { color: var(--ok); }

.field-group { margin-bottom: 36px; }

/* ============ Recording banner ============ */
.rec-banner {
  background: linear-gradient(180deg, #3a0f1a 0%, #1c0a10 100%);
  border: 2px solid var(--err);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 18px;
  position: relative; overflow: hidden;
  box-shadow: 0 0 40px rgba(240,82,107,.18);
  animation: bannerIn .3s ease;
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.rec-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 50%, rgba(240,82,107,.18), transparent 60%);
  pointer-events: none;
}
.rec-pulse {
  width: 18px; height: 18px; border-radius: 50%; background: var(--err);
  flex-shrink: 0; position: relative;
}
.rec-pulse::after {
  content: '';
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--err);
  animation: ring 1.4s ease-out infinite;
}
@keyframes ring {
  0% { transform: scale(.5); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}
.rec-info { flex: 1; min-width: 0; }
.rec-info .label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--err); font-weight: 700; margin-bottom: 2px;
}
.rec-info .timer {
  font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.rec-banner button.stop {
  background: var(--err); color: #fff; border: none;
  padding: 14px 24px; font-weight: 700; font-size: 15px;
  border-radius: 10px; cursor: pointer; min-height: 50px;
}
.rec-banner button.stop:hover { background: #f56a80; }

.level-meter {
  display: flex; gap: 3px; align-items: flex-end; height: 36px;
  flex: 0 1 160px; padding: 0 4px;
}
.level-bar {
  flex: 1; min-width: 3px; background: var(--bg-4); border-radius: 2px;
  height: 20%; transition: height .08s ease, background-color .08s;
}

/* ============ Recording list ============ */
.rec-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rec-list { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.rec-item {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px;
}
.rec-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.rec-meta { font-size: 12px; color: var(--text-dim); }
.rec-status {
  font-size: 11px; padding: 3px 9px; border-radius: 4px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  display: inline-flex; align-items: center; gap: 6px;
}
.rec-status.pending, .rec-status.transcribing { background: #3a2d1a; color: var(--warn); }
.rec-status.transcribing::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); animation: pulse 1s infinite;
}
.rec-status.done { background: #1a3a29; color: var(--ok); }
.rec-status.error { background: #3a1a24; color: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }
.rec-transcript {
  font-size: 14px; color: var(--text); line-height: 1.6;
  background: var(--bg-3); padding: 12px 14px; border-radius: 8px; white-space: pre-wrap;
  margin-bottom: 8px;
}
.rec-audio { width: 100%; }

.nav-buttons { display: flex; justify-content: space-between; margin-top: 44px; gap: 10px; }
.nav-buttons button { min-width: 120px; }

/* ============ Mobile ============ */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .topbar {
    display: flex;
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    gap: 12px; align-items: center;
    backdrop-filter: blur(8px);
  }
  .hamburger {
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
    cursor: pointer; flex-shrink: 0;
  }
  .hamburger svg { width: 22px; height: 22px; stroke: var(--text); }
  .topbar-title {
    flex: 1; min-width: 0; font-size: 13px; color: var(--text);
    overflow: hidden;
  }
  .topbar-title .num {
    color: var(--accent); font-weight: 700; font-size: 11px; text-transform: uppercase;
    letter-spacing: .06em;
  }
  .topbar-title .name {
    display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 600;
  }
  .topbar-progress {
    font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums;
    flex-shrink: 0; padding-left: 4px;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 86%; max-width: 340px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 150; backdrop-filter: blur(2px);
  }
  .backdrop.open { display: block; }
  .main { padding: 20px 18px 80px; }
  .q-title { font-size: 22px; }
  .rec-banner {
    padding: 16px; gap: 12px;
  }
  .rec-info .timer { font-size: 24px; }
  .level-meter { display: none; }
  .rec-banner button.stop { padding: 12px 16px; font-size: 14px; }
  .nav-buttons button { min-width: 0; flex: 1; padding: 14px 16px; }
}

@media (max-width: 420px) {
  .topbar-title .name { font-size: 12px; }
  .main { padding: 16px 14px 80px; }
  .q-title { font-size: 20px; }
}
