/* ============================================================================
   scriptmark — shared UI system (design tokens + components)
   Linked by every app to keep panels, toggles, headers and layouts consistent.
   All classes are prefixed `sm-` so they never clash with an app's own styles.
   ============================================================================ */
:root{
  --sm-bg:#08080a;
  --sm-panel:#141519;
  --sm-panel-2:#1b1c22;
  --sm-panel-3:#212229;
  --sm-line:#26272e;
  --sm-line-soft:#1d1e24;
  --sm-accent:#ffd23f;
  --sm-accent-tint:rgba(255,210,63,.12);
  --sm-accent-tint-2:rgba(255,210,63,.18);
  --sm-ink:#ffffff;
  --sm-muted:#8b9096;
  --sm-dim:#5a5e66;
  --sm-green:#4ade80;
  --sm-err:#ff5b52;
  --sm-r:16px;
  --sm-r-sm:10px;
  --sm-r-pill:999px;
  --sm-mono:ui-monospace,SFMono-Regular,Menlo,"SF Mono",monospace;
  --sm-sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}

/* ---- meta / eyebrow: mono, uppercase, letter-spaced, muted (the core motif) ---- */
.sm-meta{font-family:var(--sm-mono);font-size:11px;letter-spacing:.1em;text-transform:uppercase;color:var(--sm-muted);}
.sm-meta--dim{color:var(--sm-dim);}
.sm-meta--accent{color:var(--sm-accent);}

/* ---- top bar ---- */
.sm-topbar{display:flex;align-items:center;gap:14px;padding:max(14px,env(safe-area-inset-top)) 22px 14px;}
.sm-logo{height:22px;width:auto;display:block;cursor:pointer;}
.sm-topbar .sm-spacer{flex:1;}
.sm-top-right{display:flex;align-items:center;gap:10px;}

/* ---- search pill ---- */
.sm-search{display:inline-flex;align-items:center;gap:9px;height:38px;padding:0 16px;
  background:var(--sm-panel-2);border:1px solid var(--sm-line);border-radius:var(--sm-r-pill);
  color:var(--sm-muted);font-size:14px;cursor:pointer;font-family:var(--sm-sans);}
.sm-search:hover{border-color:var(--sm-line);background:var(--sm-panel-3);}
.sm-search svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-search input{background:none;border:none;outline:none;color:var(--sm-ink);font-size:14px;font-family:inherit;width:100%;}

/* ---- icon button (bell etc.) + avatar ---- */
.sm-iconbtn{width:38px;height:38px;border-radius:50%;background:var(--sm-panel-2);border:1px solid var(--sm-line);
  color:var(--sm-muted);display:flex;align-items:center;justify-content:center;cursor:pointer;}
.sm-iconbtn svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-avatar{width:38px;height:38px;border-radius:50%;background:var(--sm-accent-tint);border:1.5px solid var(--sm-accent);
  color:var(--sm-accent);font-size:13px;font-weight:700;letter-spacing:.04em;display:flex;align-items:center;justify-content:center;cursor:pointer;}

/* ---- buttons ---- */
.sm-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:12px;
  padding:11px 18px;font-size:14px;font-weight:600;cursor:pointer;font-family:var(--sm-sans);border:1px solid transparent;line-height:1;}
.sm-btn--accent{background:var(--sm-accent);color:#000;}
.sm-btn--ghost{background:var(--sm-panel-2);color:var(--sm-ink);border-color:var(--sm-line);}
.sm-btn--pill{background:var(--sm-panel-2);color:var(--sm-muted);border:1px solid var(--sm-line);border-radius:var(--sm-r-pill);padding:8px 15px;font-size:13px;}
.sm-btn svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-btn:disabled{opacity:.5;cursor:default;}

/* ---- icon chip (rounded square, amber-tinted) ---- */
.sm-chip{width:44px;height:44px;border-radius:13px;background:var(--sm-accent-tint);color:var(--sm-accent);
  display:flex;align-items:center;justify-content:center;flex:0 0 auto;}
.sm-chip svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-chip--sm{width:34px;height:34px;border-radius:10px;}
.sm-chip--sm svg{width:17px;height:17px;}

/* ---- tiles ---- */
.sm-tile{display:flex;flex-direction:column;gap:12px;background:var(--sm-panel);border:1px solid var(--sm-line);
  border-radius:18px;padding:22px;cursor:pointer;position:relative;text-align:left;color:var(--sm-ink);
  transition:border-color .15s,transform .1s,background .15s;min-height:210px;}
.sm-tile:hover{border-color:#3a3b42;}
.sm-tile:active{transform:scale(.99);}
.sm-tile__title{font-size:20px;font-weight:700;}
.sm-tile__desc{font-size:13.5px;color:var(--sm-muted);line-height:1.45;}
.sm-tile__foot{margin-top:auto;padding-top:14px;border-top:1px solid var(--sm-line-soft);
  display:flex;align-items:center;justify-content:space-between;}
.sm-tile__foot .sm-arrow{color:var(--sm-accent);display:flex;}
.sm-tile__foot .sm-arrow svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-tile--featured{border-color:var(--sm-accent);background:linear-gradient(160deg,rgba(255,210,63,.07),rgba(255,210,63,.02));
  box-shadow:0 0 0 1px var(--sm-accent),0 10px 40px -16px rgba(255,210,63,.35);}
.sm-badge-new{position:absolute;top:16px;right:16px;background:var(--sm-accent);color:#000;
  font-family:var(--sm-mono);font-size:10px;font-weight:700;letter-spacing:.1em;padding:4px 8px;border-radius:7px;}

/* ---- list rows (library / activity) ---- */
.sm-row{display:flex;align-items:center;gap:14px;background:var(--sm-panel);border:1px solid var(--sm-line);
  border-radius:14px;padding:14px 16px;cursor:pointer;transition:border-color .15s,background .15s;}
.sm-row:hover{border-color:#3a3b42;background:var(--sm-panel-2);}
.sm-row__body{flex:1;min-width:0;}
.sm-row__title{font-size:15px;font-weight:600;color:var(--sm-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sm-row__sub{margin-top:3px;}
.sm-row__right{display:flex;align-items:center;gap:12px;flex:0 0 auto;}
.sm-chevron{color:var(--sm-dim);display:flex;}
.sm-chevron svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;}

/* amber-outlined pill badge (e.g. "✱ 2 marks") */
.sm-pill-badge{display:inline-flex;align-items:center;gap:5px;font-family:var(--sm-mono);font-size:11px;font-weight:700;
  letter-spacing:.06em;text-transform:uppercase;color:var(--sm-accent);background:var(--sm-accent-tint);
  border:1px solid rgba(255,210,63,.35);border-radius:var(--sm-r-pill);padding:5px 10px;}

/* ---- section header ---- */
.sm-section-head{display:flex;align-items:center;justify-content:space-between;margin:0 0 14px;}
.sm-section-head h2{font-size:19px;font-weight:700;margin:0;color:var(--sm-ink);}

/* ---- sidebar (folders / scenes / layers) ---- */
.sm-side-head{font-family:var(--sm-mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--sm-muted);
  display:flex;align-items:center;justify-content:space-between;padding:4px 6px;margin-bottom:8px;}
.sm-side-item{display:flex;align-items:center;gap:11px;padding:11px 12px;border-radius:10px;cursor:pointer;color:var(--sm-ink);
  border:1px solid transparent;position:relative;}
.sm-side-item:hover{background:var(--sm-panel-2);}
.sm-side-item.sm-on{background:var(--sm-accent-tint);color:var(--sm-accent);}
.sm-side-item.sm-on::before{content:"";position:absolute;left:0;top:8px;bottom:8px;width:3px;border-radius:2px;background:var(--sm-accent);}
.sm-side-item svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;flex:0 0 auto;}
.sm-side-item .sm-side-label{flex:1;min-width:0;font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sm-side-item .sm-side-count{font-family:var(--sm-mono);font-size:12px;color:var(--sm-muted);}

/* ---- layer row: color dot · title · info · eye ---- */
.sm-layer{display:flex;align-items:center;gap:11px;padding:12px 12px;border-radius:12px;border:1px solid transparent;cursor:pointer;}
.sm-layer:hover{background:var(--sm-panel-2);}
.sm-layer.sm-on{border-color:var(--sm-accent);background:var(--sm-accent-tint);}
.sm-layer__dot{width:11px;height:11px;border-radius:50%;flex:0 0 auto;}
.sm-layer__body{flex:1;min-width:0;}
.sm-layer__title{font-size:14px;font-weight:700;color:var(--sm-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sm-layer__eye{color:var(--sm-muted);cursor:pointer;display:flex;flex:0 0 auto;}
.sm-layer__eye svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2;}
.sm-layer.sm-hidden .sm-layer__title{color:var(--sm-dim);}

/* ---- status (synced) ---- */
.sm-status{display:inline-flex;align-items:center;gap:6px;font-family:var(--sm-mono);font-size:12px;letter-spacing:.08em;
  text-transform:uppercase;color:var(--sm-green);}
.sm-status svg{width:14px;height:14px;stroke:currentColor;fill:none;stroke-width:2;}

/* ---- divider ---- */
.sm-divider{height:1px;background:var(--sm-line-soft);border:none;margin:0;}

/* ============================================================================
   LIGHT THEME — warm-paper palette. Dormant until <html data-theme="light">.
   Only overrides the --sm-* tokens (+ a few intentionally-dark accents), so any
   surface built on the shared tokens flips automatically; apps keeping their own
   --bg/--panel vars also need light overrides of those (added per app).
   ============================================================================ */
:root[data-theme="light"]{
  --sm-bg:#f3f0e8;
  --sm-panel:#ffffff;
  --sm-panel-2:#eeeae0;
  --sm-panel-3:#e6e1d4;
  --sm-line:#e4dfd1;
  --sm-line-soft:#ece8dd;
  --sm-ink:#1b1a17;
  --sm-muted:#8b8675;
  --sm-dim:#aaa493;
  --sm-accent-tint:rgba(255,210,63,.20);
  --sm-accent-tint-2:rgba(255,210,63,.30);
}
/* avatar reads as a solid dark chip on the light page (matches the reference) */
:root[data-theme="light"] .sm-avatar{background:#1b1a17;border-color:#1b1a17;color:#fff;}
/* the featured tile (Wonderframe) stays a dark card for contrast */
:root[data-theme="light"] .sm-tile--featured{background:#141414;border-color:#141414;
  box-shadow:0 16px 42px -18px rgba(0,0,0,.45);}
:root[data-theme="light"] .sm-tile--featured .sm-tile__title{color:#fff;}
:root[data-theme="light"] .sm-tile--featured .sm-tile__desc{color:#b3ae9f;}
:root[data-theme="light"] .sm-tile--featured .sm-tile__foot{border-color:rgba(255,255,255,.12);}

/* ---- AI usage readout (sits inside an avatar dropdown menu) ---- */
.sm-usage{padding:8px 10px 10px;border-bottom:1px solid var(--sm-line-soft);margin-bottom:6px;}
.sm-usage-lbl{display:block;font-family:var(--sm-mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--sm-muted);margin-bottom:8px;}
.sm-usage-row{display:flex;align-items:center;justify-content:space-between;font-size:13px;color:var(--sm-ink);}
.sm-usage-row .n{font-family:var(--sm-mono);font-size:12px;color:var(--sm-muted);}
.sm-bar{height:4px;border-radius:2px;background:var(--sm-panel-3);overflow:hidden;margin:5px 0 9px;}
.sm-bar:last-child{margin-bottom:0;}
.sm-bar>i{display:block;height:100%;width:0;background:var(--sm-accent);border-radius:2px;transition:width .3s ease;}

/* ---- theme toggle row (sits inside an avatar dropdown menu) ---- */
.sm-theme-row{padding:8px 10px 10px;border-bottom:1px solid var(--sm-line-soft);margin-bottom:6px;}
.sm-theme-row .sm-theme-lbl{display:block;font-family:var(--sm-mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--sm-muted);margin-bottom:8px;}
.sm-seg{display:flex;background:var(--sm-panel-2);border:1px solid var(--sm-line);border-radius:9px;padding:3px;gap:2px;}
.sm-seg button{flex:1;background:none;border:none;color:var(--sm-muted);font-size:12px;font-weight:600;padding:7px 4px;border-radius:6px;cursor:pointer;font-family:inherit;}
.sm-seg button.on{background:var(--sm-accent);color:#000;}

/* ---- avatar dropdown menu (shared by every app so they all match Home) ---- */
.sm-avmenu{position:fixed;top:60px;right:18px;z-index:160;min-width:210px;display:none;
  background:var(--sm-panel);border:1px solid var(--sm-line);border-radius:12px;padding:8px;
  box-shadow:0 18px 50px -16px rgba(0,0,0,.45);}
.sm-avmenu.show{display:block;}
.sm-avmenu .am-email{font-size:12px;color:var(--sm-muted);padding:8px 10px;margin-bottom:6px;
  border-bottom:1px solid var(--sm-line-soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;word-break:break-all;}
.sm-avmenu .am-item,.sm-avmenu>button,.sm-avmenu>a{display:block;width:100%;box-sizing:border-box;text-align:left;
  background:none;border:none;color:var(--sm-ink);font-size:14px;padding:10px;border-radius:9px;cursor:pointer;
  font-family:inherit;text-decoration:none;}
.sm-avmenu .am-item:hover,.sm-avmenu>button:hover,.sm-avmenu>a:hover{background:var(--sm-panel-2);}

/* ---- generation-modal components (Generate / From-scene / Settings preset editor) ---- */
/* 44px+ touch targets throughout — these modals are used on iPad on set. */
.sm-segbig{display:flex;background:var(--sm-panel-2);border:1px solid var(--sm-line);border-radius:12px;padding:4px;gap:4px;}
.sm-segbig button{flex:1;height:44px;background:none;border:none;border-radius:9px;color:var(--sm-muted);font-size:14px;font-weight:600;cursor:pointer;font-family:inherit;-webkit-tap-highlight-color:transparent;}
.sm-segbig button.on{background:var(--sm-accent);color:#000;}

/* 16:9 tap-to-add reference tile: the whole tile is the target; filled = image + × badge */
.sm-reflab{display:block;font-family:var(--sm-mono);font-size:10px;letter-spacing:.07em;text-transform:uppercase;color:var(--sm-muted);margin-bottom:6px;text-align:center;}
.sm-refgrid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;}
.sm-reftile{position:relative;aspect-ratio:16/9;border-radius:11px;border:1.5px dashed rgba(139,144,150,.45);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;cursor:pointer;
  color:var(--sm-muted);font-size:12px;overflow:hidden;-webkit-tap-highlight-color:transparent;}
.sm-reftile.has{border:1px solid var(--sm-line);}
.sm-reftile>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:none;}
.sm-reftile.has>img{display:block;}
.sm-reftile .rt-ph{display:flex;flex-direction:column;align-items:center;gap:3px;pointer-events:none;}
.sm-reftile .rt-ph svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.sm-reftile.has .rt-ph{display:none;}
.sm-reftile .rt-x{position:absolute;top:6px;right:6px;z-index:2;width:30px;height:30px;border-radius:8px;border:none;
  background:rgba(0,0,0,.55);color:#fff;cursor:pointer;display:none;align-items:center;justify-content:center;padding:0;}
.sm-reftile.has .rt-x{display:flex;}
.sm-reftile .rt-x svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;}
.sm-reftile .rt-hint{position:absolute;left:8px;bottom:6px;z-index:1;font-family:var(--sm-mono);font-size:10px;color:#fff;
  text-shadow:0 1px 3px rgba(0,0,0,.8);display:none;pointer-events:none;}
.sm-reftile.has .rt-hint{display:block;}

/* visual preset picker (replaces a native <select>: a preset IS its images) */
.sm-presetlist{display:flex;flex-direction:column;gap:10px;}
.sm-presetrow{display:flex;gap:12px;align-items:center;border:1.5px solid var(--sm-line);border-radius:12px;
  padding:10px 12px;cursor:pointer;background:transparent;width:100%;box-sizing:border-box;text-align:left;
  font-family:inherit;-webkit-tap-highlight-color:transparent;}
.sm-presetrow.on{border-color:var(--sm-accent);background:var(--sm-accent-tint);}
.sm-presetrow .pr-thumbs{display:flex;gap:4px;flex:0 0 auto;}
.sm-presetrow .pr-thumbs>span{width:52px;aspect-ratio:16/9;border-radius:5px;display:block;
  background:var(--sm-panel-2) center/cover no-repeat;font-family:var(--sm-mono);font-size:10px;
  color:var(--sm-dim);text-align:center;line-height:29px;overflow:hidden;}
.sm-presetrow .pr-body{flex:1;min-width:0;}
.sm-presetrow .pr-name{display:block;font-size:14px;font-weight:600;color:var(--sm-ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.sm-presetrow .pr-sub{display:block;font-size:12px;color:var(--sm-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;}
.sm-presetrow .pr-chk{flex:0 0 auto;width:22px;height:22px;color:var(--sm-accent);display:none;}
.sm-presetrow.on .pr-chk{display:block;}
.sm-presetrow .pr-chk svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;}
.sm-pr-tag{font-family:var(--sm-mono);font-size:9px;letter-spacing:.08em;color:var(--sm-accent);
  border:1px solid var(--sm-accent);border-radius:5px;padding:1px 6px;margin-left:7px;vertical-align:1px;}

/* − N + stepper (replaces number inputs on touch) */
.sm-stepper{display:flex;align-items:center;border:1px solid var(--sm-line);border-radius:11px;background:var(--sm-panel-2);height:48px;}
.sm-stepper button{width:56px;height:100%;border:none;background:transparent;color:var(--sm-ink);cursor:pointer;
  font-size:22px;line-height:1;font-family:inherit;padding:0;-webkit-tap-highlight-color:transparent;}
.sm-stepper .st-val{flex:1;text-align:center;font-size:19px;font-weight:700;color:var(--sm-ink);}

/* ---- toggle switch (amber iOS-style; replaces checkboxes) ---- */
.sm-toggle{display:inline-flex;align-items:center;gap:12px;cursor:pointer;-webkit-tap-highlight-color:transparent;}
.sm-toggle>input{position:absolute;opacity:0;width:0;height:0;}
.sm-toggle .sm-track{width:48px;height:28px;border-radius:999px;background:#3a3b42;flex:0 0 auto;position:relative;transition:background .15s;}
.sm-toggle .sm-track::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:transform .15s;box-shadow:0 1px 3px rgba(0,0,0,.4);}
.sm-toggle>input:checked + .sm-track{background:var(--sm-accent);}
.sm-toggle>input:checked + .sm-track::after{transform:translateX(20px);background:#141414;}
.sm-toggle>input:focus-visible + .sm-track{box-shadow:0 0 0 3px var(--sm-accent-tint);}
.sm-toggle .sm-toggle-label{font-size:15px;font-weight:600;color:var(--sm-ink);}
