/* ============================================================
   QUOTH — the living app-window replica (dark slate chrome,
   warm cream transcript page, khaki-gold accents).
   ============================================================ */

.app {
  position: absolute;
  width: 1280px; height: 820px;
  left: -640px; top: -410px;
  background: var(--slate);
  border: 1px solid #33393f;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 60px 140px rgba(0, 0, 0, 0.65),
    0 0 90px rgba(240, 230, 140, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  -webkit-box-reflect: below 34px linear-gradient(transparent 72%, rgba(0, 0, 0, 0.28));
  font-family: var(--grotesk);
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* shared bits */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.dot-red { background: var(--red); }
.dot-green { background: #3fb950; }
.dot-emerald { background: var(--emerald); }
.dot.pulse { animation: dotpulse 1.3s ease-in-out infinite; }
@keyframes dotpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.region { transition: filter 0.7s ease; }
.app .region:not(.r-page) { opacity: var(--chrome, 1); }
.app { border-color: rgba(51, 57, 63, calc(var(--chrome, 1))); }

/* ---------- titlebar ---------- */
.titlebar {
  height: 36px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 14px;
  background: #15181c;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.tb-left { display: flex; align-items: center; gap: 9px; }
.tb-logo {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  background: var(--gold);
  color: var(--slate);
  font-weight: 700; font-size: 11px;
  border-radius: 5px;
}
.tb-title { font-size: 11.5px; color: var(--dim); letter-spacing: 0.02em; }
.tb-win { display: flex; gap: 18px; color: #596069; font-size: 10px; }

.app-row { display: flex; flex: 1; min-height: 0; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 236px; flex: 0 0 auto;
  background: #1e2226;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sb-head {
  height: 44px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.sb-logo {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--slate);
  border-radius: 6px;
  font-weight: 700; font-size: 12px;
}
.sb-word { font-weight: 600; font-size: 13px; }
.sb-save {
  margin-left: auto;
  display: flex; align-items: center; gap: 5px;
  font-size: 9.5px; color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 8px;
}
.sb-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}
.sb-tabs span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--dim);
  padding: 8px 0 7px;
  border-bottom: 2px solid transparent;
}
.sb-tabs span.active { color: var(--gold); border-bottom-color: var(--gold); }
.sb-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.sb-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
}
.sbc-label { font-size: 8.5px; letter-spacing: 0.18em; color: #6a737d; margin-bottom: 7px; }
.sbc-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px;
  padding: 3px 0;
}
.sbc-row.muted { color: var(--dim); font-size: 10px; justify-content: space-between; }
.swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }

/* mixer */
.mixer {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
}
.mx-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 8.5px; letter-spacing: 0.18em; color: #6a737d;
  margin-bottom: 8px;
}
.mx-meters { display: flex; gap: 14px; }
.mx-ch { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.mx-track {
  position: relative;
  width: 18px; height: 92px;
  background: #0d0f12;
  border-radius: 3px;
  overflow: hidden;
  background-image:
    linear-gradient(to top, transparent 24%, rgba(255,255,255,0.08) 25%, transparent 26%,
      transparent 49%, rgba(255,255,255,0.08) 50%, transparent 51%,
      transparent 74%, rgba(255,255,255,0.08) 75%, transparent 76%);
}
.mx-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 30%;
  background: linear-gradient(to top, #3fb950 0%, #3fb950 55%, #d9e25c 75%, var(--red) 95%);
  transition: height 0.1s linear;
}
.mx-peak {
  position: absolute; left: 0; right: 0;
  height: 2px; background: #fff;
  bottom: 60%;
  transition: bottom 0.25s ease;
}
.mx-db { font-family: var(--mono); font-size: 8.5px; color: var(--dim); }

/* ---------- main column ---------- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* toolbar */
.toolbar {
  height: 54px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 0;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.tg {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  height: 34px;
}
.tg-label {
  position: absolute; top: -6px; left: 8px;
  font-size: 7.5px; letter-spacing: 0.14em;
  color: #6a737d;
  background: var(--card);
  padding: 0 4px;
}
.tg-red { border-color: rgba(215, 58, 73, 0.35); }
.tg-red .tg-label { color: #c2606c; }
.ti {
  font-style: normal;
  font-size: 11px;
  color: var(--dim);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 5px;
}
.ti:hover { background: var(--line); color: var(--text); }
.ti-rec { color: var(--red); }
.zoom-val { font-family: var(--mono); font-size: 9.5px; color: var(--dim); }
.tg-spacer { flex: 1; }
.collab-badge {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--dim);
}
.collab-badge .dot { background: #596069; transition: background 0.4s ease, box-shadow 0.4s ease; }
body[data-collab="on"] .collab-badge .dot { background: #3fb950; box-shadow: 0 0 8px rgba(63, 185, 80, 0.8); }
body[data-collab="on"] .cb-wait { display: none; }
.cb-code { color: var(--text); letter-spacing: 0.08em; }
.cb-wait { color: #6a737d; }

/* recording strip */
.recbar {
  height: 40px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: rgba(215, 58, 73, 0.05);
  border-bottom: 1px solid rgba(215, 58, 73, 0.22);
  font-size: 11px;
}
.rec-ind {
  display: flex; align-items: center; gap: 7px;
  color: var(--red);
  font-weight: 600; letter-spacing: 0.1em; font-size: 11px;
}
.rec-timer { font-family: var(--mono); font-size: 12px; color: var(--text); }
.asr-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; letter-spacing: 0.06em;
  color: #7ee0a3;
  border: 1px solid rgba(63, 185, 80, 0.35);
  border-radius: 99px;
  padding: 3px 9px;
}
.lbl-toggle { font-size: 10px; color: var(--dim); }
.lbl-toggle b { color: var(--dim); font-weight: 500; }
.lbl-toggle em { font-style: normal; color: var(--gold); font-weight: 600; }
.lbl-toggle span { margin: 0 5px; color: #495057; }
.rec-gap { flex: 1; }
.rec-btn {
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}
.rec-stop { color: #ff8a80; border-color: rgba(215, 58, 73, 0.4); }

/* tab bar */
.tabbar {
  height: 34px; flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 2px;
  padding: 0 10px;
  background: rgba(36, 41, 46, 0.5);
  border-bottom: 1px solid var(--line);
}
.tab {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px;
  color: var(--dim);
  padding: 7px 13px;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.tab-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.tab-plus { color: var(--dim); padding: 7px 9px; font-size: 12px; }

/* ---------- editor / page ---------- */
.editor {
  flex: 1; min-height: 0;
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(rgba(201, 209, 217, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  justify-content: center;
}
.page {
  position: relative;
  width: 816px;
  height: 1056px;
  flex: 0 0 auto;
  margin-top: 26px;
  transform: scale(0.78);
  transform-origin: top center;
  background: var(--cream);
  color: #3a3a3a;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    0 20px 60px rgba(0, 0, 0, 0.45);
  font-family: 'Courier New', Courier, monospace;
}
.page-frame {
  position: absolute;
  inset: 40px 46px;
  border: 1px solid #3a3a3a;
  pointer-events: none;
}
.page-num {
  position: absolute;
  top: 30px; right: 60px;
  background: var(--cream);
  padding: 0 8px;
  font-size: 15px;
  color: #3a3a3a;
}
.bm-pip {
  position: absolute;
  top: 30px; left: 60px;
  background: #3b82f6;
  color: #fff;
  font-family: var(--grotesk);
  font-size: 10px; font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
}
.page-lines {
  position: absolute;
  top: 64px; left: 0;
  width: 106px;
  text-align: right;
  font-size: 15px;
  line-height: 34.56px;
  color: #7e7860;
  user-select: none;
}
.page-body {
  position: absolute;
  top: 64px; left: 128px; right: 70px;
  font-size: 16px;
  line-height: 34.56px;
  white-space: pre-wrap;
}
.seg { position: relative; display: block; }
.seg-play {
  position: absolute;
  left: -66px; top: 9px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #3b82f6;
  opacity: 0.4;
  display: grid; place-items: center;
}
.seg-play::after {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid #fff;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  margin-left: 1.5px;
}
.seg-ts {
  position: absolute;
  left: -46px; top: 12px;
  font-size: 9px;
  color: #7e7860;
  letter-spacing: 0;
}
.sp-q, .sp-a, .sp-c { font-weight: 700; transition: color 1.1s ease; }
.sp-q { color: #3a3a3a; }
.sp-a { color: #3a3a3a; }
.sp-c { color: #3a3a3a; }
body.tinted .sp-q { color: #b23a2d; }
body.tinted .sp-a { color: #1f5faa; }
body.tinted .sp-c { color: #7b3f9c; }

.w { transition: background 0.15s ease; border-radius: 2px; }
.w.playing { background: rgba(59, 130, 246, 0.32); }
.w.played { background: rgba(59, 130, 246, 0.08); }

.live-partial { color: rgba(58, 58, 58, 0.45); }
.live-caret {
  display: inline-block;
  width: 8px; height: 17px;
  background: #3a3a3a;
  vertical-align: text-bottom;
  animation: dotpulse 1s steps(1) infinite;
}

/* fixed word (collab) */
.fixme { background: rgba(255, 138, 128, 0.5); border-radius: 2px; transition: background 0.5s ease; }
.fixme.fixed { background: rgba(63, 185, 80, 0.3); }

/* remote caret */
.remote-caret {
  position: absolute;
  width: 2.5px; height: 26px;
  background: #ff8a80;
  left: 300px; top: 300px;
  opacity: 0;
  transition: left 1s cubic-bezier(0.6, 0, 0.3, 1), top 1s cubic-bezier(0.6, 0, 0.3, 1), opacity 0.5s ease;
}
.rc-flag {
  position: absolute;
  left: 0; top: -17px;
  background: #ff8a80;
  color: #431410;
  font-family: var(--grotesk);
  font-size: 9.5px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px 3px 3px 0;
  white-space: nowrap;
}

/* ---------- player ---------- */
.player {
  flex: 0 0 auto;
  background: rgba(36, 41, 46, 0.85);
  border-top: 1px solid var(--line);
  padding: 0 0 8px;
}
.pl-scrub {
  position: relative;
  height: 3px;
  background: rgba(139, 148, 158, 0.25);
}
.pl-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 18%;
  background: rgba(240, 230, 140, 0.85);
  transition: width 0.3s linear;
}
.pl-thumb {
  position: absolute; top: 50%;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-50%, -50%);
  left: 18%;
  box-shadow: 0 0 10px rgba(240, 230, 140, 0.6);
  transition: left 0.3s linear;
}
.pl-row {
  display: flex; align-items: center;
  padding: 8px 14px 0;
  gap: 16px;
}
.pl-time { font-family: var(--mono); font-size: 10px; color: var(--dim); }
.pl-ctrls {
  display: flex; align-items: center; gap: 12px;
  margin: 0 auto;
  color: var(--dim);
  font-size: 11px;
}
.pl-play {
  font-style: normal;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: var(--gold);
  color: var(--slate);
  border-radius: 50%;
  font-size: 9px;
}
.pl-live {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px;
  color: #ff8a80;
  border: 1px solid rgba(215, 58, 73, 0.4);
  border-radius: 99px;
  padding: 3px 9px;
}

/* ---------- restore overlay + blackout ---------- */
.restore {
  position: absolute; inset: 0;
  z-index: 6;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: rgba(26, 29, 33, 0.96);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.restore.on { opacity: 1; }
.rs-spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(240, 230, 140, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rs-title { font-size: 15px; color: var(--text); }
.rs-sub { font-size: 11px; color: var(--dim); }
.rs-bar {
  width: 220px; height: 4px;
  background: rgba(139, 148, 158, 0.2);
  border-radius: 99px;
  overflow: hidden;
}
.rs-fill {
  height: 100%; width: 0%;
  background: var(--gold);
  border-radius: 99px;
}
.blackout {
  position: absolute; inset: 0;
  z-index: 7;
  background: #060708;
  opacity: 0;
  pointer-events: none;
}

/* ---------- chapter focus (blur the rest) ---------- */
body[data-chapter="1"] .r-page, body[data-chapter="1"] .r-player,
body[data-chapter="1"] .r-toolbar, body[data-chapter="1"] .r-chrome {
  filter: blur(2.5px) brightness(0.6) saturate(0.8);
}
body[data-chapter="2"] .r-side, body[data-chapter="2"] .r-toolbar,
body[data-chapter="2"] .r-rec, body[data-chapter="2"] .r-chrome, body[data-chapter="2"] .r-player,
body[data-chapter="3"] .r-side, body[data-chapter="3"] .r-toolbar,
body[data-chapter="3"] .r-rec, body[data-chapter="3"] .r-chrome,
body[data-chapter="4"] .r-side, body[data-chapter="4"] .r-rec,
body[data-chapter="4"] .r-player, body[data-chapter="4"] .r-chrome {
  filter: blur(2.5px) brightness(0.6) saturate(0.8);
}
