/* =====================================================================
   Meeting Copilot — design system
   Dark by default, light on request, RTL-aware for every Arabic block.
   ===================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-ar: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sidebar-w: 288px;
  --topbar-h: 62px;
}

/* ---- Dark (default) ---- */
:root,
[data-theme='dark'] {
  --bg: #0a0d16;
  --bg-elevated: #111624;
  --bg-panel: rgba(20, 26, 42, 0.72);
  --bg-input: #0e1320;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(94, 234, 212, 0.1);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e8ecf6;
  --text-dim: #9aa5bd;
  --text-faint: #66708a;

  --accent: #5eead4;
  --accent-2: #a78bfa;
  --accent-ink: #04241f;
  --accent-soft: rgba(94, 234, 212, 0.14);

  --gold: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);

  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  --glow: 0 0 0 1px rgba(94, 234, 212, 0.28), 0 12px 34px -18px rgba(94, 234, 212, 0.6);
  color-scheme: dark;
}

/* ---- Light ---- */
[data-theme='light'] {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.86);
  --bg-input: #ffffff;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-active: rgba(13, 148, 136, 0.1);

  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);

  --text: #0f172a;
  --text-dim: #52607a;
  --text-faint: #8492ab;

  --accent: #0d9488;
  --accent-2: #7c3aed;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 148, 136, 0.12);

  --gold: #d97706;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.12);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.1);

  --shadow: 0 16px 36px -22px rgba(15, 23, 42, 0.4);
  --glow: 0 0 0 1px rgba(13, 148, 136, 0.3), 0 12px 30px -18px rgba(13, 148, 136, 0.55);
  color-scheme: light;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(760px 480px at 92% 4%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 70%);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------- text */
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.015em;
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.2rem;
}
h3 {
  font-size: 1rem;
}

.muted {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
  font-size: 0.82rem;
}
.small {
  font-size: 0.85rem;
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.ar {
  font-family: var(--font-ar);
  direction: rtl;
  text-align: right;
  line-height: 1.85;
  unicode-bidi: isolate;
}

.gradient-text {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 550;
  white-space: nowrap;
  transition: all 0.16s var(--ease);
}
.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: var(--glow);
  background: linear-gradient(100deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--accent-2)));
}
.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: 7px;
}
.btn-icon {
  padding: 7px;
  min-width: 34px;
  border-radius: 9px;
}
.btn-block {
  width: 100%;
}
.btn-rec {
  background: linear-gradient(100deg, #f43f5e, #fb7185);
  color: #fff;
  border-color: transparent;
  font-weight: 650;
}
.btn-rec.is-recording {
  animation: pulse 1.9s infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.5);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(244, 63, 94, 0);
  }
}

/* -------------------------------------------------------------- inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.field .hint {
  font-size: 0.78rem;
  color: var(--text-faint);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.6;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* --------------------------------------------------------------- chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}
.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.chip-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}
.chip-live {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.chip-live .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1.4s infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* --------------------------------------------------------------- cards */
.card {
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: var(--sp-5);
}

/* -------------------------------------------------- expandable section */
.section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  overflow: hidden;
  transition: border-color 0.16s var(--ease);
}
.section + .section {
  margin-top: var(--sp-3);
}
.section:hover {
  border-color: var(--border-strong);
}
.section-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 13px var(--sp-4);
  text-align: start;
  font-weight: 600;
}
.section-head:hover {
  background: var(--bg-hover);
}
.section-head .caret {
  color: var(--text-faint);
  transition: transform 0.2s var(--ease);
  flex: none;
  font-size: 0.7rem;
}
.section.open > .section-head .caret {
  transform: rotate(90deg);
}
.section-head .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-head .icon {
  font-size: 1rem;
  flex: none;
}
.section-body {
  padding: 0 var(--sp-4) var(--sp-4);
  display: none;
  animation: reveal 0.22s var(--ease);
}
.section.open > .section-body {
  display: block;
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------- bi-text */
.bi {
  display: grid;
  gap: 10px;
}
.bi .en {
  line-height: 1.65;
}
.bi .ar-line {
  padding-top: 9px;
  border-top: 1px dashed var(--border);
  color: var(--text-dim);
}
body[data-lang='en'] .ar-line {
  display: none;
}
body[data-lang='ar'] .en-line {
  display: none;
}
body[data-lang='ar'] .ar-line {
  border-top: none;
  padding-top: 0;
  color: var(--text);
}

.list-clean {
  list-style: none;
  display: grid;
  gap: 10px;
}
.list-clean > li {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

/* ========================================================== app layout */
#root {
  position: relative;
  z-index: 1;
  height: 100%;
}

/*
 * min-height: 0 on every column and scroll container.
 *
 * A grid or flex item defaults to min-height: auto, which refuses to shrink
 * below its content. The main column then grows to the full height of the page
 * instead of the viewport, its inner overflow-y: auto never engages, and with
 * body overflow hidden everything below the fold becomes unreachable — no
 * scrollbar, no way down. Phones hid it because that layout is a single column.
 */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  min-height: 0;
}
.shell.collapsed {
  grid-template-columns: 0 1fr;
}

/* ------------------------------------------------------------- sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.24s var(--ease);
}
.shell.collapsed .sidebar {
  transform: translateX(-100%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-4);
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 0.95rem;
  flex: none;
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.nav {
  display: grid;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 550;
  font-size: 0.9rem;
  text-align: start;
  width: 100%;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
}
.nav-item .badge {
  margin-inline-start: auto;
  font-size: 0.72rem;
  color: var(--text-faint);
}
.nav-sep {
  height: 1px;
  background: var(--border);
  margin: var(--sp-2) 0;
}
.side-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  padding: 0 4px;
}

/* The row is a button, so delete cannot live inside it. The wrapper carries the
   background and selection instead, and holds the two controls side by side. */
.meeting-row-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.meeting-row-wrap:hover {
  background: var(--bg-hover);
}
.meeting-row-wrap.active {
  background: var(--bg-active);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.meeting-row {
  display: grid;
  gap: 3px;
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  border: none;
  text-align: start;
  background: transparent;
}

/* Kept out of the way until wanted — but always reachable by keyboard, and
   always present on touch, where there is no hover to reveal it. */
.meeting-del {
  opacity: 0;
  margin-inline-end: 6px;
  font-size: 0.95rem;
  transition: opacity 0.12s ease;
}
.meeting-row-wrap:hover .meeting-del,
.meeting-row-wrap.active .meeting-del,
.meeting-del:focus-visible {
  opacity: 0.75;
}
.meeting-del:hover {
  opacity: 1;
  color: var(--danger);
}
@media (hover: none) {
  .meeting-del {
    opacity: 0.6;
  }
}
.meeting-row .t {
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meeting-row .m {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-faint);
}

/* ------------------------------------------------------- the capture dock */
/* Capture follows the user across tabs. It sits under the tab bar rather than
   floating over the content, so nothing is ever hidden behind it — on a phone
   the bottom of the screen belongs to the navigation and the keyboard. */
.capture-dock {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border-block-end: 1px solid var(--border);
  background: color-mix(in srgb, var(--danger) 7%, var(--bg-panel));
  position: sticky;
  top: 0;
  z-index: 5;
}
.capture-dock[hidden] {
  display: none;
}
.dock-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dock-title {
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}
.dock-heard {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 1.1em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dock-pad {
  display: grid;
  gap: 6px;
}
.dock-pad textarea {
  font-size: 1rem;
  resize: vertical;
}

/* ------------------------------------------------------------- dashboard */

/* Headline figures. Auto-fit rather than a fixed column count: six of these
   belong in two rows on a phone and one row on a laptop, without a breakpoint
   for every step between. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--sp-3);
}
.tile {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.tile-value {
  font-size: 1.7rem;
  font-weight: 650;
  line-height: 1;
}
.tile-label {
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 5px;
}

/* The area chart stretches; its stroke must not stretch with it. */
.chart {
  width: 100%;
  height: 130px;
  display: block;
  vector-effect: non-scaling-stroke;
}
.chart path {
  vector-effect: non-scaling-stroke;
}

.rating-bars {
  display: grid;
  gap: 7px;
}
.rating-row {
  display: grid;
  grid-template-columns: 62px 1fr 28px;
  align-items: center;
  gap: 10px;
}
.rating-track {
  height: 9px;
  border-radius: 99px;
  background: var(--bg-hover);
  overflow: hidden;
}
.rating-fill {
  height: 100%;
  border-radius: 99px;
  min-width: 2px;
}

.donut-wrap {
  position: relative;
  width: 130px;
  margin: 0 auto;
}
.donut {
  width: 130px;
  height: 130px;
  display: block;
}
.donut-centre {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.15;
}
.donut-centre strong {
  font-size: 1.4rem;
}

/* Recent meetings are buttons, so they need the row treatment a button loses. */
.recent-row {
  display: grid;
  gap: 3px;
  width: 100%;
  text-align: start;
  padding: 10px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-radius: 0;
}
.recent-row:hover {
  background: var(--bg-hover);
}

/* Column chart, still used by the month-by-month view. */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 120px;
}
.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex: 1;
  height: 100%;
}
.bar {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  opacity: 0.85;
}
.bar-col:hover .bar {
  opacity: 1;
}

.usage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  display: grid;
  gap: 9px;
  background: var(--bg-panel);
}
.meter {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s var(--ease);
}
.meter.warn > i {
  background: linear-gradient(90deg, var(--warn), var(--danger));
}

/* -------------------------------------------------------------- topbar */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
}
.topbar .title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Chips next to the title never push the action buttons off the bar. */
.topbar .title-wrap .chip {
  flex: none;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  line-height: 1.7;
}
.title-input {
  font-size: 1.02rem;
  font-weight: 650;
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  min-width: 0;
  max-width: 460px;
}
.title-input:hover {
  border-color: var(--border);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ---------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 3px;
  padding: 10px var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab .count {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-faint);
}
.tab.active .count {
  background: var(--accent-soft);
  color: var(--accent);
}

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-5);
  scroll-behavior: smooth;
}
.view-narrow {
  max-width: 880px;
  margin: 0 auto;
}

/* -------------------------------------------------------- split layout */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: var(--sp-4);
  align-items: start;
}
.split.stack {
  grid-template-columns: 1fr;
}
.pane-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.pane-head h2 {
  flex: 1;
  min-width: 0;
}

/* ----------------------------------------------------------- transcript */
.transcript {
  display: grid;
  gap: 2px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 4px;
}
.seg {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
}
.seg:hover {
  background: var(--bg-hover);
}
.seg:hover .seg-actions {
  opacity: 1;
}
.seg .ts {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  padding-top: 3px;
}
.seg .speaker {
  font-weight: 650;
  color: var(--accent);
  margin-inline-end: 6px;
}
.seg-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}
.seg.interim {
  opacity: 0.62;
  font-style: italic;
}
.seg[dir='rtl'] .body {
  font-family: var(--font-ar);
  text-align: right;
}

.rec-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  margin-bottom: var(--sp-4);
}
.level {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
  width: 42px;
}
.level i {
  flex: 1;
  background: var(--accent);
  border-radius: 2px;
  height: 15%;
  transition: height 0.09s linear;
}
.timer {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ----------------------------------------------------------- questions */
.filters {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  align-items: flex-end;
  padding: var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  margin-bottom: var(--sp-4);
  position: sticky;
  top: calc(var(--sp-5) * -1);
  z-index: 5;
  backdrop-filter: blur(14px);
}
.filters .field {
  flex: 1 1 150px;
  max-width: 220px;
}
.filters .field.grow {
  flex: 2 1 220px;
  max-width: none;
}
/* Rating keeps its select and its star picker on one line. */
.filters .field.rating {
  flex: 0 1 300px;
  max-width: 320px;
}
.filters .field.rating > .row {
  flex-wrap: nowrap;
}
.filters .field.rating select {
  min-width: 130px;
}

.stars {
  display: inline-flex;
  gap: 2px;
  font-size: 1.02rem;
  line-height: 1;
}
.stars .s {
  color: var(--text-faint);
  transition: transform 0.12s var(--ease);
}
.stars .s.on {
  color: var(--gold);
}
.stars.interactive .s {
  cursor: pointer;
  padding: 2px;
}
.stars.interactive .s:hover {
  transform: scale(1.22);
}

.q-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  overflow: hidden;
  transition: border-color 0.16s var(--ease), transform 0.16s var(--ease);
}
.q-card + .q-card {
  margin-top: var(--sp-3);
}
.q-card:hover {
  border-color: var(--border-strong);
}
.q-card.r5 {
  border-inline-start: 3px solid var(--gold);
}
.q-card.r4 {
  border-inline-start: 3px solid var(--accent);
}
.q-card.r3 {
  border-inline-start: 3px solid var(--info);
}
.q-card.asked {
  opacity: 0.6;
}
.q-head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  width: 100%;
  text-align: start;
}
.q-head:hover {
  background: var(--bg-hover);
}
.q-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 7px;
}
.q-text {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}
.q-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.q-body {
  display: none;
  padding: 0 var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border);
  margin-top: -1px;
  padding-top: var(--sp-4);
}
.q-card.open .q-body {
  display: grid;
  gap: var(--sp-3);
  animation: reveal 0.2s var(--ease);
}
.q-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  flex: none;
}

.kv {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 8px 14px;
  font-size: 0.9rem;
}
.kv dt {
  color: var(--text-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

/* ----------------------------------------------------------- chat / ask */
.chat {
  display: grid;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.bubble {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 88%;
}
.bubble.me {
  margin-inline-start: auto;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}
.bubble.ai {
  background: var(--bg-panel);
}
.composer {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  padding-top: var(--sp-3);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------------------------------------------------------- empty/skel */
.empty {
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-dim);
}
.empty .art {
  font-size: 2.4rem;
  opacity: 0.6;
}
.empty h3 {
  color: var(--text);
}

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-hover), var(--border), var(--bg-hover));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  height: 14px;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------------------------------------- toasts */
.toasts {
  position: fixed;
  bottom: var(--sp-5);
  inset-inline-end: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
  z-index: 100;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  animation: toast-in 0.24s var(--ease);
  font-size: 0.9rem;
}
.toast.ok {
  border-inline-start: 3px solid var(--ok);
}
.toast.err {
  border-inline-start: 3px solid var(--danger);
}
.toast.info {
  border-inline-start: 3px solid var(--info);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

/* --------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.66);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: var(--sp-4);
  animation: reveal 0.18s var(--ease);
}
.modal {
  width: min(680px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  flex: 1;
}
.modal-body {
  padding: var(--sp-5);
  display: grid;
  gap: var(--sp-4);
}
.modal-foot {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-elevated);
}

/* ================================================================= auth */
.auth-wrap {
  height: 100%;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.auth-hero {
  padding: var(--sp-7) var(--sp-6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-5);
  border-right: 1px solid var(--border);
}
.auth-hero h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.9rem);
  letter-spacing: -0.03em;
}
.hero-points {
  display: grid;
  gap: var(--sp-3);
  max-width: 520px;
}
.hero-point {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
}
.hero-point .ico {
  font-size: 1.2rem;
  flex: none;
}
.auth-panel {
  padding: var(--sp-7) var(--sp-6);
  display: grid;
  align-content: center;
  justify-items: stretch;
}
.auth-card {
  width: min(420px, 100%);
  margin: 0 auto;
  display: grid;
  gap: var(--sp-4);
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border);
}
.auth-tabs button {
  padding: 8px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.auth-tabs button.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------------- plans */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--sp-4);
}
.plan {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  align-content: start;
}
.plan.current {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.plan .price {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.plan ul {
  list-style: none;
  display: grid;
  gap: 7px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.plan li::before {
  content: '✓ ';
  color: var(--accent);
  font-weight: 700;
}

/* --------------------------------------------------------- misc layout */
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
}
/* A display rule on a utility class beats the browser default for [hidden],
   so anything hidden in JavaScript has to be told again, louder. */
[hidden] {
  display: none !important;
}

.stack-3 {
  display: grid;
  gap: var(--sp-3);
}
.stack-4 {
  display: grid;
  gap: var(--sp-4);
}
.stack-5 {
  display: grid;
  gap: var(--sp-5);
}
.spacer {
  flex: 1;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
}
.stat .n {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat .l {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  border: 1px solid var(--border);
}
.banner.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}
.banner.info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 32%, transparent);
}
.banner.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
}

pre.export {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.65;
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------- mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 40;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.mobile-nav-inner {
  display: grid;
  grid-auto-flow: column;
  gap: 2px;
}
.mnav {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-faint);
}
.mnav .ico {
  font-size: 1.05rem;
}
.mnav.active {
  color: var(--accent);
  background: var(--bg-active);
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .auth-wrap {
    grid-template-columns: 1fr;
  }
  .auth-hero {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: var(--sp-6) var(--sp-4);
  }
  .auth-panel {
    padding: var(--sp-5) var(--sp-4) var(--sp-7);
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }
  .topbar {
    gap: var(--sp-2);
    padding: 0 var(--sp-3);
  }
  .topbar .title-wrap {
    min-width: 0;
  }
  .topbar-actions {
    gap: 5px;
  }
  /* Theme and language live in Profile → App settings on small screens. */
  .hide-mobile {
    display: none !important;
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(84vw, var(--sidebar-w));
    z-index: 60;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .shell.drawer-open .sidebar {
    transform: none;
  }
  .shell.collapsed .sidebar {
    transform: translateX(-100%);
  }
  .drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(3, 6, 14, 0.6);
    z-index: 50;
  }
  .view {
    padding: var(--sp-4) var(--sp-3) 88px;
  }
  .mobile-nav {
    display: block;
  }
  .transcript {
    max-height: none;
  }
  .filters {
    position: static;
  }
  .title-input {
    max-width: none;
    font-size: 0.95rem;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 3px 0;
  }
  .kv dt {
    margin-top: 8px;
  }
  .toasts {
    bottom: 84px;
    inset-inline: var(--sp-3);
    max-width: none;
  }
}

/* Very narrow phones: buttons keep their icon, drop their label. */
@media (max-width: 560px) {
  /* Two filters per row instead of one, so the bar does not eat the screen. */
  .filters {
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-3);
  }
  .filters .field,
  .filters .field.rating {
    flex: 1 1 44%;
    max-width: none;
  }
  .filters .field.rating .stars {
    display: none;
  }
  .filters select {
    padding: 8px 10px;
  }
  .btn-label {
    display: none;
  }
  .topbar .title-wrap .chip {
    display: none;
  }
  .title-input {
    font-size: 0.9rem;
    padding: 5px 6px;
  }
  .btn {
    padding: 9px 11px;
  }
}

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

@media print {
  .sidebar,
  .topbar,
  .tabs,
  .mobile-nav,
  .filters,
  .toasts {
    display: none !important;
  }
  body {
    overflow: visible;
    background: #fff;
    color: #000;
  }
  .view {
    overflow: visible;
    padding: 0;
  }
}
