/* Smart Suite design system — SmartStudio.
   Tokens are verbatim from DESIGN_SYSTEM.md (SmartSurf). Never hard-code a hex
   in a component; reference the variable. Light theme only.

   SmartStudio adds an editor layer on top of the suite language, because this
   app has a surface the others do not: a canvas. Those additions are namespaced
   --ed-* and kept below the suite block so the shared tokens stay recognisable.
*/

:root {
  --navy:      #1A0033;
  --purple:    #7020B0;
  --purple-l:  #9D4EDD;
  --purple-xl: #C77DFF;
  --lilac:     #E0AAFF;
  --light:     #F5EDFB;
  --mid:       #DCC4F5;
  --bg:        #FAFAFA;
  --card:      #FFFFFF;
  --border:    #E5DDF0;
  --text:      #241638;
  --muted:     #6B5D7E;
  --success:   #2D8A4F;
  --warning:   #C77;
  --danger:    #C33;
  --font-display: 'Space Grotesk', 'Poppins', -apple-system, sans-serif;
  --font-body:    'Poppins', -apple-system, sans-serif;

  /* editor chrome — a working surface, deliberately cooler and quieter than
     the app pages so the artboard is the brightest thing on screen */
  --ed-shell:   #F2EFF6;
  --ed-rail:    #FFFFFF;
  --ed-void:    #E8E4EF;
  --ed-grid:    rgba(26,0,51,0.055);
  --ed-select:  #7020B0;
  --ed-handle:  #FFFFFF;
}

:root { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: 4px; }

/* ── sidebar ─────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }
.main { flex: 1; margin-left: 240px; padding: 28px 32px 48px; max-width: 1400px; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 240px;
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column; overflow-y: auto; z-index: 30;
}
.sb-brand { display: flex; align-items: center; gap: 11px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.09); }
.sb-wordmark { font-family: var(--font-display); line-height: 1.05; }
.sb-wordmark .l1 { display: block; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.sb-wordmark .l2 { display: block; font-size: 15px; font-weight: 700; color: #c175f9; letter-spacing: -0.01em; }
.sb-nav { padding: 14px 10px; flex: 1; }
.sb-section { font-size: 10px; font-weight: 600; color: var(--lilac);
  text-transform: uppercase; letter-spacing: 1.5px; padding: 14px 8px 7px; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--mid); font-size: 13.5px; font-weight: 500; text-decoration: none;
  margin-bottom: 2px; transition: background .15s, color .15s; }
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active { background: var(--purple); color: #fff; }
.sb-item svg { width: 18px; height: 18px; flex: none; }
.sb-badge { font-size: 10.5px; font-weight: 700; background: var(--danger);
  color: #fff; border-radius: 999px; padding: 1px 7px; min-width: 8px; text-align: center; }
.sb-badge:empty { display: none; }
.sb-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.09);
  font-size: 11px; color: var(--mid); }

/* the shared SmartStudio bars mark */
.pf-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(150deg, var(--purple-l), var(--purple) 65%, var(--navy));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 6px 18px rgba(112,32,176,0.28); }
.pf-icon svg, .pf-icon img { width: 19px; height: 19px; }
.pf-icon.lg { width: 54px; height: 54px; border-radius: 14px; }
.pf-icon.lg svg, .pf-icon.lg img { width: 27px; height: 27px; }

/* ── page furniture ──────────────────────────────────────── */

.page-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); gap: 16px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--navy); font-family: var(--font-display); margin: 0; }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--navy); margin: 0 0 12px; font-family: var(--font-display); }
.stat { border-top: 3px solid var(--purple); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--navy); font-family: var(--font-display); line-height: 1.1; }
.stat-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.btn { padding: 9px 16px; border-radius: 7px; font-weight: 600; font-size: 13px; cursor: pointer;
  border: none; transition: all .15s; font-family: inherit; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-l); }
.btn-secondary { background: #fff; color: var(--purple); border: 1px solid var(--purple); }
.btn-secondary:hover { background: var(--light); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--light); color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 12px; display: inline-block; }
.pill-ok    { background: #E6F7EB; color: var(--success); }
.pill-warn  { background: #FFF5E5; color: #C77; }
.pill-draft { background: var(--light); color: var(--muted); }
.pill-info  { background: var(--mid); color: var(--purple); }
.pill-bad   { background: #FDECEC; color: var(--danger); }

.pill-live { background: rgba(45,138,79,0.1); color: var(--success); font-size: 11px; font-weight: 600;
  padding: 3px 9px 3px 20px; border-radius: 12px; position: relative; display: inline-block; }
.pill-live::before { content: ''; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) { .pill-live::before { animation: none } }

table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
td { font-size: 13px; padding: 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--light); }
/* numeric table columns — digits must line up to be comparable at a glance */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.form-label { font-size: 12px; font-weight: 600; color: var(--navy); margin-bottom: 6px; display: block; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; background: #fff; color: var(--text); font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--purple); outline: none; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.field { margin-bottom: 14px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--navy); font-family: var(--font-display); margin: 0 0 6px; font-size: 15px; }

/* ═══════════════════════════════════════════════════════════
   EDITOR — the surface the rest of the suite does not have
   ═══════════════════════════════════════════════════════════ */

.ed { position: fixed; inset: 0; display: grid;
  grid-template-columns: 264px 1fr 300px; grid-template-rows: 56px 1fr;
  background: var(--ed-shell); }

/* top bar spans all three columns */
.ed-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: var(--navy); color: #fff; z-index: 20; }
.ed-top .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.ed-top .brand .l1 { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #fff; }
.ed-top .brand .l2 { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #c175f9; }
.ed-docname { font-family: var(--font-display); font-weight: 600; font-size: 14px;
  color: #fff; background: rgba(255,255,255,.08); border: 1px solid transparent;
  border-radius: 7px; padding: 6px 11px; min-width: 190px; }
.ed-docname:focus { background: rgba(255,255,255,.14); border-color: var(--purple-l); outline: none; }
.ed-top .spacer { flex: 1; }
.ed-chip { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08);
  border-radius: 7px; padding: 5px 8px; font-size: 12px; color: var(--mid); }
.ed-chip select { background: transparent; border: none; color: #fff; font-family: inherit;
  font-size: 12px; font-weight: 600; padding: 1px 2px; }
.ed-chip select option { color: var(--text); }
.ed-zoom { display: flex; align-items: center; gap: 2px; }
.ed-zoom button { width: 26px; height: 26px; border-radius: 6px; border: none; cursor: pointer;
  background: rgba(255,255,255,.08); color: #fff; font-size: 15px; line-height: 1; }
.ed-zoom button:hover { background: rgba(255,255,255,.18); }
.ed-zoom .val { font-size: 12px; color: var(--mid); min-width: 44px; text-align: center;
  font-variant-numeric: tabular-nums; }

/* left rail */
.ed-left { background: var(--ed-rail); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; }
.ed-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.ed-tab { flex: 1; padding: 11px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; font-family: inherit; }
.ed-tab:hover { color: var(--navy); background: var(--light); }
.ed-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.ed-panel { flex: 1; overflow-y: auto; padding: 12px; display: none; }
.ed-panel.active { display: block; }
.ed-grouphead { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1.2px; margin: 4px 0 8px; }

/* layer list */
.lyr { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 8px;
  cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; }
.lyr:hover { background: var(--light); }
.lyr.sel { background: var(--light); border-color: var(--purple); }
.lyr .ico { width: 26px; height: 26px; border-radius: 6px; background: var(--light);
  display: flex; align-items: center; justify-content: center; color: var(--purple); flex: none; }
.lyr.sel .ico { background: var(--purple); color: #fff; }
.lyr .nm { flex: 1; font-size: 12.5px; font-weight: 500; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lyr .tag { font-size: 9.5px; font-weight: 600; color: var(--purple); background: var(--light);
  padding: 2px 5px; border-radius: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* element palette */
.el-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.el-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-size: 11.5px; font-weight: 500; color: var(--navy); font-family: inherit; transition: all .15s; }
.el-btn:hover { border-color: var(--purple); background: var(--light); color: var(--purple); }
.el-btn svg { width: 20px; height: 20px; }

/* data panel */
.src { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.src-head { display: flex; align-items: center; gap: 8px; padding: 10px 11px; background: var(--light); }
.src-head .nm { flex: 1; font-size: 12.5px; font-weight: 600; color: var(--navy); }
.fld { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-top: 1px solid var(--border);
  cursor: grab; font-size: 12px; }
.fld:hover { background: var(--light); }
.fld .k { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--purple); }
.fld .v { flex: 1; color: var(--muted); text-align: right; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.fld .req { font-size: 9px; color: var(--danger); font-weight: 700; }

/* fonts panel */
.frow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 9px; margin-bottom: 8px; }
.frow .aa { width: 34px; height: 34px; flex: none; border-radius: 7px; background: var(--light);
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--purple);
  font-weight: 600; }
.frow .meta { flex: 1; min-width: 0; }
.frow .fam { font-size: 12.5px; font-weight: 600; color: var(--navy); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.frow .sub { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.frow .del { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px;
  line-height: 1; padding: 4px; flex: none; }
.frow .del:hover { color: var(--danger); }

/* canvas */
.ed-canvas { position: relative; overflow: auto; background: var(--ed-void);
  background-image: radial-gradient(var(--ed-grid) 1px, transparent 1px); background-size: 16px 16px;
  display: grid; place-items: center; padding: 40px; }
/* The artboard box carries the SCALED size so the flow lays it out correctly and
   `place-items:center` actually centres it. The inner surface keeps design
   coordinates and is scaled from its top-left corner. Scaling the outer box
   instead leaves a full-size layout box behind and the view centres on that —
   which pushes the visible artwork off under the inspector. */
.artboard { position: relative; background: #000; flex: none; overflow: hidden;
  box-shadow: 0 10px 40px rgba(26,0,51,.28), 0 0 0 1px rgba(26,0,51,.12); }
.ab-inner { position: absolute; top: 0; left: 0; transform-origin: top left; }
.ab-layer { position: absolute; overflow: hidden; }
.ab-layer.pickable { cursor: pointer; }
.ab-layer.sel { outline: 2px solid var(--ed-select); outline-offset: 0; }
.ab-handle { position: absolute; width: 9px; height: 9px; background: var(--ed-handle);
  border: 1.5px solid var(--ed-select); border-radius: 2px; z-index: 5; }
.ab-handle[data-h="nw"], .ab-handle[data-h="se"] { cursor: nwse-resize; }
.ab-handle[data-h="ne"], .ab-handle[data-h="sw"] { cursor: nesw-resize; }
.ab-handle[data-h="n"],  .ab-handle[data-h="s"]  { cursor: ns-resize; }
.ab-handle[data-h="e"],  .ab-handle[data-h="w"]  { cursor: ew-resize; }

.ab-layer.pickable { cursor: move; }
.ab-layer.dragging { opacity: .92; }
.ab-layer.editing { outline: 2px dashed var(--ed-select); cursor: text; }
.ab-layer.editing .ab-txt { outline: none; }

/* Alignment guides. Rendered inside the scaled surface, so the line width is
   divided by the zoom to stay 1px on screen at any magnification. */
.ab-guide { position: absolute; background: #FF2D9B; pointer-events: none; z-index: 9; }
.ab-guide.v { top: 0; bottom: 0; }
.ab-guide.h { left: 0; right: 0; }

.ed-hint { position: absolute; right: 16px; bottom: 14px; display: flex; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 11px; font-size: 11px; color: var(--muted);
  box-shadow: 0 2px 8px rgba(26,0,51,.08); }
.ed-hint kbd { background: var(--light); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font: 600 10px var(--font-body); color: var(--navy); }
.ab-txt { display: flex; width: 100%; height: 100%; }

.ab-badge { position: absolute; top: -26px; left: 0; background: var(--ed-select); color: #fff;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }

.ed-status { position: absolute; left: 16px; bottom: 14px; display: flex; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 11px; font-size: 11.5px; box-shadow: 0 2px 8px rgba(26,0,51,.08); max-width: calc(100% - 32px); }
.ed-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }
.ed-status .dot.warn { background: var(--warning); }
.ed-status .dot.bad { background: var(--danger); }
.ed-status .msg { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* right inspector */
.ed-right { background: var(--ed-rail); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 14px; }
.insp-head { font-family: var(--font-display); font-size: 13px; font-weight: 600;
  color: var(--navy); margin: 0 0 3px; }
.insp-sub { font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.insp-sec { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.insp-sec:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .8px; margin-bottom: 4px; display: block; }
.form-input.sm { padding: 7px 9px; font-size: 12px; }
.swatch { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 7px;
  padding: 2px; background: #fff; cursor: pointer; }

.warnbox { background: #FFF5E5; border: 1px solid #F0DFC0; border-radius: 8px;
  padding: 9px 11px; font-size: 11.5px; color: #8a6516; margin-bottom: 10px; }
.badbox { background: #FDECEC; border: 1px solid #F3C9C9; border-radius: 8px;
  padding: 9px 11px; font-size: 11.5px; color: #9c2b2b; margin-bottom: 10px; }

@media (max-width: 1100px) {
  .ed { grid-template-columns: 220px 1fr; }
  .ed-right { display: none; }
}
