/* Obscura CMS — dark by design, matching the gallery and the Obscura UI kit tokens */
:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0b0b0b;
  --surface-2: #141414;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.24);
  --ink: #f2f2f2;
  --ink-muted: #9a9a9a;
  --glass: rgba(120, 120, 120, 0.32);
  --glass-hover: rgba(170, 170, 170, 0.42);
  --solid: #ffffff;
  --on-solid: #000000;
  --chip: rgba(255, 255, 255, 0.1);
  --danger: #ff7a6b;
  --field: rgba(255, 255, 255, 0.04);
  --radius-item: 10px;
  --radius-menu: 18px;
  --radius-pill: 999px;
  --ease-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em; text-transform: uppercase; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: var(--radius-pill); padding: 10px 16px;
  font-size: 13.5px; font-weight: 500; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap;
  transition: background-color 0.25s, transform 0.4s var(--ease-expo), opacity 0.2s; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-solid { background: var(--solid); color: var(--on-solid); }
.btn-solid:not(:disabled):hover { transform: scale(1.04); }
.btn-glass { background: var(--glass); color: var(--ink); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.btn-glass:not(:disabled):hover { background: var(--glass-hover); }
.btn-danger { background: none; color: var(--danger); padding-left: 4px; padding-right: 4px; }
.btn-danger:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- top bar ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 14px 20px; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-word { font-weight: 800; font-size: 18px; letter-spacing: -0.03em; }
.brand-word sup { font-size: 8px; font-weight: 600; }
.chip { padding: 4px 8px; border-radius: var(--radius-pill); background: var(--chip); color: var(--ink-muted); }
.stats { margin: 0; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); font-weight: 500; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); min-height: calc(100vh - 63px); }
.list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.editor { min-width: 0; }

/* ---------- list tools ---------- */
.list-tools { display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 10px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; border-radius: var(--radius-pill);
  background: var(--field); border: 1px solid var(--line); color: var(--ink-muted); }
.search:focus-within { border-color: var(--line-strong); color: var(--ink); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); }
.search input::placeholder { color: var(--ink-muted); }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--radius-pill); background: var(--glass); align-self: flex-start; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; color: var(--ink); transition: background-color 0.25s, color 0.25s; }
.seg button[aria-pressed="true"] { background: var(--solid); color: var(--on-solid); }
.seg .count { font-family: var(--mono); font-size: 10px; opacity: 0.6; margin-left: 2px; font-variant-numeric: tabular-nums; }
.seg-wide { align-self: stretch; }

.list-note { margin: 0; padding: 0 16px 8px; color: var(--ink-muted); }

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0 8px 24px; overflow-y: auto; flex: 1; }
.row { display: grid; grid-template-columns: 16px 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius-item); cursor: pointer; border: 1px solid transparent; position: relative; }
.row:hover { background: rgba(255, 255, 255, 0.04); }
.row.is-selected { background: rgba(255, 255, 255, 0.08); border-color: var(--line); }
.row.is-dragging { opacity: 0.4; }
.row.drop-before::before, .row.drop-after::after { content: ""; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--solid); border-radius: 1px; }
.row.drop-before::before { top: -1px; }
.row.drop-after::after { bottom: -1px; }
.handle { color: var(--ink-muted); cursor: grab; display: grid; place-items: center; opacity: 0.6; }
.row:hover .handle { opacity: 1; }
.list.is-locked .handle { visibility: hidden; }
.swatch { width: 28px; height: 28px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.row-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-client { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title { color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-year { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.list-empty { padding: 24px 16px; color: var(--ink-muted); margin: 0; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: var(--radius-pill); white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1px solid currentColor; }
.status-pill.is-published { background: var(--solid); color: var(--on-solid); }
.status-pill.is-published::before { background: currentColor; }
.status-pill.is-draft { background: var(--chip); color: var(--ink-muted); }

/* ---------- editor ---------- */
.editor-empty { max-width: 44ch; margin: 18vh auto 0; padding: 0 24px; text-align: center; color: var(--ink-muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.editor-empty p { margin: 0; }
.eyebrow { margin: 0 0 6px; color: var(--ink-muted); }

.form { display: flex; flex-direction: column; min-height: 100%; }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 28px 8px; }
.ed-title { margin: 0; font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; text-wrap: balance; overflow-wrap: anywhere; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 32px; padding: 16px 28px 28px; align-items: start; }
.fields { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; border: 0; min-width: 0; }
.label { color: var(--ink-muted); padding: 0; }
.aside { text-transform: none; letter-spacing: 0; opacity: 0.7; margin-left: 4px; }
.field input:not([type="color"]), .field textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-item); border: 1px solid var(--line); background: var(--field); color: var(--ink);
  transition: border-color 0.2s; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06); }
.field textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger); }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: none; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-muted); transition: background-color 0.2s, color 0.2s, border-color 0.2s; }
.tag:hover { color: var(--ink); border-color: var(--line-strong); }
.tag[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--on-solid); }
.tag:disabled { opacity: 0.35; cursor: default; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sw { width: 30px; height: 30px; border-radius: 8px; border: 0; padding: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); position: relative; }
.sw[aria-pressed="true"]::after { content: ""; position: absolute; inset: -4px; border-radius: 11px; border: 2px solid var(--solid); }
.sw-custom { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; color: var(--ink-muted); }
.sw-custom input { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.sw-custom input::-webkit-color-swatch-wrapper { padding: 2px; }
.sw-custom input::-webkit-color-swatch { border: 0; border-radius: 5px; }

.form-error { margin: 0; min-height: 1.4em; color: var(--danger); font-size: 13px; }

/* ---------- previews ---------- */
.preview { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 8px; }
.tile { container-type: inline-size; position: relative; aspect-ratio: 4 / 3.8; width: 100%; overflow: hidden; background: #000;
  box-shadow: inset 0 0 0 1px var(--line); margin-bottom: 10px; }
.tile-client { position: absolute; left: 3.9cqw; top: 3.9cqw; font-weight: 700; font-size: 3.9cqw; line-height: 1; color: #ececec; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-title { position: absolute; right: 3.9cqw; top: 4.9cqw; font: 500 2.25cqw/1 var(--mono); letter-spacing: 0.2cqw; text-transform: uppercase; color: #d2d2d2; max-width: 50%; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-media { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); overflow: hidden; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.4s; }
.tile-media img.is-loaded { opacity: 1; }
.tile-foot { position: absolute; left: 3.9cqw; right: 3.9cqw; bottom: 3.9cqw; display: flex; align-items: center; gap: 0.9cqw; }
.tile-tags { display: flex; gap: 0.9cqw; min-width: 0; }
.tile-tags span { display: inline-flex; align-items: center; height: 4.1cqw; padding: 0 1.46cqw; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: #b4b4b4;
  font: 500 1.95cqw/1 var(--mono); letter-spacing: 0.15cqw; text-transform: uppercase; white-space: nowrap; }
.tile-year { margin-left: auto; font: 500 1.95cqw/1 var(--mono); color: #9a9a9a; }

.page-pv { container-type: inline-size; display: flex; flex-direction: column; gap: 14px; padding: 22px 14px 14px; border-radius: 4px; color: #0b0b0b; min-height: 150px; justify-content: space-between; transition: background-color 0.3s; }
.page-pv-title { font-weight: 900; text-transform: uppercase; text-align: center; font-size: clamp(22px, 11cqw, 44px); line-height: 0.86; letter-spacing: -0.055em; text-wrap: balance; overflow-wrap: anywhere; }
.page-pv-meta { display: flex; align-items: center; gap: 6px; border-top: 1px solid rgba(0, 0, 0, 0.25); padding-top: 8px; font-size: 9px; flex-wrap: wrap; }
.page-pv-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.page-pv-tags span { padding: 4px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.1); }
#pv-page-year { margin-left: auto; }

/* ---------- footer ---------- */
.editor-foot { position: sticky; bottom: env(safe-area-inset-bottom, 0px); margin-top: auto; display: flex; align-items: center; gap: 8px;
  padding: 14px 28px; background: rgba(0, 0, 0, 0.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.dirty { color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.dirty::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--solid); }

/* ---------- toast + modal ---------- */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 10px); z-index: 30; padding: 10px 14px; border-radius: var(--radius-pill);
  background: rgba(30, 30, 30, 0.92); border: 1px solid var(--line); color: var(--ink); opacity: 0; pointer-events: none;
  transition: opacity 0.35s var(--ease-expo), transform 0.35s var(--ease-expo); }
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { color: var(--danger); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card { width: min(420px, 100%); padding: 22px; border-radius: var(--radius-menu); background: #161616; border: 1px solid var(--line); }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.modal-card p { margin: 0 0 20px; color: var(--ink-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-ok-danger { background: var(--danger); color: #000; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; border-bottom: 1px solid var(--line); max-height: 46vh; }
  .editor-grid { grid-template-columns: 1fr; }
  .preview { position: static; }
  .stats { display: none; }
}
@media (max-width: 560px) {
  .top { padding: 12px 16px; gap: 12px; }
  .brand-word { display: none; }
  .top-actions .btn-glass { display: none; }
  .editor-head, .editor-grid { padding-left: 16px; padding-right: 16px; }
  .editor-foot { padding: 12px 16px; flex-wrap: wrap; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- section tabs ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--radius-pill); background: var(--glass); }
.tabs a { padding: 7px 13px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none; transition: background-color 0.25s, color 0.25s; }
.tabs a:hover { background: rgba(255, 255, 255, 0.08); }
.tabs a[aria-current="page"] { background: var(--solid); color: var(--on-solid); }

/* ---------- lens page ---------- */
.lens-page { max-width: 760px; margin: 0 auto; padding: 32px 24px 40px; display: flex; flex-direction: column; gap: 20px; }
.lens-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.lens-intro { margin: 10px 0 0; max-width: 60ch; color: var(--ink-muted); }
.lens-list { display: flex; flex-direction: column; padding: 4px 18px; border: 1px solid var(--line); border-radius: var(--radius-menu); background: var(--surface); }
.lens-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 90px; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.lens-row:last-child { border-bottom: 0; }
.lens-name { display: flex; flex-direction: column; gap: 4px; }
.lens-name b { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.lens-name span { color: var(--ink-muted); text-transform: none; }
.lens-row input[type="range"] { width: 100%; accent-color: var(--solid); }
.lens-value { text-align: right; font-variant-numeric: tabular-nums; }
.lens-value.is-changed::before { content: "\2022\00a0"; }
.lens-import { border: 1px solid var(--line); border-radius: var(--radius-menu); padding: 14px 18px; }
.lens-import summary { cursor: pointer; color: var(--ink-muted); }
.lens-import textarea { width: 100%; margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-item); border: 1px solid var(--line); background: var(--field); color: var(--ink); font: 400 12px/1.5 var(--mono); resize: vertical; }
.lens-import-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.lens-import-msg { color: var(--ink-muted); text-transform: none; }
.lens-foot { position: sticky; bottom: 0; }
@media (max-width: 640px) {
  .lens-row { grid-template-columns: 1fr 80px; }
  .lens-row input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
}
