/* ============================================================
   SonicScribe — Dark Theme
   ============================================================ */
:root {
  --bg:       #0d0d0d;
  --surface:  #161616;
  --card:     #1e1e1e;
  --border:   #2e2e2e;
  --text:     #e4e4e4;
  --muted:    #888;
  --primary:  #ff9800;
  --success:  #4caf50;
  --danger:   #f44336;
  --info:     #2196f3;
  --purple:   #9c27b0;
  --cyan:     #00bcd4;
  --warning:  #ff9800;
  --radius:   10px;
  --shadow:   0 4px 20px rgba(0,0,0,.4);
  --trans:    .18s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { opacity: .8; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 16px;
}
.brand { font-size: 1.05rem; font-weight: 700; color: var(--primary); white-space: nowrap; }
.nav-links { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav-links a, .nav-right a.nav-icon {
  color: var(--muted); padding: 7px 12px; border-radius: 7px;
  transition: all var(--trans); font-size: .88rem; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active,
.nav-right a.nav-icon:hover, .nav-right a.nav-icon.active {
  color: var(--text); background: #ffffff12;
}
.nav-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.nav-user { color: var(--muted); font-size: .85rem; }
.nav-pending { color: #ffcc80; font-size: .82rem; opacity: .8; }
.nav-icon { font-size: 1.1rem; }

/* ── Layout ─────────────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }
main.container { min-height: calc(100vh - 58px); }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }

.two-col   { display: grid; grid-template-columns: 1fr 1fr;  gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.four-col  { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.two-col-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 900px) {
  .two-col, .three-col, .four-col, .two-col-form { grid-template-columns: 1fr; }
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.card-header-row { display: flex; align-items: center; justify-content: space-between;
                    margin-bottom: 14px; gap: 8px; }
.card-header-row .card-title { margin-bottom: 0; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: .87rem; font-weight: 600; transition: all var(--trans);
  text-decoration: none; white-space: nowrap; line-height: 1;
}
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn:not(:disabled):hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0) !important; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-full { width: 100%; }

.btn-primary  { background: var(--primary);  color: #000; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-info     { background: var(--info);     color: #fff; }
.btn-purple   { background: var(--purple);   color: #fff; }
.btn-cyan     { background: var(--cyan);     color: #000; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:not(:disabled):hover { color: var(--text); border-color: #555; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: .83rem;
                    color: var(--muted); font-weight: 500; }
.form-group label small { font-weight: 400; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px;
                  cursor: pointer; color: var(--text) !important; font-size: .87rem !important; }
.checkbox-label input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
select, textarea {
  width: 100%; padding: 9px 13px; background: #141414; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .87rem;
  transition: border-color var(--trans); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
.select-inline { width: auto; padding: 6px 10px; font-size: .85rem; }

.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 38px; }
.toggle-vis {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted); font-size: .9rem;
  padding: 4px;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-error   { background: rgba(244,67,54,.15);   border: 1px solid rgba(244,67,54,.4);   color: #ef9a9a; }
.alert-success { background: rgba(76,175,80,.15);   border: 1px solid rgba(76,175,80,.4);   color: #a5d6a7; }
.alert-warning { background: rgba(255,152,0,.12);   border: 1px solid rgba(255,152,0,.35);  color: #ffcc80; }
.alert-info    { background: rgba(33,150,243,.12);  border: 1px solid rgba(33,150,243,.35); color: #90caf9; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: .88rem; }
.notice-warning { background: rgba(255,152,0,.1);  border: 1px solid rgba(255,152,0,.3);  color: #ffcc80; }
.notice-info    { background: rgba(33,150,243,.1); border: 1px solid rgba(33,150,243,.3); color: #90caf9; }
.notice-info code { background: rgba(33,150,243,.2); padding: 1px 6px; border-radius: 4px; font-family: monospace; }

/* ── Site footer notices ───────────────────────────────────────────────── */
.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding: 0 24px 24px;
}
.footer-notice {
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: .82rem;
  line-height: 1.5;
}
.footer-notice--warning { background: rgba(255,152,0,.08);  border: 1px solid rgba(255,152,0,.25);  color: #bba870; }
.footer-notice--info    { background: rgba(33,150,243,.07); border: 1px solid rgba(33,150,243,.22); color: #7a9fbf; }

/* ── Progress ────────────────────────────────────────────── */
.progress-bar { background: var(--border); border-radius: 6px; height: 6px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; width: 0%; transition: width .4s ease;
                 border-radius: 6px; }

/* ── Item list (sidebar lists) ───────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; }
.item-list-entry {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; background: var(--surface);
  border: 1px solid var(--border); transition: all var(--trans);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.item-list-entry:hover { border-color: var(--primary); background: rgba(255,152,0,.06); }
.item-list-entry.active { border-color: var(--primary); background: rgba(255,152,0,.12); }
.item-list-entry__title { font-size: .88rem; font-weight: 600; overflow: hidden;
                           text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.item-list-entry__meta  { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.item-list-entry__del { background: none; border: none; color: var(--muted); cursor: pointer;
                         padding: 2px 6px; border-radius: 4px; font-size: .9rem; }
.item-list-entry__del:hover { color: var(--danger); background: rgba(244,67,54,.12); }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge-blue   { background: rgba(33,150,243,.2);  color: #90caf9; }
.badge-green  { background: rgba(76,175,80,.2);   color: #a5d6a7; }
.badge-orange { background: rgba(255,152,0,.2);   color: #ffcc80; }
.badge-purple { background: rgba(156,39,176,.2);  color: #ce93d8; }
.badge-red    { background: rgba(244,67,54,.2);   color: #ef9a9a; }
.badge-grey   { background: rgba(255,255,255,.08); color: #aaa; }

/* ── Admin table ───────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr.row-disabled td { opacity: .45; }
.admin-table tr.row-pending { background: rgba(255,152,0,.04); }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-warning { background: rgba(255,152,0,.15); color: #ffcc80; border: 1px solid rgba(255,152,0,.3); }
.btn-warning:hover { background: rgba(255,152,0,.25); }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center;
             min-height: 100vh; background: var(--bg); }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
             padding: 40px 36px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-logo   { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.auth-title  { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-subtitle { color: var(--muted); text-align: center; margin-bottom: 24px; font-size: .9rem; }
.auth-form .btn-full { margin-top: 6px; padding: 12px; font-size: .95rem; }
.auth-switch { text-align: center; margin-top: 20px; font-size: .88rem; color: var(--muted); }

/* ── Dashboard ───────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
@media (max-width: 800px) { .dashboard-grid { grid-template-columns: 1fr; } }

.dash-card {
  display: flex; align-items: flex-start; gap: 20px; padding: 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  text-decoration: none; color: var(--text); transition: all var(--trans);
  border-left: 4px solid transparent;
}
.dash-card:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,.5); }
.dash-card--green  { border-left-color: var(--success); }
.dash-card--orange { border-left-color: var(--primary); }
.dash-card--blue   { border-left-color: var(--info); }
.dash-card--purple { border-left-color: var(--purple); }
.dash-card__icon { font-size: 2.2rem; }
.dash-card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.dash-card p  { color: var(--muted); font-size: .85rem; line-height: 1.5; margin-bottom: 10px; }
.dash-card__stat { font-size: .8rem; color: var(--primary); font-weight: 600; }

/* ── Dropzone (file upload) ──────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 28px 20px;
  text-align: center; cursor: pointer; transition: all var(--trans); background: #111;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--primary); background: rgba(255,152,0,.05); }
.dropzone__icon { font-size: 2rem; margin-bottom: 8px; }
.dropzone p { color: var(--muted); font-size: .88rem; margin: 2px 0; }
.dropzone .link { color: var(--primary); }

/* ── Meta tags (transcription info) ─────────────────────── */
.meta-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meta-tag  { padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 500;
              background: rgba(33,150,243,.15); color: #90caf9; border: 1px solid rgba(33,150,243,.3); }

/* ── Stream output ───────────────────────────────────────── */
.stream-output {
  min-height: 160px; max-height: 540px; overflow-y: auto;
  background: #111; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; font-size: .87rem; line-height: 1.7; white-space: pre-wrap;
  word-break: break-word; color: var(--text); font-family: inherit;
}

/* ── Char count ──────────────────────────────────────────── */
.char-count { font-size: .78rem; color: var(--muted); text-align: right; margin-top: 4px; }

/* ── Modals ─────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 400; display: flex;
          align-items: center; justify-content: center; padding: 20px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.65);
                  backdrop-filter: blur(2px); }
.modal-box {
  position: relative; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); z-index: 1;
}
.modal-box--sm { max-width: 420px; }
.modal-box--lg { max-width: 860px; }
.modal-header  { display: flex; align-items: center; justify-content: space-between;
                  margin-bottom: 18px; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close   { background: none; border: none; color: var(--muted); cursor: pointer;
                  font-size: 1.3rem; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--border); }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
            padding-bottom: 0; }
.tab { padding: 8px 16px; background: none; border: none; color: var(--muted); cursor: pointer;
       font-size: .88rem; font-weight: 600; border-bottom: 2px solid transparent;
       transition: all var(--trans); margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Story layout ────────────────────────────────────────── */
.story-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.story-sidebar { position: sticky; top: 78px; }
@media (max-width: 1000px) { .story-layout { grid-template-columns: 1fr; }
  .story-sidebar { position: static; } }

.chapters-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.chapters-sidebar .item-list { max-height: 350px; }
@media (max-width: 900px) { .chapters-layout { grid-template-columns: 1fr; } }

details { margin-top: 4px; }
details summary.details-summary {
  cursor: pointer; color: var(--muted); font-size: .85rem; padding: 6px 0;
  list-style: none; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
details summary.details-summary::before { content: '▶'; font-size: .7rem; transition: transform var(--trans); }
details[open] summary.details-summary::before { transform: rotate(90deg); }

/* ── Sections list (TTS) ─────────────────────────────────── */
.sections-list { display: flex; flex-direction: column; gap: 8px; }
.section-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: all var(--trans);
}
.section-item:hover { border-color: var(--primary); }
.section-item__drag { color: var(--muted); cursor: grab; font-size: 1rem; }
.section-item__body { flex: 1; overflow: hidden; }
.section-item__title { font-size: .85rem; font-weight: 600; }
.section-item__meta  { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.section-item__preview { font-size: .78rem; color: var(--muted); overflow: hidden;
                          text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }

/* ── Chat layout ─────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px;
                height: calc(100vh - 100px); }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; height: auto; } }
.chat-sidebar .card  { height: 100%; display: flex; flex-direction: column; }
.chat-main .card     { height: 100%; display: flex; flex-direction: column; }

.messages-area {
  flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 14px;
}
.message { display: flex; gap: 10px; }
.message.user   { flex-direction: row-reverse; }
.message__bubble {
  max-width: 78%; padding: 12px 16px; border-radius: 12px; font-size: .88rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.message.user .message__bubble   { background: rgba(255,152,0,.18); border: 1px solid rgba(255,152,0,.3); }
.message.assistant .message__bubble { background: var(--surface); border: 1px solid var(--border); }
.message__avatar { width: 32px; height: 32px; border-radius: 50%; display: flex;
                    align-items: center; justify-content: center; font-size: .9rem;
                    background: var(--border); flex-shrink: 0; }

.chat-input-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px;
                   padding-top: 12px; border-top: 1px solid var(--border); }
.chat-input-row textarea { flex: 1; resize: none; max-height: 120px; }

/* ── Settings ────────────────────────────────────────────── */
.settings-section  { margin-bottom: 16px; }
.settings-heading  { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.settings-desc     { color: var(--muted); font-size: .83rem; margin-bottom: 14px; }

/* ── Misc ────────────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-center { text-align: center; }
.quick-settings-notice { margin-top: 20px; }
