:root {
  --ink: #100f0c;
  --ink-soft: #1a1813;
  --ink-2: #221f18;
  --ink-line: #36321f;
  --gold: #d9a53d;
  --gold-bright: #f0c869;
  --coral: #ef6a4c;
  --green: #4fc283;
  --text: #efe8d6;
  --muted: #a89f8a;
  --sans: "Manrope", "Noto Sans Malayalam", system-ui, sans-serif;
  --serif: "Fraunces", "Noto Serif Malayalam", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--ink); color: var(--text); font-family: var(--sans); line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.15; }

.shell { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 18px 0 80px; }
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--ink-line); margin-bottom: 28px; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: 0.14em; font-size: 12px; color: var(--gold); text-decoration: none; }
.brand span { color: var(--muted); letter-spacing: 0.06em; font-weight: 700; margin-left: 8px; }
.nav-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 7px; background: var(--gold); color: #17120b; font-weight: 800; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--gold-bright); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--ink-line); }
.btn.ghost:hover { border-color: var(--gold); }
.btn.danger { background: transparent; color: #ff9f88; border: 1px solid rgba(239, 106, 76, 0.4); }
.btn.danger:hover { background: rgba(239, 106, 76, 0.12); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.wa { background: #25d366; color: #05230f; }

.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); margin: 0 0 6px; }
.muted { color: var(--muted); }
.notice { padding: 12px 14px; border-radius: 8px; font-size: 14px; border: 1px solid var(--ink-line); background: var(--ink-soft); color: var(--muted); }
.notice.error { border-color: rgba(239, 106, 76, 0.45); background: rgba(239, 106, 76, 0.1); color: #ffbca9; }
.notice.ok { border-color: rgba(79, 194, 131, 0.45); background: rgba(79, 194, 131, 0.1); color: #a9ecc7; }
.notice.admin { border-color: rgba(217, 165, 61, 0.45); background: rgba(217, 165, 61, 0.08); color: var(--gold-bright); }

/* auth */
.auth { max-width: 420px; margin: 6vh auto 0; background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 12px; padding: 28px; }
.auth h1 { font-size: 28px; margin-bottom: 6px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--ink); border: 1px solid var(--ink-line); border-radius: 8px; padding: 4px; margin: 18px 0; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 6px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink-2); color: var(--text); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 700; color: #d8cfb9; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field input[type="date"], .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--ink-line); border-radius: 7px; background: var(--ink); font-size: 15px;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field textarea.tall { min-height: 300px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); margin-top: 2px; flex: none; }

/* list */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 4vw, 36px); }
.seg { display: inline-flex; border: 1px solid var(--ink-line); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink-2); color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font-size: 19px; line-height: 1.3; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: rgba(79, 194, 131, 0.12); color: var(--green); width: max-content; }
.pill.closed { background: rgba(239, 106, 76, 0.12); color: #ff9f88; }
.stat { display: flex; align-items: baseline; gap: 6px; }
.stat b { font-family: var(--serif); font-size: 28px; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 99px; background: var(--ink-line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.card .meta { font-size: 12.5px; color: var(--muted); }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.empty { text-align: center; padding: 60px 20px; border: 1px dashed var(--ink-line); border-radius: 12px; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.panel { background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel > p.muted { font-size: 13px; margin: 0 0 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sticky { position: sticky; top: 16px; }

.flist { display: grid; gap: 8px; }
.frow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--ink); border: 1px solid var(--ink-line); border-radius: 8px; padding: 10px; }
.frow.off { opacity: 0.55; }
.frow .main { display: grid; gap: 6px; min-width: 0; }
.frow .main input.label-input { min-height: 36px; padding: 6px 10px; border: 1px solid transparent; border-radius: 6px; background: var(--ink-2); font-weight: 700; font-size: 14px; width: 100%; }
.frow .main input.label-input:focus { border-color: var(--gold); }
.frow .opts { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12.5px; color: var(--muted); }
.frow .opts label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.frow .opts input[type="checkbox"] { accent-color: var(--gold); }
.frow .opts select { min-height: 28px; padding: 2px 6px; border: 1px solid var(--ink-line); border-radius: 5px; background: var(--ink-2); font-size: 12.5px; }
.frow textarea.options { min-height: 54px; padding: 6px 10px; border: 1px solid var(--ink-line); border-radius: 6px; background: var(--ink-2); font-size: 13px; width: 100%; resize: vertical; }
.frow .tools { display: flex; flex-direction: column; gap: 4px; }
.icon-btn { width: 30px; height: 28px; display: grid; place-items: center; border: 1px solid var(--ink-line); border-radius: 6px; background: var(--ink-2); cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--gold); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--ink-line); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--gold); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.tag { font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--ink-line); border-radius: 4px; padding: 1px 5px; }

.savebar { display: flex; gap: 10px; flex-wrap: wrap; }
.savebar .btn { flex: 1; }

/* signatures */
.sig-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.sig-head h1 { font-size: clamp(22px, 3.4vw, 30px); max-width: 30ch; }
.sig-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--ink-line); border-radius: 10px; background: var(--ink-soft); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ink-line); vertical-align: middle; }
th { font-size: 12px; letter-spacing: 0; color: var(--muted); font-weight: 800; background: var(--ink-2); position: sticky; top: 0; white-space: nowrap; }
td { max-width: 260px; overflow-wrap: anywhere; }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
td.sig img { height: 44px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 4px; padding: 2px; display: block; }
tr:last-child td { border-bottom: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5, 5, 4, 0.72); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { width: min(100%, 460px); max-height: calc(100vh - 32px); overflow: auto; background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 12px; padding: 22px; }
.modal-card h2 { font-size: 22px; margin-bottom: 4px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 10px; padding: 16px; margin: 16px 0; }
.qr canvas, .qr img { width: 220px !important; height: 220px !important; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; min-width: 0; min-height: 42px; padding: 0 10px; border: 1px solid var(--ink-line); border-radius: 7px; background: var(--ink); font-size: 13px; }
.stack { display: grid; gap: 10px; margin-top: 12px; }
.progress-text { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
  .auth { padding: 20px; }
}

/* change log */
.modal-card.wide { width: min(100%, 620px); }
.changes { display: grid; gap: 10px; margin-top: 12px; }
.change { border: 1px solid var(--ink-line); border-radius: 8px; padding: 10px 12px; background: var(--ink); }
.change .clabel { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.change .kind { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.change .kind.content { background: rgba(239, 106, 76, 0.15); color: #ffb39f; }
.change .kind.setting { background: rgba(217, 165, 61, 0.14); color: var(--gold-bright); }
.inline-change { font-size: 14px; overflow-wrap: anywhere; }
.inline-change .old { color: #ff9f88; text-decoration: line-through; }
.inline-change .arrow { color: var(--muted); margin: 0 6px; }
.inline-change .new { color: #8fe0b2; }
.diff { font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
.diff .line { padding: 2px 8px; border-radius: 4px; }
.diff .line.del { background: rgba(239, 106, 76, 0.1); }
.diff .line.ins { background: rgba(79, 194, 131, 0.1); }
.diff .line.same { color: var(--muted); }
.diff .line::before { display: inline-block; width: 1.2em; color: var(--muted); }
.diff .line.del::before { content: "−"; color: #ff9f88; }
.diff .line.ins::before { content: "+"; color: #8fe0b2; }
.diff .line.same::before { content: " "; }
.diff del { background: rgba(239, 106, 76, 0.35); color: #ffd3c8; text-decoration: line-through; border-radius: 3px; }
.diff ins { background: rgba(79, 194, 131, 0.3); color: #d6f7e5; text-decoration: none; border-radius: 3px; }
.diff .gap { color: var(--muted); padding: 2px 8px; font-style: italic; }

.versions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.vchip { border: 1px solid var(--ink-line); background: var(--ink-soft); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.vchip b { color: var(--gold-bright); font-family: var(--serif); font-size: 18px; margin-right: 4px; }
.vchip.current { border-color: var(--gold); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.entry { background: var(--ink-soft); border: 1px solid var(--ink-line); border-radius: 10px; padding: 16px 18px; }
.entry-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.entry-head .seq { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; font-weight: 700; }
.entry-head .what { font-weight: 800; font-size: 15px; }
.entry-head time { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--ink-line); color: var(--muted); }
.badge.v { color: var(--gold-bright); border-color: rgba(217, 165, 61, 0.5); }
.badge.bump { color: #ffb39f; border-color: rgba(239, 106, 76, 0.5); }
.entry .by { font-size: 13.5px; color: #d8cfb9; margin-top: 8px; }
.entry .remark { margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--gold); background: var(--ink); border-radius: 0 6px 6px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .hash { margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.entry details { margin-top: 10px; }
.entry summary { cursor: pointer; color: var(--gold); font-weight: 700; font-size: 13px; }
.entry .snapshot { margin-top: 8px; padding: 12px; background: var(--ink); border-radius: 8px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
td.ver { white-space: nowrap; font-weight: 700; color: var(--gold-bright); width: 1%; }
