@charset "UTF-8";
/* ==========================================================================
   صِياغة | Siyagha — design system
   Newsroom dark theme with a full light counterpart. RTL-first.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --ink:          #10151A;
  --surface:      #1B232B;
  --surface-alt:  #212B33;
  --surface-hi:   #27333C;
  --paper:        #EDE8DD;
  --muted:        #8FA0A8;
  --muted-dim:    #6B7B84;
  --amber:        #E3A23C;
  --amber-soft:   rgba(227, 162, 60, .13);
  --amber-line:   rgba(227, 162, 60, .38);
  --teal:         #4FA98C;
  --teal-soft:    rgba(79, 169, 140, .13);
  --line:         #2B363F;
  --line-soft:    #232E36;
  --danger:       #E07A63;
  --danger-soft:  rgba(224, 122, 99, .12);
  --warn:         #D9A441;
  --info:         #6C8EBF;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.28);
  --shadow-2: 0 6px 22px rgba(0,0,0,.34);
  --shadow-3: 0 18px 48px rgba(0,0,0,.45);

  --sans:  'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --naskh: 'Noto Naskh Arabic', 'Times New Roman', serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --sidebar-w: 244px;
  --topbar-h:  56px;
  --ticker-h:  30px;

  --ring: 0 0 0 2px var(--ink), 0 0 0 4px var(--amber);
  color-scheme: dark;
}

html[data-theme="light"] {
  --ink:          #F4F1EA;
  --surface:      #FFFFFF;
  --surface-alt:  #F7F5F0;
  --surface-hi:   #EEEAE1;
  --paper:        #1A2026;
  --muted:        #62727C;
  --muted-dim:    #8A98A1;
  --amber:        #B87614;
  --amber-soft:   rgba(184, 118, 20, .10);
  --amber-line:   rgba(184, 118, 20, .34);
  --teal:         #2F7C64;
  --teal-soft:    rgba(47, 124, 100, .10);
  --line:         #DCD6CA;
  --line-soft:    #E7E2D8;
  --danger:       #B4462C;
  --danger-soft:  rgba(180, 70, 44, .10);
  --warn:         #9A6C10;
  --info:         #3B5F91;
  --shadow-1: 0 1px 2px rgba(30,25,15,.07);
  --shadow-2: 0 6px 20px rgba(30,25,15,.10);
  --shadow-3: 0 18px 44px rgba(30,25,15,.16);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--amber);
  color-scheme: light;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Utility classes set display:flex/grid, which would otherwise win over the
   [hidden] attribute's UA rule. Keep [hidden] authoritative. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
p  { margin: 0 0 .9rem; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
::selection { background: var(--amber-soft); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-dim); }

/* ---------- Icons ---------- */
.icon {
  width: 1.15em; height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
  vertical-align: -.18em;
}
.icon-sm { width: 1em;   height: 1em; }
.icon-lg { width: 1.4em; height: 1.4em; }
.icon-xl { width: 2rem;  height: 2rem; stroke-width: 1.5; }

/* ==========================================================================
   Shell
   ========================================================================== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  padding: .95rem 1rem;
  border-bottom: 1px solid var(--line);
  min-height: var(--topbar-h);
}
.brand__mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--amber), #c8862c);
  color: #17202A;
  display: grid; place-items: center;
  font-weight: 800; font-size: .95rem;
  box-shadow: var(--shadow-1);
}
.brand__name { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.brand__sub  { font-size: .66rem; color: var(--muted); font-family: var(--mono); letter-spacing: .06em; }

.nav { padding: .7rem .6rem; overflow-y: auto; flex: 1; }
.nav__group { margin-bottom: 1.1rem; }
.nav__label {
  font-size: .64rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-dim); font-family: var(--mono);
  padding: 0 .55rem .4rem;
}
.nav__link {
  display: flex; align-items: center; gap: .6rem;
  padding: .52rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .845rem; font-weight: 500;
  transition: background .14s, color .14s;
  position: relative;
}
.nav__link:hover { background: var(--surface-alt); color: var(--paper); text-decoration: none; }
.nav__link.is-active { background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.nav__link.is-active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--amber);
}
.nav__badge {
  margin-inline-start: auto;
  font-family: var(--mono); font-size: .66rem;
  background: var(--surface-hi); color: var(--muted);
  padding: .05rem .38rem; border-radius: 20px;
}

.sidebar__foot { border-top: 1px solid var(--line); padding: .6rem; }

/* ---------- User chip ---------- */
.userchip {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .5rem; border-radius: var(--radius-sm);
  width: 100%; background: none; border: 0; color: inherit;
  font-family: inherit; cursor: pointer; text-align: start;
}
.userchip:hover { background: var(--surface-alt); }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; color: #14191F;
  background: var(--amber);
}
.avatar-sm { width: 24px; height: 24px; font-size: .62rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.05rem; }
.userchip__name { font-size: .8rem; font-weight: 600; line-height: 1.25; }
.userchip__role { font-size: .68rem; color: var(--muted); }

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

.ticker {
  height: var(--ticker-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: .68rem;
  overflow: hidden; white-space: nowrap;
}
.ticker__tag { color: var(--amber); font-weight: 700; flex: none; display: flex; align-items: center; gap: .35rem; }
.ticker__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); animation: pulse 2.4s ease-in-out infinite; }
.ticker__msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.ticker__msg.is-swap { animation: tickerFade .5s ease; }
@keyframes tickerFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-size: 1rem; font-weight: 700; }
.topbar__spacer { flex: 1; }

.iconbtn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.iconbtn:hover { background: var(--surface-alt); color: var(--paper); }
.iconbtn.is-on { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }

.burger { display: none; }

.content { padding: 1.25rem; flex: 1; }
.content--wide { max-width: none; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.15rem; }
.page-head__text { min-width: 0; flex: 1; }
.page-head h1 { font-size: 1.35rem; margin-bottom: .2rem; }
.page-head p  { color: var(--muted); font-size: .84rem; margin: 0; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line-soft);
}
.card__title { font-size: .9rem; font-weight: 700; }
.card__hint  { font-size: .74rem; color: var(--muted); }
.card__body  { padding: 1rem; }
.card__foot  { padding: .75rem 1rem; border-top: 1px solid var(--line-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--paper);
  font-family: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .14s, border-color .14s, color .14s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-hi); border-color: var(--muted-dim); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn--primary { background: var(--amber); border-color: var(--amber); color: #16202A; }
.btn--primary:hover { background: #f0ae46; border-color: #f0ae46; }
.btn--teal { background: var(--teal); border-color: var(--teal); color: #0E1A16; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.btn--sm { padding: .32rem .6rem; font-size: .74rem; }
.btn--lg { padding: .68rem 1.2rem; font-size: .9rem; }
.btn--block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: .95rem; }
.label {
  display: block; margin-bottom: .35rem;
  font-size: .74rem; font-weight: 600; color: var(--muted);
}
.label .req { color: var(--amber); }
.hint { font-size: .7rem; color: var(--muted-dim); margin-top: .3rem; }

.input, .textarea, .select {
  width: 100%;
  padding: .55rem .7rem;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font-family: inherit; font-size: .84rem; line-height: 1.6;
  transition: border-color .14s, background .14s;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--muted-dim); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--amber);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-dim); }
.textarea { resize: vertical; min-height: 96px; }
.textarea--tall { min-height: 210px; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: left 1rem top 55%, left .68rem top 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-start: 2rem;
}
.input--mono { font-family: var(--mono); direction: ltr; text-align: left; }

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: .5rem;
  font-size: .8rem; cursor: pointer; padding: .18rem 0;
}
.checkbox input, .radio input {
  width: 16px; height: 16px; flex: none; margin-top: .18rem;
  accent-color: var(--amber); cursor: pointer;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .85rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: .85rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .85rem; }

/* ---------- Chips (selectable cards) ---------- */
.chipgrid { display: grid; gap: .55rem; }
.chipgrid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.chipgrid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }

.chip {
  position: relative;
  display: block; width: 100%; text-align: start;
  padding: .6rem .65rem;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  cursor: pointer; font-family: inherit;
  transition: border-color .14s, background .14s, transform .06s;
}
.chip:hover { border-color: var(--amber-line); }
.chip:active { transform: translateY(1px); }
.chip__icon { color: var(--muted); margin-bottom: .25rem; display: block; }
.chip__label { font-size: .78rem; font-weight: 600; line-height: 1.3; }
.chip__sub { font-size: .66rem; color: var(--muted); line-height: 1.35; margin-top: .1rem; }
.chip.is-active { background: var(--amber-soft); border-color: var(--amber); }
.chip.is-active .chip__icon { color: var(--amber); }
.chip--teal.is-active { background: var(--teal-soft); border-color: var(--teal); }
.chip--teal.is-active .chip__icon { color: var(--teal); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .28rem;
  padding: .12rem .5rem;
  border-radius: 20px;
  font-size: .68rem; font-weight: 600;
  background: var(--surface-hi); color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--draft     { background: var(--surface-hi);   color: var(--muted); }
.badge--review    { background: rgba(217,164,65,.14); color: var(--warn); }
.badge--approved  { background: var(--teal-soft);    color: var(--teal); }
.badge--published { background: var(--amber-soft);   color: var(--amber); }
.badge--archived  { background: transparent; color: var(--muted-dim); border-color: var(--line); }
.badge--danger    { background: var(--danger-soft);  color: var(--danger); }
.badge--info      { background: rgba(108,142,191,.14); color: var(--info); }
.badge--ok        { background: var(--teal-soft);    color: var(--teal); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  border: 1px solid transparent;
  margin-bottom: .8rem;
}
.alert--error   { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert--success { background: var(--teal-soft);   color: var(--teal);   border-color: color-mix(in srgb, var(--teal) 30%, transparent); }
.alert--info    { background: rgba(108,142,191,.10); color: var(--info); border-color: rgba(108,142,191,.3); }
.alert--warn    { background: rgba(217,164,65,.10); color: var(--warn); border-color: rgba(217,164,65,.3); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.15rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem .95rem;
  display: flex; align-items: flex-start; gap: .7rem;
}
.stat__icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-alt); color: var(--amber);
}
.stat__icon--teal { color: var(--teal); }
.stat__icon--info { color: var(--info); }
.stat__label { font-size: .7rem; color: var(--muted); }
.stat__value { font-family: var(--mono); font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.stat__delta { font-size: .66rem; color: var(--muted-dim); }

/* ---------- Table ---------- */
.tablewrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 620px; }
.table th {
  text-align: start; font-weight: 600; font-size: .7rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: .6rem .8rem; border-bottom: 1px solid var(--line);
  background: var(--surface-alt); white-space: nowrap;
}
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }
.table .num { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.table__actions { display: flex; gap: .3rem; justify-content: flex-end; }

.empty { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty .icon-xl { color: var(--muted-dim); margin-bottom: .6rem; }
.empty h3 { font-size: .95rem; margin-bottom: .3rem; color: var(--paper); }
.empty p { font-size: .8rem; margin: 0; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: .35rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 32px; height: 32px; padding: 0 .5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-size: .78rem; font-family: var(--mono);
}
.pager a:hover { border-color: var(--amber-line); color: var(--paper); text-decoration: none; }
.pager .is-current { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); font-weight: 700; }
.pager .is-disabled { opacity: .4; pointer-events: none; }

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex; gap: .55rem; flex-wrap: wrap; align-items: center;
  margin-bottom: 1rem;
}
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.searchbox { position: relative; flex: 1; min-width: 190px; }
.searchbox .icon { position: absolute; inset-inline-start: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted-dim); pointer-events: none; }
.searchbox .input { padding-inline-start: 2.1rem; width: 100%; }

/* ==========================================================================
   Studio (generation screen)
   ========================================================================== */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 1rem; align-items: start; }

.output {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.15rem 1.25rem;
  font-family: var(--naskh);
  font-size: 15.5px;
  line-height: 2.05;
  white-space: pre-wrap;
  min-height: 420px;
  max-height: 68vh;
  overflow-y: auto;
}
html[data-theme="light"] .output { background: #FFFDF8; }
.output:empty::before { content: attr(data-placeholder); color: var(--muted); font-family: var(--sans); font-size: .84rem; }
.output__caret {
  display: inline-block; width: 2px; height: 1.05em;
  background: var(--amber); vertical-align: -.15em;
  animation: caret .9s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.metrics {
  display: flex; gap: 1rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: .7rem; color: var(--muted);
  padding-top: .7rem; margin-top: .1rem;
  border-top: 1px solid var(--line-soft);
}
.metrics b { color: var(--paper); font-weight: 600; }

.counterbar { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .68rem; color: var(--muted-dim); margin-top: .3rem; }
.counterbar .over { color: var(--danger); }

/* Editor pane */
.editor {
  width: 100%;
  min-height: 420px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--paper);
  font-family: var(--naskh);
  font-size: 15.5px; line-height: 2.05;
  padding: 1.15rem 1.25rem;
  resize: vertical;
}
html[data-theme="light"] .editor { background: #FFFDF8; }

/* ---------- Sparkline / bars ---------- */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 60px; }
.spark__bar { flex: 1; min-width: 3px; background: var(--amber-soft); border-radius: 2px 2px 0 0; position: relative; transition: background .14s; }
.spark__bar > i { display: block; width: 100%; background: var(--amber); border-radius: 2px 2px 0 0; position: absolute; bottom: 0; }
.spark__bar:hover { background: var(--surface-hi); }

.barlist { display: flex; flex-direction: column; gap: .55rem; }
.barlist__row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: .6rem; align-items: center; font-size: .78rem; }
.barlist__track { height: 7px; background: var(--surface-alt); border-radius: 4px; overflow: hidden; }
.barlist__fill { height: 100%; background: var(--amber); border-radius: 4px; }
.barlist__val { font-family: var(--mono); font-size: .72rem; color: var(--muted); }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; inset-block-end: 1rem; inset-inline-start: 1rem;
  display: flex; flex-direction: column; gap: .5rem; z-index: 90;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .65rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: .8rem;
  animation: toastIn .2s ease;
}
.toast--ok    { border-inline-start-color: var(--teal); }
.toast--error { border-inline-start-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(6, 9, 12, .66);
  padding: 1rem;
  animation: fadeIn .14s ease;
}
html[data-theme="light"] .modal { background: rgba(40, 34, 22, .38); }
.modal[hidden] { display: none; }
.modal__box {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  max-height: 88vh; overflow-y: auto;
}
.modal__head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: .5rem; }
.modal__body { padding: 1.1rem; }
.modal__foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line-soft); display: flex; gap: .5rem; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Auth pages ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: 1fr;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(227,162,60,.10), transparent 62%),
    radial-gradient(760px 420px at 8% 108%, rgba(79,169,140,.09), transparent 60%),
    var(--ink);
}
.auth__box { width: min(410px, 100%); }
.auth__brand { text-align: center; margin-bottom: 1.4rem; }
.auth__mark {
  width: 54px; height: 54px; margin: 0 auto .7rem;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--amber), #c8862c);
  color: #17202A; display: grid; place-items: center;
  font-size: 1.35rem; font-weight: 800;
  box-shadow: var(--shadow-2);
}
.auth__title { font-size: 1.25rem; }
.auth__sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.auth__foot { text-align: center; margin-top: 1rem; font-size: .76rem; color: var(--muted); }
.auth__legal { text-align: center; margin-top: 1.6rem; font-size: .68rem; color: var(--muted-dim); font-family: var(--mono); }

/* ---------- Password strength ---------- */
.pwmeter { display: flex; gap: 3px; margin-top: .4rem; }
.pwmeter i { height: 3px; flex: 1; background: var(--line); border-radius: 3px; transition: background .2s; }
.pwmeter[data-score="1"] i:nth-child(1) { background: var(--danger); }
.pwmeter[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.pwmeter[data-score="3"] i:nth-child(-n+3) { background: var(--info); }
.pwmeter[data-score="4"] i { background: var(--teal); }

/* ---------- Misc ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .74rem; }
.tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: .5rem; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.divider-label {
  display: flex; align-items: center; gap: .6rem;
  color: var(--muted-dim); font-size: .7rem; font-family: var(--mono);
  margin: 1rem 0;
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.offline-bar {
  display: none;
  align-items: center; gap: .45rem; justify-content: center;
  background: var(--warn); color: #1A1305;
  font-size: .74rem; font-weight: 600; padding: .3rem;
}
body.is-offline .offline-bar { display: flex; }

.scrim {
  position: fixed; inset: 0; background: rgba(6,9,12,.55); z-index: 39;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
body.nav-open .scrim { opacity: 1; pointer-events: auto; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 262px; }
  .burger { display: grid; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-end: 0;
    transform: translateX(100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-3);
  }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 1rem .85rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .chipgrid--3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .page-head h1 { font-size: 1.15rem; }
  .stat__value { font-size: 1.2rem; }
}

@media (max-width: 520px) {
  body { font-size: 13.5px; }
  .grid-4 { grid-template-columns: 1fr; }
  .chipgrid--3, .chipgrid--2 { grid-template-columns: 1fr; }
  .ticker { display: none; }
  .toolbar .input, .toolbar .select { min-width: 0; width: 100%; }
  .searchbox { min-width: 0; width: 100%; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .toasts { inset-inline: .75rem; max-width: none; }
  .modal__box { border-radius: var(--radius); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .sidebar, .topbar, .ticker, .page-head__actions, .toasts, .offline-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .output { border: 0; max-height: none; font-size: 12pt; }
}
