/* Mythos Studio — design system.
   Palette and type come from the series' Project Brain ("Black Tide"): abyss blues, bronze, pearl, verdigris.
   Every page stylesheet builds on these tokens and components; don't hard-code colours elsewhere. */

:root {
  --abyss: #020509;
  --deep: #061424;
  --tide: #0b2234;
  --tide-2: #0f2b40;
  --tide-3: #143650;
  --line: rgba(159, 211, 224, .14);
  --line-2: rgba(159, 211, 224, .24);
  --shaft: #9fd3e0;
  --verdigris: #74ad9b;
  --bronze: #c9a063;
  --bronze-hi: #f0dcae;
  --bronze-dim: rgba(201, 160, 99, .16);
  --pearl: #e7ede9;
  --muted: #8ea5b0;
  --faint: #5d7480;
  --blood: #c4483f;
  --lure: #bff3ff;
  --ok: #8fe0b5;
  --warn: #e8c26a;

  --bg: var(--abyss);
  --surface: #06101b;
  --surface-2: #0a1828;
  --surface-3: #0f2135;
  --ink: var(--pearl);

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --serif: "Cormorant Garamond", "Iowan Old Style", Garamond, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .4);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t: .18s var(--ease);
  color-scheme: dark;
}

/* ---------- reset + type ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 13.5px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
h1 { font: 500 26px/1.15 var(--display); letter-spacing: .06em; }
h2 { font: 500 17px/1.25 var(--display); letter-spacing: .08em; }
h3 { font: 600 13px/1.3 var(--sans); }
a { color: var(--shaft); text-decoration: none; }
a:hover { color: var(--lure); }
img, video, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); font-size: 12px; }
::selection { background: rgba(201, 160, 99, .35); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

* { scrollbar-width: thin; scrollbar-color: rgba(159, 211, 224, .18) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(159, 211, 224, .16); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(159, 211, 224, .3); }

/* text helpers */
.eyebrow { font: 500 10.5px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.display { font-family: var(--display); letter-spacing: .08em; }
.serif { font-family: var(--serif); }
.serif-i { font-family: var(--serif); font-style: italic; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .bronze { color: var(--bronze); }
.mono { font-family: var(--mono); font-size: 12px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* layout helpers */
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stack.tight { gap: 6px; } .stack.loose { gap: 20px; }
.grow { flex: 1 1 auto; min-width: 0; } .spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }
.icon { display: inline-flex; flex: none; }

/* ---------- buttons ---------- */
.btn {
  --h: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--h); padding: 0 13px;
  border-radius: var(--r); border: 1px solid var(--line-2); background: rgba(15, 33, 53, .6); color: var(--ink);
  font: 500 13px/1 var(--sans); white-space: nowrap; cursor: pointer; text-decoration: none; user-select: none;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t), box-shadow var(--t);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: rgba(159, 211, 224, .34); color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .42; cursor: not-allowed; }
.btn.sm { --h: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { --h: 24px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.lg { --h: 42px; padding: 0 18px; font-size: 14px; }
.btn.icon-only { width: var(--h); padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: rgba(159, 211, 224, .08); border-color: transparent; color: var(--ink); }
.btn.primary {
  background: linear-gradient(180deg, var(--bronze-hi), var(--bronze)); border-color: transparent; color: #1a1206;
  font-weight: 600; box-shadow: 0 6px 20px rgba(201, 160, 99, .18), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #fbe9c3, #d6ae6e); color: #1a1206; box-shadow: 0 8px 28px rgba(201, 160, 99, .28), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn.danger { background: var(--blood); border-color: transparent; color: #fff; font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: #d4574e; color: #fff; }
.btn.danger-text { color: #ef8a82; }
.btn.danger-text:hover:not(:disabled) { color: #ffb0a9; border-color: rgba(196, 72, 63, .5); background: rgba(196, 72, 63, .1); }
.btn.on, .btn[aria-pressed="true"] { border-color: rgba(201, 160, 99, .6); color: var(--bronze-hi); background: var(--bronze-dim); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: rgba(2, 5, 9, .55); border: 1px solid var(--line); border-radius: 11px; }
.seg > button { height: 28px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; transition: background var(--t), color var(--t); }
.seg > button:hover { color: var(--ink); }
.seg > button[aria-pressed="true"], .seg > button.active { background: var(--tide-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg > button small { font: 11px var(--mono); color: var(--faint); }

/* ---------- form fields ---------- */
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 8px 11px; border-radius: var(--r); border: 1px solid var(--line-2);
  background: rgba(2, 5, 9, .6); color: var(--ink); transition: border-color var(--t), box-shadow var(--t);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgba(201, 160, 99, .7); box-shadow: 0 0 0 3px rgba(201, 160, 99, .14); }
.textarea { resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--surface-2); color: var(--ink); }
.input.search { padding-left: 34px; background: rgba(2, 5, 9, .6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238ea5b0' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") 11px 50% no-repeat; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font: 500 10.5px/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.field > .hint { font-size: 12px; color: var(--faint); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--bronze); width: 15px; height: 15px; }

/* toggle switch: <label class="switch"><input type="checkbox"><span></span> Text</label> */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch > span { width: 30px; height: 18px; border-radius: 99px; background: rgba(159, 211, 224, .16); position: relative; transition: background var(--t); flex: none; }
.switch > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--pearl); transition: transform var(--t); }
.switch input:checked + span { background: var(--bronze); }
.switch input:checked + span::after { transform: translateX(12px); background: #1a1206; }
.switch input:focus-visible + span { outline: 2px solid var(--bronze); outline-offset: 2px; }

/* ---------- chips, tags, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--line); background: rgba(2, 5, 9, .4); color: var(--muted); font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: all var(--t); }
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip.active, .chip[aria-pressed="true"] { color: var(--bronze-hi); border-color: rgba(201, 160, 99, .55); background: var(--bronze-dim); }
.chip small { font: 11px var(--mono); opacity: .7; }
.tagpill { display: inline-flex; align-items: center; max-width: 100%; padding: 2px 7px; border-radius: 6px; background: rgba(116, 173, 155, .12); color: var(--verdigris); font: 500 11.5px/1.4 var(--mono); border: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagpill:hover { background: rgba(116, 173, 155, .22); color: #a6dccb; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 99px; font: 500 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; background: rgba(2, 5, 9, .72); color: var(--pearl); border: 1px solid var(--line); white-space: nowrap; backdrop-filter: blur(6px); }
.badge.ok { color: var(--ok); border-color: rgba(143, 224, 181, .35); }
.badge.warn { color: var(--warn); border-color: rgba(232, 194, 106, .35); }
.badge.danger { color: #f08a82; border-color: rgba(196, 72, 63, .45); }
.badge.bronze { color: var(--bronze-hi); border-color: rgba(201, 160, 99, .45); }
.badge.info { color: var(--shaft); border-color: rgba(159, 211, 224, .35); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.dot.todo { background: #4b6270; } .dot.progress { background: var(--shaft); } .dot.review { background: var(--warn); } .dot.approved { background: var(--ok); }
kbd, .kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--muted); font: 11px var(--mono); background: rgba(2, 5, 9, .5); }

/* ---------- surfaces ---------- */
.card { background: linear-gradient(180deg, rgba(15, 33, 53, .55), rgba(6, 16, 27, .7)); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel { background: rgba(6, 16, 27, .82); border: 1px solid var(--line); border-radius: var(--r-xl); backdrop-filter: blur(18px) saturate(1.2); box-shadow: var(--shadow); }
.msg { padding: 9px 12px; border-radius: var(--r); font-size: 12.5px; line-height: 1.45; border: 1px solid transparent; }
.msg.error { background: rgba(196, 72, 63, .12); border-color: rgba(196, 72, 63, .3); color: #ffc2bc; }
.msg.warn { background: rgba(232, 194, 106, .1); border-color: rgba(232, 194, 106, .25); color: #f3dca4; }
.msg.info { background: rgba(159, 211, 224, .08); border-color: rgba(159, 211, 224, .2); color: #cfe9f0; }
.msg.ok { background: rgba(143, 224, 181, .08); border-color: rgba(143, 224, 181, .25); color: #c6f0d8; }
.code { margin: 0; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: rgba(2, 5, 9, .7); white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto; font: 12px/1.55 var(--mono); color: #cfdbe0; }

/* empty state: .empty > .empty-art, h3, p, .row */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 20px; color: var(--muted); }
.empty h3 { font: 500 16px var(--display); letter-spacing: .08em; color: var(--pearl); }
.empty p { max-width: 420px; }
.empty-art { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: var(--bronze); background: radial-gradient(circle, rgba(201, 160, 99, .16), transparent 70%); border: 1px solid rgba(201, 160, 99, .25); }

/* loading */
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(159, 211, 224, .18); border-top-color: var(--bronze); animation: spin .9s linear infinite; }
.skeleton { background: linear-gradient(100deg, rgba(159, 211, 224, .05) 30%, rgba(159, 211, 224, .11) 50%, rgba(159, 211, 224, .05) 70%); background-size: 300% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--r); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.rise { animation: rise .35s var(--ease) both; }

/* ---------- overlays: modal, drawer, menu, toast, tooltip ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(1, 3, 6, .72); backdrop-filter: blur(4px); animation: fade .15s ease both; }
.modal { width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: linear-gradient(180deg, #0a1a2b, #06101b); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: var(--shadow); animation: rise .25s var(--ease) both; }
.modal.sm { max-width: 440px; } .modal.md { max-width: 640px; } .modal.lg { max-width: 980px; } .modal.xl { max-width: 1280px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
.modal-head h2 { flex: 1; min-width: 0; }
.modal-body { padding: 4px 20px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }

.drawer-wrap { position: fixed; inset: 0; z-index: 55; background: rgba(1, 3, 6, .5); animation: fade .15s ease both; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); display: flex; flex-direction: column; background: linear-gradient(180deg, #091828, #050d17); border-left: 1px solid var(--line-2); box-shadow: -30px 0 60px rgba(0, 0, 0, .5); animation: slidein .28s var(--ease) both; }
.drawer.wide { width: min(880px, 100vw); }
.drawer .modal-body { flex: 1; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.menu { position: fixed; z-index: 80; min-width: 200px; max-width: 360px; max-height: min(420px, 70vh); overflow: auto; padding: 5px; background: #0b1b2c; border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); animation: rise .14s var(--ease) both; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; cursor: pointer; font-size: 13px; }
.menu-item:hover, .menu-item.active { background: rgba(159, 211, 224, .09); }
.menu-item.danger { color: #ef8a82; }
.menu-item small { margin-left: auto; color: var(--faint); font: 11px var(--mono); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu-title { padding: 8px 9px 4px; }

#toasts { position: fixed; z-index: 100; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 560px; padding: 10px 16px; border-radius: 12px; background: #0e2033; border: 1px solid var(--line-2); box-shadow: var(--shadow); color: var(--ink); animation: rise .25s var(--ease) both; pointer-events: auto; }
.toast.error { border-color: rgba(196, 72, 63, .55); color: #ffd0cb; }
.toast.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; z-index: 90; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 5px 9px; border-radius: 7px; background: #11253a; border: 1px solid var(--line-2); color: var(--pearl);
  font: 500 11.5px/1.3 var(--sans); letter-spacing: 0; text-transform: none; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-sm); animation: fade .12s ease both;
}
[data-tip-pos="below"]:hover::after { bottom: auto; top: calc(100% + 8px); }

/* ---------- media tiles ---------- */
.thumb { position: relative; overflow: hidden; border-radius: var(--r); background: #03080e; }
.thumb > img, .thumb > video { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease), opacity .3s; }
.thumb.contain > img, .thumb.contain > video { object-fit: contain; }
.thumb > img[data-loading] { opacity: 0; }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spinner { animation: spin 3s linear infinite !important; }
}

/* ---------- page frame (used by every page) ----------
   <div class="page">                       max-width content column with padding
     <header class="page-head">             title block + actions
       <div><div class="eyebrow">Section</div><h1>Title</h1><p class="sub">…</p></div>
       <div class="actions">buttons</div>
     </header>
     <div class="toolbar">…</div>           filters/search row (sticky under the top of the page)
     <section class="section"><div class="section-head"><h2>…</h2><a/button></div>…</section>
   </div>
   .page.full drops the max-width (canvas, boards). */
.page { padding: 28px 34px 64px; max-width: 1680px; margin: 0 auto; min-width: 0; }
.page.full { max-width: none; padding: 0; height: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; }
.page-head .sub { margin-top: 6px; color: var(--muted); max-width: 720px; }
.page-head .eyebrow { margin-bottom: 8px; color: var(--bronze); }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; margin-bottom: 14px; background: linear-gradient(180deg, var(--bg) 80%, rgba(2, 5, 9, 0)); }
.toolbar .input.search { width: 260px; }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 15px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--ink); }
.crumbs .icon { opacity: .5; }

@media (max-width: 900px) {
  .page { padding: 20px 16px 48px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .toolbar .input.search { width: 100%; }
  .drawer, .drawer.wide { width: 100vw; }
}
