:root {
  --ink: #1C1B19; --ink-2: #3D3A35; --muted: #6B665E; --soft-ink: #4A463F;
  --line: #DDD8CE; --line-2: #ECE8E0; --edge: #E4DFD5;
  --paper: #FFFFFF; --ground: #F3F1EC; --soft: #FBFAF7; --chip: #EEEBE4;
  --accent: #2E4BC6; --accent-ink: #1F3591; --accent-tint: #E8ECFB;
  --live: #2F6B45; --live-bg: #E3F1E7; --draft: #6E5100; --draft-bg: #FFF1C1; --hidden-bg: #EEEBE4;
  --danger: #A1321F; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Figtree, system-ui, sans-serif; color: var(--ink); background: var(--ground); font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { display: flex; height: 100vh; height: 100dvh; }

/* sidebar */
.side { width: 256px; flex-shrink: 0; background: var(--paper); border-right: 1px solid var(--edge); display: flex; flex-direction: column; gap: 22px; padding: 20px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.brand span { font-family: 'Bricolage Grotesque', sans-serif; font-size: 20px; font-weight: 700; }
.brand em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--soft-ink); background: var(--chip); padding: 3px 8px; border-radius: 999px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group p { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav-group a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-group a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-group a span { flex: 1; }
.nav-group a b { font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-group a:hover { background: var(--ground); }
.nav-group a[aria-current="page"] { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
.nav-group a[aria-current="page"] b { color: var(--accent); }
.conn { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--soft-ink); display: flex; flex-direction: column; gap: 4px; }
.conn strong { color: var(--ink); font-size: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: #C9C4B8; }
.dot.on { background: #3F9A62; }

/* top bar */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 68px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--paper); border-bottom: 1px solid var(--edge); }
.top-title { font-size: 13px; color: var(--muted); }
.top-title strong { color: var(--ink); }
.grow { flex: 1; }
.link-ext { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; text-decoration: none; }
.link-ext svg { width: 16px; height: 16px; }
.notice { margin: 16px 32px 0; padding: 12px 16px; border-radius: 12px; background: #FFF8E1; color: #5C4A12; font-size: 14px; line-height: 1.5; }
.notice.error { background: #FBEAE6; color: #7A2616; }
.notice a, .notice button.linklike { color: inherit; font-weight: 700; }
.view { flex: 1; overflow-y: auto; padding: 28px 32px 48px; outline: none; }

/* buttons */
.btn { height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; color: var(--ink); text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--soft); border-color: #C9C4B8; color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.btn.dark:hover:not(:disabled) { background: #000; color: #fff; }
.btn.plain { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); border-color: #E5C3BC; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.pill { background: rgba(255,255,255,.22); padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; }

/* page head */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .t { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 6px; }
.page-head h1 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 32px; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: 0; font-size: 15px; color: var(--soft-ink); max-width: 720px; line-height: 1.5; }
.crumb { font-size: 13px; color: var(--muted); }

/* tabs + filters */
.tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--edge); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { height: 42px; padding: 0 12px; border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--soft-ink); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button span { font-weight: 500; color: var(--muted); margin-left: 4px; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.tabs .filter { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--soft-ink); padding-bottom: 6px; }
select, .field input, .field textarea, .field select { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); padding: 0 12px; font-size: 15px; }
.tabs select { height: 34px; font-size: 13px; padding: 0 8px; }
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { background: var(--paper); border: 1px solid var(--edge); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.card.is-hidden .pv { opacity: .45; }
.card .pv { display: block; width: 100%; aspect-ratio: 16 / 10; border-bottom: 1px solid var(--line-2); background: var(--ground); }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.card .line { display: flex; align-items: center; gap: 8px; }
.card h2 { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { font-size: 13px; color: var(--muted); flex: 1; }
.status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status.live { color: var(--live); background: var(--live-bg); }
.status.draft { color: var(--draft); background: var(--draft-bg); }
.status.hidden { color: var(--soft-ink); background: var(--hidden-bg); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--accent-tint); color: var(--accent); }

/* switch */
.switch { appearance: none; -webkit-appearance: none; margin: 0; width: 40px; height: 24px; border-radius: 12px; background: #CFC9BD; position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(28,27,25,.3); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.sw { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--soft-ink); }

/* menus */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; min-width: 180px; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(28,27,25,.18); display: flex; flex-direction: column; }
.menu button { height: 34px; border: 0; background: none; border-radius: 8px; text-align: left; padding: 0 10px; font-size: 14px; }
.menu button:hover { background: var(--ground); }
.menu button.danger { color: var(--danger); }

/* lists */
.list { background: var(--paper); border: 1px solid var(--edge); border-radius: 14px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line-2); }
.list-row:first-child { border-top: 0; }
.list-row .main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-row .name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.list-row .meta { font-size: 13px; color: var(--muted); }
.sample { font-size: 26px; line-height: 1.2; min-width: 240px; }

/* panels */
.panel { background: var(--paper); border: 1px solid var(--edge); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.panel h2 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel h2 .status { margin-left: auto; }
.panel p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--soft-ink); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check .m { color: var(--muted); }

/* editor */
.editor { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 24px; align-items: start; }
.editor form { background: var(--paper); border: 1px solid var(--edge); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.editor h3 { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: var(--ground); }
.seg button { height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; font-weight: 600; color: var(--soft-ink); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(28,27,25,.15); }
.colors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.color { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 8px 0 10px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.color input[type=color] { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; flex-shrink: 0; }
.color span { flex: 1; display: flex; flex-direction: column; }
.color small { font-size: 11px; font-weight: 600; color: var(--muted); }
.color button { width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; color: var(--muted); padding: 0; }
.color button:hover { background: var(--ground); color: var(--danger); }
.slider { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.slider input { accent-color: var(--accent); }
.slider output { font-size: 13px; color: var(--soft-ink); text-align: right; font-variant-numeric: tabular-nums; }
.preview-pane { background: #E9E5DC; border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 16px; align-items: center; position: sticky; top: 0; }
.preview-pane .bar { align-self: stretch; display: flex; align-items: center; gap: 10px; }
.preview-pane canvas { max-width: 100%; box-shadow: 0 10px 30px rgba(28,27,25,.18); background: #fff; }
.preview-pane .where { align-self: stretch; font-size: 13px; color: var(--soft-ink); }

/* layouts grid */
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.lthumb { position: relative; border: 2px solid var(--line-2); border-radius: 12px; background: var(--paper); padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lthumb canvas { width: 100%; aspect-ratio: 1; }
.lthumb span { font-size: 11px; font-weight: 600; color: var(--soft-ink); }
.lthumb[aria-pressed="false"] { border-color: transparent; background: var(--chip); }
.lthumb[aria-pressed="false"] canvas { opacity: .35; }
.lthumb[aria-pressed="false"] span { color: var(--muted); }

/* banner preview */
.banner-demo { border-radius: 12px; overflow: hidden; border: 1px solid var(--edge); }
.banner-demo .b { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 40px; padding: 6px 16px; background: var(--ink); color: #fff; font-size: 14px; }
.banner-demo .b[data-tone="accent"] { background: var(--accent); }
.banner-demo .b[data-tone="warm"] { background: #F6D58E; color: var(--ink); }
.banner-demo .b a { color: inherit; font-weight: 700; }
.banner-demo .fake { height: 90px; background: repeating-linear-gradient(90deg, var(--ground) 0 80px, var(--paper) 80px 81px); }

/* dialog */
.modal { border: 0; padding: 0; border-radius: 20px; box-shadow: 0 24px 60px rgba(28,27,25,.35); width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); color: var(--ink); }
.modal.small { width: min(560px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(28,27,25,.55); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 18px 28px; border-bottom: 1px solid var(--line-2); }
.dlg-head .t { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dlg-head h2 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 24px; font-weight: 700; }
.dlg-head p { margin: 0; font-size: 14px; color: var(--soft-ink); }
.dlg-body { display: flex; min-height: 0; overflow: auto; }
.dlg-pad { padding: 22px 28px; display: flex; flex-direction: column; gap: 16px; flex: 1; min-width: 0; }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line-2); }
.types { width: 320px; flex-shrink: 0; border-right: 1px solid var(--line-2); padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--soft); }
.types button { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: 12px; border: 2px solid transparent; background: transparent; text-align: left; }
.types button[aria-checked="true"] { border-color: var(--accent); background: var(--paper); }
.types .ico { width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--chip); color: var(--ink-2); }
.types button[aria-checked="true"] .ico { background: var(--accent); color: #fff; }
.types .ico svg { width: 20px; height: 20px; }
.types strong { display: block; font-size: 15px; }
.types small { display: block; font-size: 13px; color: var(--soft-ink); line-height: 1.35; margin-top: 2px; }
.drop { min-height: 170px; border-radius: 14px; border: 2px dashed #CFC9BD; background: var(--soft); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 16px; cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop svg { width: 30px; height: 30px; color: var(--accent); }
.drop strong { font-size: 16px; }
.drop span { font-size: 13px; color: var(--soft-ink); }
.drop img { max-width: 100%; max-height: 120px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.info { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--accent-tint); font-size: 13px; line-height: 1.5; color: #1F2E6B; }
.info svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); margin-top: 1px; }
.changes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.changes li { font-size: 14px; padding: 8px 12px; border-radius: 8px; background: var(--ground); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; background: var(--paper); border: 1px dashed var(--line); border-radius: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .shell { flex-direction: column; height: auto; min-height: 100dvh; }
  .side { width: auto; flex-direction: row; flex-wrap: wrap; gap: 8px; padding: 12px; border-right: 0; border-bottom: 1px solid var(--edge); }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-group p, .conn { display: none; }
  .top { padding: 0 12px; height: auto; min-height: 60px; flex-wrap: wrap; gap: 8px; padding-block: 10px; }
  .view { padding: 20px 16px 40px; overflow: visible; }
  .editor, .cols { grid-template-columns: 1fr; }
  .types { width: 100%; border-right: 0; border-bottom: 1px solid var(--line-2); }
  .dlg-body { flex-direction: column; }
  .row3 { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.status-select { height: 34px; font-size: 13px; font-weight: 600; padding: 0 8px; border-radius: 8px; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--edge); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 12px 40px rgba(28,27,25,.08); }
.login-card .brand { padding: 0; }
.login-card h1 { font-family: 'Bricolage Grotesque', sans-serif; font-size: 28px; }
.login-card .btn { height: 44px; }
.login-card .hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.login-err { margin: 0; min-height: 1em; color: var(--danger); font-size: 14px; font-weight: 600; }
