:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #191d28;
  --line: #292f3e;
  --muted: #929aab;
  --text: #f5f7fb;
  --accent: #a46cff;
  --accent-2: #67e8f9;
  --danger: #ff6b81;
  --success: #62e6a7;
  --warning: #ffd166;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: radial-gradient(circle at 18% -10%, rgba(164,108,255,.17), transparent 35%), var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.skip-link { position:fixed; z-index:1000; top:10px; left:10px; padding:10px 14px; border-radius:9px; background:#fff; color:#090b10; transform:translateY(-180%); }
.skip-link:focus { transform:none; }
:where(a, button, input, textarea, select):focus-visible { outline:3px solid var(--accent-2); outline-offset:3px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(460px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 26px; background: rgba(18,21,29,.92); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brand-mark { display: flex; align-items: center; gap: 12px; font-weight: 820; letter-spacing: -.035em; }
.brand-glyph { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0b0d12; font-size: 25px; box-shadow: 0 12px 30px rgba(164,108,255,.25); }
.brand-copy strong { display:block; font-size: 20px; }
.brand-copy small { color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.login-card h1 { margin: 34px 0 10px; font-size: clamp(30px, 6vw, 44px); letter-spacing: -.055em; line-height: 1; }
.login-card p { color: var(--muted); line-height: 1.6; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 18px; border-right: 1px solid var(--line); background: rgba(11,13,18,.86); backdrop-filter: blur(20px); overflow-y: auto; }
.sidebar .brand-mark { padding: 0 8px 23px; }
.nav-group { margin-top: 22px; }
.nav-label { padding: 0 10px 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: #c8ceda; text-align: left; }
.nav-button:hover { background: var(--panel); color: white; }
.nav-button.active { background: linear-gradient(135deg, rgba(164,108,255,.18), rgba(103,232,249,.08)); border-color: rgba(164,108,255,.38); color: white; }
.nav-icon { width: 24px; height: 24px; display:grid; place-items:center; border-radius: 8px; background: rgba(255,255,255,.05); font-size: 12px; }
.nav-button small { margin-left:auto; color: var(--muted); }
.sidebar-footer { margin-top: 24px; padding: 16px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }

.workspace { min-width: 0; }
.topbar { height: 74px; display:flex; align-items:center; justify-content:space-between; gap: 18px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(11,13,18,.72); backdrop-filter: blur(18px); position: sticky; top:0; z-index:10; }
.topbar-title strong { display:block; font-size:15px; }
.topbar-title span { color: var(--muted); font-size:12px; }
.topbar-actions { display:flex; gap:10px; align-items:center; }
.content { padding: 32px; max-width: 1440px; margin: 0 auto; }
.page-head { display:flex; gap:20px; justify-content:space-between; align-items:flex-end; margin-bottom: 26px; }
.page-head h1 { margin:0; font-size: clamp(30px,4vw,48px); letter-spacing:-.055em; line-height:1; }
.page-head p { margin:10px 0 0; color:var(--muted); max-width:720px; line-height:1.6; }

.button { min-height: 42px; display:inline-flex; align-items:center; justify-content:center; gap:8px; padding: 0 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); color: var(--text); font-weight: 750; }
.button:hover { transform: translateY(-1px); border-color:#414a60; }
.button.primary { border-color: transparent; color:#0b0d12; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.button.preview { border-color: rgba(103,232,249,.32); color:#dffcff; background:rgba(103,232,249,.08); }
.button.ghost { background: transparent; }
.button.danger { color:#ffd9df; background: rgba(255,107,129,.09); border-color: rgba(255,107,129,.28); }
.button.small { min-height:34px; padding:0 11px; font-size:13px; }
.button:disabled { opacity:.5; cursor:not-allowed; transform:none; }

.card { border: 1px solid var(--line); border-radius: 18px; background: rgba(18,21,29,.86); box-shadow: 0 16px 60px rgba(0,0,0,.13); overflow: hidden; }
.card-head { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:18px 20px; border-bottom:1px solid var(--line); }
.card-head h2 { margin:0; font-size:17px; }
.card-body { padding:20px; }
.stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:22px; }
.stat { padding:18px; border:1px solid var(--line); border-radius:15px; background:linear-gradient(145deg, rgba(255,255,255,.025), transparent); }
.stat strong { display:block; font-size:28px; letter-spacing:-.04em; }
.stat span { color:var(--muted); font-size:12px; }

.entry-list { display:grid; gap:10px; }
.entry-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:16px; align-items:center; width:100%; padding:15px 16px; border:1px solid var(--line); border-radius:13px; background:var(--panel); color:inherit; text-align:left; }
.entry-row:hover { border-color:#46506a; background:#151925; }
.entry-title { font-weight:780; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.entry-meta { margin-top:5px; color:var(--muted); font-size:12px; display:flex; gap:10px; flex-wrap:wrap; }
.badge { display:inline-flex; align-items:center; min-height:24px; padding:0 9px; border-radius:999px; font-size:11px; font-weight:850; letter-spacing:.03em; }
.badge.published { background:rgba(98,230,167,.12); color:var(--success); }
.badge.draft { background:rgba(255,209,102,.12); color:var(--warning); }
.badge.unhealthy { background:rgba(255,107,129,.12); color:var(--danger); }

.editor-grid { display:grid; grid-template-columns:minmax(0,1fr) 310px; gap:22px; align-items:start; }
.form-card { padding:22px; border:1px solid var(--line); border-radius:18px; background:rgba(18,21,29,.86); }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.field { display:grid; gap:8px; align-content:start; }
.field.full { grid-column:1/-1; }
.field label { font-size:13px; font-weight:780; }
.field-help { color:var(--muted); font-size:12px; line-height:1.45; }
.input, .textarea, .select { width:100%; border:1px solid var(--line); border-radius:11px; background:#0f1219; color:var(--text); outline:none; }
.input, .select { min-height:44px; padding:0 12px; }
.textarea { min-height:120px; padding:12px; resize:vertical; line-height:1.55; }
.textarea.rich { min-height:240px; }
.input:focus, .textarea:focus, .select:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(164,108,255,.12); }
.switch { display:flex; align-items:center; gap:10px; min-height:44px; }
.switch input { width:19px; height:19px; accent-color:var(--accent); }
.editor-aside { position:sticky; top:96px; display:grid; gap:14px; }
.action-stack { display:grid; gap:10px; }
.status-copy { color:var(--muted); font-size:12px; line-height:1.55; }

.media-field { display:grid; gap:12px; }
.media-preview { position:relative; border:1px dashed #3a4255; border-radius:14px; min-height:130px; display:grid; place-items:center; overflow:hidden; background:#0d1016; }
.media-preview img { width:100%; height:180px; object-fit:cover; display:block; }
.media-empty { color:var(--muted); font-size:13px; padding:20px; text-align:center; }
.gallery { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:10px; }
.gallery-item { position:relative; border:1px solid var(--line); border-radius:12px; overflow:hidden; background:#0d1016; }
.gallery-item img { display:block; width:100%; aspect-ratio:1; object-fit:cover; }
.gallery-actions { display:flex; gap:5px; padding:7px; }
.gallery-actions button { flex:1; min-height:28px; border:1px solid var(--line); border-radius:7px; background:var(--panel-2); color:var(--text); }
.file-input { display:none; }

.revision-list { display:grid; gap:12px; }
.revision { padding:18px; border:1px solid var(--line); border-radius:15px; background:var(--panel); }
.revision-top { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; }
.revision h3 { margin:0 0 6px; font-size:15px; }
.revision p { margin:0; color:var(--muted); font-size:12px; line-height:1.55; }
.revision-details { margin-top:13px; padding-top:13px; border-top:1px solid var(--line); display:flex; gap:16px; flex-wrap:wrap; color:var(--muted); font-size:12px; }
.empty-state { padding:54px 24px; text-align:center; color:var(--muted); }
.empty-state strong { display:block; color:var(--text); font-size:18px; margin-bottom:8px; }

.eyebrow { display:block; margin-bottom:9px; color:var(--accent-2); font-size:11px; font-weight:850; letter-spacing:.14em; text-transform:uppercase; }
.appearance-page-head { align-items:center; }
.template-overview { display:grid; grid-template-columns:220px minmax(0,1fr); min-height:220px; margin-bottom:22px; border:1px solid var(--line); border-radius:22px; overflow:hidden; background:linear-gradient(145deg,rgba(25,29,40,.96),rgba(13,16,23,.96)); box-shadow:0 24px 90px rgba(0,0,0,.18); }
.template-art { position:relative; display:grid; place-items:center; overflow:hidden; background:radial-gradient(circle at 25% 15%,rgba(103,232,249,.28),transparent 35%),radial-gradient(circle at 80% 90%,rgba(164,108,255,.42),transparent 50%),#111520; }
.template-art::before,.template-art::after { content:""; position:absolute; width:240px; height:1px; background:linear-gradient(90deg,transparent,rgba(255,255,255,.32),transparent); transform:rotate(-35deg); }
.template-art::before { top:35%; left:-20%; }
.template-art::after { bottom:25%; right:-25%; }
.template-art > span { position:relative; z-index:1; display:grid; place-items:center; width:86px; height:86px; border:1px solid rgba(255,255,255,.2); border-radius:28px; background:linear-gradient(145deg,rgba(255,255,255,.16),rgba(255,255,255,.03)); box-shadow:0 24px 60px rgba(0,0,0,.25); color:white; font-size:55px; }
.template-art small { position:absolute; bottom:16px; left:16px; color:rgba(255,255,255,.58); font-size:9px; font-weight:900; letter-spacing:.18em; }
.template-copy { align-self:center; padding:30px; }
.template-title { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; }
.template-title h2 { margin:0; font-size:clamp(27px,4vw,42px); letter-spacing:-.055em; }
.template-copy > p { max-width:760px; margin:16px 0 20px; color:var(--muted); line-height:1.65; }
.template-meta { display:flex; flex-wrap:wrap; align-items:center; gap:8px; color:var(--muted); font-size:12px; }
.template-meta > span:not(.capability) { padding-right:9px; border-right:1px solid var(--line); }
.capability { padding:5px 9px; border:1px solid rgba(164,108,255,.28); border-radius:999px; background:rgba(164,108,255,.08); color:#d9c7ff; font-weight:750; }

.appearance-studio { display:grid; grid-template-columns:minmax(380px,470px) minmax(0,1fr); gap:22px; align-items:start; }
.appearance-controls { display:grid; gap:14px; min-width:0; }
.appearance-group { border:1px solid var(--line); border-radius:18px; background:rgba(18,21,29,.86); overflow:hidden; }
.appearance-group-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:18px 19px; border-bottom:1px solid var(--line); }
.appearance-group-head h3 { margin:0; font-size:15px; }
.appearance-group-head p { margin:5px 0 0; color:var(--muted); font-size:12px; line-height:1.5; }
.text-button { padding:3px 0; border:0; background:transparent; color:var(--accent-2); font-size:11px; font-weight:800; white-space:nowrap; }
.text-button:hover { color:white; }
.appearance-settings { display:grid; }
.appearance-setting { display:grid; grid-template-columns:minmax(0,1fr) minmax(145px,45%); gap:16px; align-items:center; padding:15px 18px; border-bottom:1px solid rgba(41,47,62,.68); }
.appearance-setting:last-child { border-bottom:0; }
.appearance-setting.overridden { box-shadow:inset 2px 0 var(--accent); }
.appearance-setting-head { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; min-width:0; }
.appearance-setting-head label { display:block; font-size:12px; font-weight:780; }
.appearance-setting-head p { margin:4px 0 0; color:var(--muted); font-size:10px; line-height:1.4; }
.appearance-input { min-width:0; }
.color-control { min-height:42px; display:flex; align-items:center; gap:10px; padding:5px 9px 5px 6px; border:1px solid var(--line); border-radius:11px; background:#0f1219; }
.color-input { width:34px; height:30px; padding:0; border:0; border-radius:8px; background:transparent; overflow:hidden; }
.color-input::-webkit-color-swatch-wrapper { padding:0; }
.color-input::-webkit-color-swatch { border:0; border-radius:7px; }
.color-control code { color:var(--muted); font-size:11px; }
.range-control { display:grid; grid-template-columns:minmax(70px,1fr) 70px; gap:9px; align-items:center; }
.range-control input[type="range"] { width:100%; accent-color:var(--accent); }
.range-number { min-width:0; padding-inline:8px; }
.appearance-switch { display:flex; align-items:center; gap:9px; color:var(--muted); font-size:11px; cursor:pointer; }
.appearance-switch input { position:absolute; opacity:0; pointer-events:none; }
.appearance-switch i { position:relative; width:38px; height:22px; border:1px solid var(--line); border-radius:999px; background:#0d1016; transition:.18s ease; }
.appearance-switch i::after { content:""; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:#777f90; transition:.18s ease; }
.appearance-switch input:checked + i { border-color:rgba(164,108,255,.6); background:rgba(164,108,255,.24); }
.appearance-switch input:checked + i::after { transform:translateX(16px); background:var(--accent); }
.variation-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; padding:14px; }
.variation { min-width:0; display:grid; gap:7px; padding:10px; border:1px solid var(--line); border-radius:12px; background:#0f1219; color:var(--text); text-align:left; }
.variation:hover { border-color:#4a546c; }
.variation.selected { border-color:var(--accent); box-shadow:0 0 0 2px rgba(164,108,255,.12); }
.variation strong { overflow:hidden; text-overflow:ellipsis; font-size:11px; }
.variation small { display:-webkit-box; overflow:hidden; -webkit-box-orient:vertical; -webkit-line-clamp:2; min-height:28px; color:var(--muted); font-size:9px; line-height:1.45; }
.variation-palette { display:flex; height:28px; overflow:hidden; border-radius:8px; }
.variation-palette i { flex:1; }
.control-divider { display:flex; align-items:center; gap:12px; padding:6px 4px 0; color:var(--muted); font-size:10px; font-weight:850; letter-spacing:.13em; text-transform:uppercase; }
.control-divider i { flex:1; height:1px; background:var(--line); }
.appearance-actions { position:sticky; bottom:12px; z-index:4; display:grid; grid-template-columns:minmax(0,1fr) repeat(3,auto); gap:8px; align-items:center; padding:12px; border:1px solid #384056; border-radius:16px; background:rgba(17,20,28,.94); box-shadow:0 20px 70px rgba(0,0,0,.38); backdrop-filter:blur(18px); }
.appearance-actions > div strong,.appearance-actions > div span { display:block; }
.appearance-actions > div strong { font-size:11px; }
.appearance-actions > div span { margin-top:3px; color:var(--muted); font-size:9px; }
.appearance-actions .button { min-height:36px; padding-inline:10px; font-size:10px; }

.preview-panel { position:sticky; top:96px; min-width:0; overflow:hidden; border:1px solid var(--line); border-radius:20px; background:#090b0f; box-shadow:0 24px 90px rgba(0,0,0,.22); }
.preview-toolbar { min-height:54px; display:flex; align-items:center; justify-content:space-between; gap:16px; padding:8px 12px; border-bottom:1px solid var(--line); background:#12151d; }
.device-switcher { display:flex; gap:3px; padding:3px; border:1px solid var(--line); border-radius:10px; background:#0c0f15; }
.device-switcher button { min-height:28px; padding:0 9px; border:0; border-radius:7px; background:transparent; color:var(--muted); font-size:10px; font-weight:750; }
.device-switcher button.active { background:var(--panel-2); color:white; box-shadow:0 3px 12px rgba(0,0,0,.2); }
.preview-toolbar-actions { display:flex; align-items:center; gap:12px; }
.preview-state { display:flex; align-items:center; gap:7px; color:var(--muted); font-size:10px; white-space:nowrap; }
.status-dot { width:7px; height:7px; border-radius:50%; background:#596173; box-shadow:0 0 0 3px rgba(89,97,115,.1); }
.status-dot.success { background:var(--success); box-shadow:0 0 0 3px rgba(98,230,167,.11); }
.status-dot.warning { background:var(--warning); box-shadow:0 0 0 3px rgba(255,209,102,.11); }
.preview-stage { min-height:calc(100vh - 230px); display:flex; justify-content:center; align-items:flex-start; padding:18px; overflow:auto; background-color:#090b0f; background-image:linear-gradient(rgba(255,255,255,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.025) 1px,transparent 1px); background-size:22px 22px; }
.preview-device { width:min(100%,var(--preview-width)); height:calc(100vh - 270px); min-height:560px; overflow:hidden; border:1px solid #343b4e; border-radius:13px; background:white; box-shadow:0 24px 70px rgba(0,0,0,.42); transition:width .25s ease; }
.preview-device.tablet { max-width:820px; }
.preview-device.mobile { max-width:390px; border-radius:24px; }
.preview-device iframe { display:block; width:100%; height:100%; border:0; background:white; }
.preview-placeholder { height:100%; display:grid; place-content:center; justify-items:center; padding:34px; background:radial-gradient(circle at 50% 20%,rgba(164,108,255,.18),transparent 36%),#0f1219; color:var(--text); text-align:center; }
.preview-placeholder > span { display:grid; place-items:center; width:60px; height:60px; margin-bottom:18px; border:1px solid rgba(164,108,255,.36); border-radius:20px; background:rgba(164,108,255,.11); color:var(--accent); font-size:30px; }
.preview-placeholder strong { font-size:17px; }
.preview-placeholder p { max-width:390px; margin:8px 0 20px; color:var(--muted); font-size:12px; line-height:1.6; }

.toast-region { position:fixed; right:20px; bottom:20px; z-index:100; display:grid; gap:10px; width:min(390px,calc(100vw - 40px)); }
.toast { padding:14px 16px; border:1px solid var(--line); border-radius:13px; background:#171b25; box-shadow:var(--shadow); line-height:1.45; }
.toast.error { border-color:rgba(255,107,129,.45); }
.toast.success { border-color:rgba(98,230,167,.4); }
.busy-overlay { position:fixed; inset:auto 22px 22px auto; z-index:200; display:flex; align-items:center; gap:12px; min-width:260px; padding:14px 16px; border:1px solid #3b4358; border-radius:14px; background:rgba(17,20,28,.96); box-shadow:var(--shadow); opacity:0; transform:translateY(12px); pointer-events:none; transition:.18s ease; }
.busy-overlay[aria-hidden="false"] { opacity:1; transform:none; }
.busy-overlay strong,.busy-overlay span { display:block; }
.busy-overlay strong { font-size:12px; }
.busy-overlay div span { margin-top:3px; color:var(--muted); font-size:10px; }
.busy-spinner { width:24px; height:24px; border:2px solid rgba(255,255,255,.13); border-top-color:var(--accent-2); border-radius:50%; animation:busy-spin .8s linear infinite; }
.loading .shell,.loading .login-shell { pointer-events:none; }
@keyframes busy-spin { to { transform:rotate(360deg); } }

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

@media (max-width: 980px) {
  .shell { grid-template-columns: 82px minmax(0,1fr); }
  .sidebar { padding-inline:12px; }
  .sidebar .brand-copy, .nav-button span:not(.nav-icon), .nav-button small, .nav-label, .sidebar-footer { display:none; }
  .sidebar .brand-mark { justify-content:center; padding-inline:0; }
  .nav-button { justify-content:center; padding-inline:8px; }
  .editor-grid { grid-template-columns:1fr; }
  .editor-aside { position:static; }
  .appearance-studio { grid-template-columns:1fr; }
  .preview-panel { position:static; }
}
@media (max-width: 680px) {
  .shell { display:block; }
  .sidebar { position:static; width:100%; height:auto; display:flex; align-items:center; gap:8px; overflow:auto; border-right:0; border-bottom:1px solid var(--line); }
  .sidebar .brand-mark { padding:0 8px 0 0; }
  .nav-group { margin:0; display:flex; }
  .nav-button { width:auto; }
  .workspace { width:100%; }
  .topbar { padding:0 16px; }
  .content { padding:22px 16px; }
  .page-head { align-items:flex-start; flex-direction:column; }
  .form-grid { grid-template-columns:1fr; }
  .stats { grid-template-columns:1fr; }
  .topbar-title span { display:none; }
  .template-overview { grid-template-columns:1fr; }
  .template-art { min-height:150px; }
  .appearance-setting { grid-template-columns:1fr; }
  .variation-grid { grid-template-columns:1fr; }
  .appearance-actions { position:static; grid-template-columns:1fr; }
  .appearance-actions > div { padding:4px; }
  .preview-toolbar { align-items:flex-start; flex-direction:column; }
  .preview-toolbar-actions { width:100%; justify-content:space-between; }
  .preview-stage { min-height:660px; padding:10px; }
  .preview-device { height:640px; min-height:640px; }
  .busy-overlay { right:12px; bottom:12px; left:12px; min-width:0; }
}
