/* Crystal Sheets — crystal-glass design system.
   Tokens: hue per theme (--h, --accent-l) x surface set per mode (light | dark).
   Themes: blue (Crystal Blue), emerald (Crystal Emerald), violet (Royal Violet), dark (Crystal Dark).
   Logical properties (inline-start/end) make the layout correct for both RTL (Arabic) and LTR. */

:root {
  --h: 205; --accent-l: 40%;
  --radius: 16px; --radius-sm: 10px;
  --blur: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}
:root[data-theme="blue"]    { --h: 205; --accent-l: 40%; }
:root[data-theme="emerald"] { --h: 155; --accent-l: 28%; }
:root[data-theme="violet"]  { --h: 265; --accent-l: 47%; }
:root[data-theme="dark"]    { --h: 210; --accent-l: 60%; }

/* ---- Light surfaces (default) ---- */
:root {
  --bg-1: hsl(var(--h) 85% 97%);
  --bg-2: hsl(calc(var(--h) + 28) 80% 90%);
  --bg-3: hsl(calc(var(--h) - 20) 90% 94%);
  --glass: hsla(0 0% 100% / .58);
  --glass-strong: hsla(0 0% 100% / .78);
  --glass-border: hsla(0 0% 100% / .85);
  --glass-shadow: 0 8px 28px hsla(var(--h) 60% 30% / .14), inset 0 1px 0 hsla(0 0% 100% / .9);
  --text: hsl(var(--h) 45% 13%);
  --muted: hsl(var(--h) 18% 34%);
  --line: hsla(var(--h) 40% 30% / .16);
  --accent: hsl(var(--h) 78% var(--accent-l));
  --accent-hi: hsl(calc(var(--h) + 12) 82% calc(var(--accent-l) + 14%));
  --accent-lo: hsl(var(--h) 80% calc(var(--accent-l) - 10%));
  --on-accent: #fff;
  --danger: hsl(0 72% 40%);
  --ok: hsl(145 65% 26%);
  --warn: hsl(35 90% 28%);
  --input-bg: hsla(0 0% 100% / .8);
  --btn-face-hi: hsla(0 0% 100% / .95);
  --btn-face-lo: hsl(var(--h) 60% 92%);
  --btn-edge: hsl(var(--h) 35% 74%);
}
/* ---- Dark surfaces: explicit mode, Crystal Dark theme, or auto + OS dark ---- */
:root[data-mode="dark"], :root[data-theme="dark"] {
  color-scheme: dark;
  --bg-1: hsl(var(--h) 50% 7%);
  --bg-2: hsl(calc(var(--h) + 30) 55% 13%);
  --bg-3: hsl(calc(var(--h) - 15) 60% 10%);
  --glass: hsla(var(--h) 45% 22% / .46);
  --glass-strong: hsla(var(--h) 45% 16% / .82);
  --glass-border: hsla(0 0% 100% / .14);
  --glass-shadow: 0 10px 34px hsla(0 0% 0% / .45), inset 0 1px 0 hsla(0 0% 100% / .12);
  --text: hsl(var(--h) 35% 94%);
  --muted: hsl(var(--h) 18% 74%);
  --line: hsla(0 0% 100% / .14);
  --accent: hsl(var(--h) 95% 64%);
  --accent-hi: hsl(var(--h) 100% 76%);
  --accent-lo: hsl(var(--h) 90% 50%);
  --on-accent: hsl(var(--h) 70% 8%);
  --danger: hsl(0 90% 72%);
  --ok: hsl(145 60% 62%);
  --warn: hsl(40 95% 66%);
  --input-bg: hsla(var(--h) 50% 10% / .65);
  --btn-face-hi: hsla(var(--h) 45% 34% / .85);
  --btn-face-lo: hsla(var(--h) 50% 20% / .9);
  --btn-edge: hsl(var(--h) 55% 8%);
}
@media (prefers-color-scheme: dark) {
  :root[data-mode="auto"]:not([data-theme="dark"]) {
    color-scheme: dark;
    --bg-1: hsl(var(--h) 50% 7%);
    --bg-2: hsl(calc(var(--h) + 30) 55% 13%);
    --bg-3: hsl(calc(var(--h) - 15) 60% 10%);
    --glass: hsla(var(--h) 45% 22% / .46);
    --glass-strong: hsla(var(--h) 45% 16% / .82);
    --glass-border: hsla(0 0% 100% / .14);
    --glass-shadow: 0 10px 34px hsla(0 0% 0% / .45), inset 0 1px 0 hsla(0 0% 100% / .12);
    --text: hsl(var(--h) 35% 94%);
    --muted: hsl(var(--h) 18% 74%);
    --line: hsla(0 0% 100% / .14);
    --accent: hsl(var(--h) 95% 64%);
    --accent-hi: hsl(var(--h) 100% 76%);
    --accent-lo: hsl(var(--h) 90% 50%);
    --on-accent: hsl(var(--h) 70% 8%);
    --danger: hsl(0 90% 72%);
    --ok: hsl(145 60% 62%);
    --warn: hsl(40 95% 66%);
    --input-bg: hsla(var(--h) 50% 10% / .65);
    --btn-face-hi: hsla(var(--h) 45% 34% / .85);
    --btn-face-lo: hsla(var(--h) 50% 20% / .9);
    --btn-edge: hsl(var(--h) 55% 8%);
  }
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, var(--bg-3), transparent 60%),
    radial-gradient(900px 600px at 105% 10%, var(--bg-2), transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed; min-height: 100vh;
}
h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hi); }
code { background: var(--glass); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.sr-only { position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: .5rem; inset-block-start: -3rem; background: var(--accent); color: var(--on-accent); padding: .5rem .9rem; border-radius: 8px; z-index: 1000; }
.skip-link:focus { inset-block-start: .5rem; }
:focus-visible { outline: 3px solid var(--accent-hi); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---- Glass surfaces ---- */
.glass-card, .glass-panel {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(140%); backdrop-filter: blur(var(--blur)) saturate(140%);
  position: relative;
}
.glass-card::before, .glass-panel::before { /* subtle crystal reflection */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, hsla(0 0% 100% / .35), transparent 38%);
  opacity: .55; mix-blend-mode: soft-light;
}
.section { padding: 1.1rem 1.25rem; margin-block-end: 1rem; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-card, .glass-panel { background: var(--glass-strong); }
}

/* ---- 3D buttons ---- */
.btn {
  --face-hi: var(--btn-face-hi); --face-lo: var(--btn-face-lo); --edge: var(--btn-edge); --fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-block-size: 40px;
  padding: .5rem 1rem; font: inherit; font-weight: 600; color: var(--fg); text-decoration: none; cursor: pointer;
  background: linear-gradient(180deg, var(--face-hi), var(--face-lo));
  border: 1px solid var(--edge); border-radius: 12px;
  box-shadow: 0 3px 0 var(--edge), 0 8px 14px hsla(var(--h) 50% 20% / .18), inset 0 1px 0 hsla(0 0% 100% / .8), inset 0 -1px 0 hsla(0 0% 0% / .06);
  transform: translateY(0); transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .15s;
  position: relative; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.04) saturate(1.05); transform: translateY(-1px); box-shadow: 0 4px 0 var(--edge), 0 12px 18px hsla(var(--h) 50% 20% / .22), inset 0 1px 0 hsla(0 0% 100% / .85); }
.btn:active, .btn.is-pressed { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge), 0 3px 6px hsla(var(--h) 50% 20% / .2), inset 0 2px 4px hsla(0 0% 0% / .15); }
.btn:focus-visible { outline: 3px solid var(--accent-hi); outline-offset: 3px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; filter: grayscale(.4); box-shadow: 0 1px 0 var(--edge); pointer-events: none; }
.btn-primary { --face-hi: var(--accent-hi); --face-lo: var(--accent-lo); --edge: hsl(var(--h) 70% calc(var(--accent-l) - 18%)); --fg: var(--on-accent);
  text-shadow: 0 1px 0 hsla(0 0% 0% / .18); }
:root[data-mode="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary { text-shadow: none; --edge: hsl(var(--h) 80% 28%); }
.btn-danger { --face-hi: hsl(0 80% 60%); --face-lo: hsl(0 75% 42%); --edge: hsl(0 70% 26%); --fg: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; --fg: var(--text); }
.btn-ghost:hover { background: var(--glass); box-shadow: none; transform: none; }
.btn-ghost:active { transform: translateY(1px); box-shadow: none; }
.btn-sm { min-block-size: 32px; padding: .25rem .65rem; font-size: .88rem; border-radius: 10px; }
.btn-icon { min-inline-size: 40px; padding: .4rem; }
.btn-icon.btn-sm { min-inline-size: 32px; }
.btn-block { inline-size: 100%; }
.btn-3d { }
.btn.is-loading { pointer-events: none; color: transparent !important; }
.btn.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; inline-size: 18px; block-size: 18px; border-radius: 50%;
  border: 2px solid var(--fg); border-inline-end-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.field > span { font-size: .9rem; }
.field-inline { flex-direction: row; align-items: center; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.narrow { max-inline-size: 460px; }
.input {
  font: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .75rem; min-block-size: 40px; inline-size: 100%; transition: border-color .15s, box-shadow .15s;
  box-shadow: inset 0 2px 4px hsla(var(--h) 40% 20% / .08);
}
.input:hover { border-color: var(--accent); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px hsla(var(--h) 90% 60% / .35); outline: none; }
.input.invalid { border-color: var(--danger); }
.input-sm { min-block-size: 32px; padding: .2rem .5rem; inline-size: auto; }
select.input { padding-inline-end: 1.8rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; }
.row-gap { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-block: .5rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; align-items: end; }

/* ---- Alerts, pills, badges ---- */
.alert { padding: .7rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-strong); margin: 0 0 1rem; }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-success { border-color: var(--ok); color: var(--ok); }
.alert-warn { border-color: var(--warn); color: var(--warn); }
.alert-info { border-color: var(--accent); }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; background: hsla(var(--h) 80% 50% / .16); color: var(--text); border: 1px solid var(--line); margin-inline-start: .35rem; }
.pill-muted { background: transparent; color: var(--muted); }
.badge { position: absolute; inset-block-start: -2px; inset-inline-end: -2px; background: var(--danger); color: #fff; border-radius: 999px; font-size: .68rem; min-inline-size: 18px; block-size: 18px; display: grid; place-items: center; font-weight: 700; }

/* ---- App shell ---- */
.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 1rem; padding: 1rem; min-block-size: 100vh; }
.sidebar { padding: 1rem .8rem; display: flex; flex-direction: column; gap: .5rem; position: sticky; inset-block-start: 1rem; block-size: calc(100vh - 2rem); overflow: auto; }
.brand-row { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem .75rem; font-size: 1.05rem; }
.brand-mark { display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: 12px; color: var(--on-accent);
  background: linear-gradient(160deg, var(--accent-hi), var(--accent-lo)); box-shadow: 0 3px 0 hsl(var(--h) 70% calc(var(--accent-l) - 18%)), inset 0 1px 0 hsla(0 0% 100% / .5); }
.nav-list { display: flex; flex-direction: column; gap: .2rem; }
.nav-heading { margin: .9rem .6rem .2rem; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.nav-link { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; border: 1px solid transparent; }
.nav-link:hover { background: var(--glass); }
.nav-link.active { background: var(--glass-strong); border-color: var(--glass-border); box-shadow: var(--glass-shadow); color: var(--accent); }
.sidebar-foot { margin-block-start: auto; display: flex; flex-direction: column; gap: .35rem; }
.main-col { min-inline-size: 0; display: flex; flex-direction: column; gap: 1rem; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .55rem .8rem; position: sticky; inset-block-start: 1rem; z-index: 20; }
.search-box { position: relative; flex: 1; max-inline-size: 560px; display: flex; align-items: center; }
.search-box > .icon { position: absolute; inset-inline-start: .75rem; color: var(--muted); pointer-events: none; }
.input-search { padding-inline-start: 2.3rem; }
.search-results { position: absolute; inset-block-start: calc(100% + 6px); inset-inline: 0; max-block-size: 60vh; overflow: auto; z-index: 30; padding: .35rem; background: var(--glass-strong); }
.search-item { display: block; padding: .5rem .7rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.search-item:hover, .search-item:focus { background: hsla(var(--h) 80% 50% / .14); }
.search-item small { display: block; color: var(--muted); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .35rem; }
.menu-wrap { position: relative; }
.dropdown { position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0; min-inline-size: 220px; max-inline-size: 340px; padding: .35rem; z-index: 40; background: var(--glass-strong); }
.dropdown-item { display: flex; align-items: center; gap: .55rem; inline-size: 100%; text-align: start; padding: .5rem .7rem; border-radius: 10px; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: hsla(var(--h) 80% 50% / .16); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-note { padding: .6rem .8rem; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; inline-size: 28px; block-size: 28px; border-radius: 50%; background: linear-gradient(160deg, var(--accent-hi), var(--accent-lo)); color: var(--on-accent); font-weight: 700; font-size: .85rem; }
.user-name { max-inline-size: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { min-inline-size: 0; outline: none; }
.only-mobile { display: none; }

/* ---- Page content ---- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-block-end: 1rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.crumbs { color: var(--muted); font-size: .9rem; }
.dropzone { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; margin-block-end: 1rem; border-style: dashed; border-width: 2px; border-color: hsla(var(--h) 60% 45% / .5); cursor: pointer; flex-wrap: wrap; }
.dropzone.dragover { background: var(--glass-strong); border-color: var(--accent); }
.dropzone p { margin: 0; }
.progress { flex-basis: 100%; block-size: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { block-size: 100%; inline-size: 0; background: linear-gradient(90deg, var(--accent-lo), var(--accent-hi)); transition: inline-size .15s linear; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; padding: .7rem 1rem; margin-block-end: 1rem; }
.folder-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-block-end: 1rem; }
.folder-chip { display: inline-flex; align-items: center; gap: .15rem; padding: .25rem .4rem .25rem .8rem; }
.folder-link { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 600; padding-inline-end: .4rem; }
.table-card { padding: .25rem; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.data-table { inline-size: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: .65rem .8rem; text-align: start; border-block-end: 1px solid var(--line); white-space: nowrap; }
.data-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.data-table tbody tr:hover { background: hsla(var(--h) 80% 50% / .08); }
.data-table tbody tr:last-child td { border-block-end: 0; }
.file-name { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; }
.file-name:hover { color: var(--accent); }
.row-actions { text-align: end !important; }
.fav.on { color: hsl(42 95% 45%); } .fav.on .icon { fill: currentColor; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .9rem; flex-wrap: wrap; }
.pager-links { display: inline-flex; gap: .6rem; align-items: center; }
.empty-state { display: grid; place-items: center; gap: .5rem; padding: 3rem 1rem; color: var(--muted); text-align: center; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; }
.notice { padding: 1.5rem; max-inline-size: 640px; margin: 2rem auto; }

/* ---- Modal / toast ---- */
.modal-backdrop { position: fixed; inset: 0; background: hsla(var(--h) 60% 8% / .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { inline-size: min(560px, 100%); max-block-size: 92vh; overflow: auto; padding: 1.2rem 1.3rem; background: var(--glass-strong); }
.modal h2 { margin-block-end: .9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-block-start: 1rem; flex-wrap: wrap; }
.modal .alert { margin-block-end: .75rem; }
.toast-region { position: fixed; inset-block-end: 1rem; inset-inline-start: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 200; pointer-events: none; }
.toast { padding: .6rem 1rem; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); animation: toast-in .25s var(--ease); pointer-events: auto; max-inline-size: 90vw; }
.toast.error { border-color: var(--danger); color: var(--danger); } .toast.success { border-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.update-banner { position: fixed; inset-block-end: 1rem; inset-inline-end: 1rem; padding: .6rem .9rem; display: flex; gap: .8rem; align-items: center; z-index: 150; }
.share-section + .share-section { border-block-start: 1px solid var(--line); margin-block-start: 1rem; padding-block-start: 1rem; }
.link-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .4rem 0; border-block-end: 1px dashed var(--line); }

/* ---- Auth / install ---- */
.auth-shell { min-block-size: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card, .install-card { inline-size: min(440px, 100%); padding: 1.6rem; }
.install-card { inline-size: min(720px, 100%); }
.auth-card h1 { margin-block-end: 1rem; }
.auth-links { text-align: center; margin: 1rem 0 0; }
.lang-form { margin-block-start: 1rem; display: flex; justify-content: center; }
.lang-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-block-end: .5rem; }
.req-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .25rem .75rem; margin: 0 0 1rem; }
.req-list .ok { color: var(--ok); } .req-list .bad { color: var(--danger); font-weight: 700; }
.error-box { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 4rem; font-weight: 800; margin: 0; color: var(--accent); }

/* ---- Settings ---- */
.theme-grid { border: 0; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.theme-card { display: flex; flex-direction: column; gap: .35rem; padding: .9rem; cursor: pointer; transition: transform .15s var(--ease), border-color .15s; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card.selected, .theme-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--glass-shadow); }
.theme-card:has(input:focus-visible) { outline: 3px solid var(--accent-hi); outline-offset: 2px; }
.swatch { display: flex; block-size: 46px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.swatch i { flex: 1; }
[data-swatch="blue"] i:nth-child(1) { background: #e8f3ff; } [data-swatch="blue"] i:nth-child(2) { background: #9fcdf5; } [data-swatch="blue"] i:nth-child(3) { background: #1f6fb3; }
[data-swatch="emerald"] i:nth-child(1) { background: #e6f7ee; } [data-swatch="emerald"] i:nth-child(2) { background: #8fdcb4; } [data-swatch="emerald"] i:nth-child(3) { background: #0f7a4a; }
[data-swatch="violet"] i:nth-child(1) { background: #f1ebff; } [data-swatch="violet"] i:nth-child(2) { background: #c5b1f5; } [data-swatch="violet"] i:nth-child(3) { background: #6a3fc4; }
[data-swatch="dark"] i:nth-child(1) { background: #0a1220; } [data-swatch="dark"] i:nth-child(2) { background: #16294a; } [data-swatch="dark"] i:nth-child(3) { background: #4aa8ff; }

/* ---- Editor page ---- */
.editor-body { margin: 0; block-size: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.editor-bar { display: flex; align-items: center; gap: .6rem; padding: .4rem .7rem; margin: .5rem .5rem 0; border-radius: 14px; flex-wrap: wrap; }
.editor-title { font-size: 1.05rem; margin: 0; display: inline-flex; align-items: center; gap: .45rem; min-inline-size: 0; }
.editor-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 38vw; }
.editor-actions { margin-inline-start: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.editor-host { flex: 1; min-block-size: 0; margin: .5rem; border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--glass-border); }
.editor-host iframe { inline-size: 100%; block-size: 100%; border: 0; }
.status-pill { font-size: .8rem; font-weight: 700; padding: .2rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); }
.status-pill[data-state="saved"] { color: var(--ok); border-color: var(--ok); }
.status-pill[data-state="dirty"], .status-pill[data-state="saving"] { color: var(--warn); border-color: var(--warn); }
.status-pill[data-state="error"], .status-pill[data-state="offline"] { color: var(--danger); border-color: var(--danger); }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); padding: .6rem; }
  .only-mobile { display: inline-flex; }
  .sidebar { position: fixed; inset-block: .6rem; inset-inline-start: .6rem; inline-size: min(300px, 86vw); block-size: auto; z-index: 90; transform: translateX(-120%); transition: transform .22s var(--ease); background: var(--glass-strong); }
  [dir="rtl"] .sidebar { transform: translateX(120%); }
  .sidebar.open { transform: none !important; }
  .topbar { inset-block-start: .6rem; }
  .user-name { display: none; }
  .editor-title span { max-inline-size: 50vw; }
}
@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .head-actions .btn { flex: 1 1 auto; }
  .data-table th:nth-child(3), .data-table td:nth-child(3), .data-table th:nth-child(4), .data-table td:nth-child(4) { display: none; }
  .filters { gap: .5rem; }
}

/* ---- Accessibility preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .btn:hover { transform: none; }
}
@media (prefers-contrast: more) {
  :root { --glass: var(--glass-strong); --line: currentColor; }
  .glass-card::before, .glass-panel::before { display: none; }
}
@media print { .sidebar, .topbar, .head-actions, .filters, .toast-region { display: none !important; } body { background: #fff; color: #000; } .glass-card { box-shadow: none; border: 1px solid #999; } }
