/* Fableframe UI — one system for site, studio and inbox */
:root {
  --bg: #111318;
  --surface: #1b1e25;
  --surface-2: #252932;
  --hover: #2d323c;
  --line: #2c313b;
  --ink: #e8e6e3;
  --muted: #a1a6b0;
  --accent: #f2a541;
  --accent-ink: #1a1205;
  --accent-soft: rgba(242, 165, 65, 0.14);
  --good: #45bd62;
  --info: #6aa5ff;
  --danger: #f0776c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", Helvetica, Arial, system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.topbar-in { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; max-width: 1280px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font: 700 20px var(--font); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-links { display: flex; gap: 4px; }
.top-links a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.top-links a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 0; font: 600 15px/1 var(--font); cursor: pointer; color: var(--ink); background: var(--surface-2); }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #f5b35c; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.iconbtn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { background: var(--hover); }
.chip-credit { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-credit svg { color: var(--accent); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; text-transform: uppercase; flex: none; }

/* Forms */
label { font-weight: 600; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
input, textarea, select { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: 15px var(--font); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
.msg { font-size: 14px; }
.msg:empty { display: none; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--good); }
.muted { color: var(--muted); }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-pad { padding: 16px; }
.card-title { font-size: 17px; font-weight: 700; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.received::before { background: var(--accent); }
.status.production::before { background: var(--info); }
.status.delivered { color: var(--good); }
.status.delivered::before { background: var(--good); }
.dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #e41e3f; color: #fff; font: 700 12px var(--font); }

/* Chat */
.chat { display: flex; flex-direction: column; overflow: hidden; height: calc(100vh - 56px - 32px); min-height: 420px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-head strong { display: block; font-size: 15px; }
.chat-head span { font-size: 13px; color: var(--muted); }
.mlist { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 4px; list-style: none; margin: 0; }
.mrow { display: flex; flex-direction: column; align-items: flex-start; max-width: 72%; margin-top: 6px; }
.mrow.mine { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 18px; background: var(--surface-2); font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 6px; }
.mine .bubble { background: var(--accent); color: var(--accent-ink); }
.mine .bubble a { color: var(--accent-ink); text-decoration: underline; }
.bubble.media { padding: 4px; background: transparent; }
.mine .bubble.media { background: transparent; color: var(--ink); }
.mine .bubble.media a { color: var(--accent); }
.bubble video, .bubble img { display: block; width: min(260px, 60vw); max-height: 480px; border-radius: 14px; background: #000; object-fit: cover; }
.bubble audio { width: min(280px, 60vw); }
.bubble .dl { font-size: 13px; padding: 0 6px; }
.otag { font-size: 12px; color: var(--muted); padding: 0 6px; }
.mtime { font-size: 12px; color: var(--muted); margin: 2px 8px 0; }
.daysep { align-self: center; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.mrow.flash .bubble { box-shadow: 0 0 0 3px var(--accent); }
.composer { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 40px; max-height: 140px; resize: none; border-radius: 20px; padding: 9px 14px; border: 0; }
.composer .iconbtn { background: transparent; color: var(--accent); }
.composer .iconbtn:hover { background: var(--hover); }
.send { color: var(--accent); }
.filechip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.filechip button { background: none; border: 0; color: var(--accent); cursor: pointer; font: 13px var(--font); }

/* Shell: left menu, main, right rail */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 24px; max-width: 1280px; margin: 0 auto; padding: 16px; align-items: start; }
.shell.two { grid-template-columns: 260px minmax(0, 1fr); }
.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 2px; }
.side button, .side a { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: 600 15px var(--font); text-align: left; cursor: pointer; }
.side button:hover, .side a:hover { background: var(--hover); text-decoration: none; }
.side button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.side .ico { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.side button[aria-current="page"] .ico { background: var(--accent); color: var(--accent-ink); }
.side .dot { margin-left: auto; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 8px 10px; }
.rail { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 16px; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.loading { padding: 120px 0; text-align: center; color: var(--muted); }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 72px minmax(0, 1fr) 280px; }
  .shell.two { grid-template-columns: 72px minmax(0, 1fr); }
  .side .lbl, .side .dot { display: none; }
  .side button, .side a { justify-content: center; padding: 0; }
}
@media (max-width: 800px) {
  .shell, .shell.two { grid-template-columns: 1fr; padding: 12px 12px 76px; gap: 12px; }
  .rail { position: static; }
  .side { position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; top: auto; flex-direction: row; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); padding: 6px; }
  .side hr { display: none; }
  .side button, .side a { width: auto; flex: 1; min-height: 52px; }
  .chat { height: calc(100vh - 56px - 90px); }
  .mrow { max-width: 86%; }
}

/* Legal pages */
.legal { max-width: 760px; margin: 0 auto; padding: 40px 20px 80px; }
.legal h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }
.legal .updated { color: var(--muted); margin: 8px 0 32px; }
.legal h2 { font-size: 19px; font-weight: 700; margin: 32px 0 10px; }
.legal p, .legal li { color: #d4d2cf; line-height: 1.65; }
.legal p + p { margin-top: 10px; }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li + li { margin-top: 6px; }
.legal table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.legal th, .legal td { text-align: left; vertical-align: top; padding: 10px; border-bottom: 1px solid var(--line); }
.legal th { color: var(--muted); font-weight: 600; }
.site-foot { border-top: 1px solid var(--line); padding: 24px 20px 40px; max-width: 1120px; margin: 0 auto; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.site-foot nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }
