/* forseth.work design system.
   Every color, font and radius is a token; themes.css sets the tokens per [data-theme]
   (light, dark, midnight, royal). Components below only use tokens. */

/* --- Tokens (dark is the fallback) ------------------------------------------ */
:root {
  --bg: #111318;
  --surface: #181b21;          /* cards, tiles */
  --surface-strong: #1b1e25;   /* pop-ups, menus */
  --surface-sunk: #14161b;     /* inset areas: lists, logs, inputs */
  --surface-hover: #20242c;
  --border: #2a2e37;
  --border-soft: #22262e;
  --text: #e7e9ee;
  --muted: #9aa1ad;
  --accent: #7c83ff;           /* primary actions, focus */
  --accent-2: #38bdf8;         /* chart & detail colors */
  --accent-3: #fbbf24;
  --accent-4: #a78bfa;
  --accent-text: #ffffff;      /* text on accent */
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --link: var(--accent);
  --input-bg: #0f1115;
  --danger: #f87171;
  --danger-text: #fca5a5;
  --ok: #4ade80;
  --ok-text: #86efac;
  --backdrop: rgba(5, 6, 9, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 0.18s;
  /* Kept for older component styles */
  --btn-bg: var(--accent);
  --btn-text: var(--accent-text);
  color-scheme: dark;
}

/* --- Base ---------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 6px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* Visibility by sign-in state (classes set on <body> by site.js) */
body:not(.signed-in) [data-auth="in"], body.signed-in [data-auth="out"] { display: none !important; }
body:not(.is-owner) [data-owner-only], body:not(.signup-open) [data-signup="open"] { display: none !important; }

/* --- Buttons ------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 14px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  color: var(--accent-text); background: var(--accent);
  transition: background var(--dur), border-color var(--dur), color var(--dur), opacity var(--dur);
}
.btn:hover { text-decoration: none; background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn .icon { width: 16px; height: 16px; }
.btn.secondary, .btn.ghost { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn.secondary:hover, .btn.ghost:hover { background: var(--border-soft); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block, .btn.wide { width: 100%; }
.btn.share.active { color: var(--link); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }

.count-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
  border-radius: 99px; background: var(--danger); color: #fff; font: 700 11px/1 var(--font);
}
.badge { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 99px; font: 600 11px/1.4 var(--font);
  background: var(--accent-soft); color: var(--link); vertical-align: middle; }

/* --- Top bar & account menu ------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-soft); }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font: 650 16px/1 var(--font-head); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.user-menu { position: relative; }
.user-button {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 4px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 14px/1 var(--font); cursor: pointer; transition: background var(--dur);
}
.user-button:hover, .user-button[aria-expanded="true"] { background: var(--surface-hover); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font: 700 13px/1 var(--font); text-transform: uppercase; }
.user-button .chevron { width: 16px; height: 16px; color: var(--muted); }
.menu-dot { position: absolute; top: 2px; left: 26px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px; padding: 6px;
  background: var(--surface-strong); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  transform-origin: top right; animation: menu-in var(--dur) var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu-head { margin: 4px 10px 8px; font-size: 13px; color: var(--muted); }
.menu-head b { color: var(--text); font-weight: 600; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  border: 0; background: none; color: var(--text); font: 500 14px/1.2 var(--font); text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--surface-hover); text-decoration: none; outline: none; }
.menu .icon { color: var(--muted); }

/* --- Home ------------------------------------------------------------------------- */
.page { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.hero { padding: 72px 0 48px; max-width: 640px; }
.eyebrow { margin: 0 0 12px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.hero h1 { margin: 0 0 12px; font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 700; letter-spacing: -0.03em; }
.lede { margin: 0 0 28px; font-size: 1.15rem; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.section { padding-bottom: 56px; }
.section-title { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.app-tile {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-soft); color: var(--text);
  transition: border-color var(--dur), background var(--dur);
}
.app-tile:hover { text-decoration: none; border-color: var(--border); background: var(--surface-hover); }
.app-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--link); flex-shrink: 0; }
.app-icon .icon { width: 22px; height: 22px; }
.app-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-text b { font-weight: 600; }
.app-text small { color: var(--muted); font-size: 13px; }
.app-lock { margin-left: auto; color: var(--muted); }
.app-lock .icon { width: 16px; height: 16px; }

.footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 24px 20px 32px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border-soft); }
.footer-sep { opacity: 0.5; }

/* --- Pop-up shell ------------------------------------------------------------------ */
.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.modal.open { opacity: 1; visibility: visible; transition: opacity var(--dur) var(--ease), visibility 0s; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.modal-panel {
  position: relative; width: 100%; min-width: 0; max-width: 460px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; background: var(--surface-strong); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.99); transition: transform var(--dur) var(--ease), max-width var(--dur) var(--ease);
}
.modal.open .modal-panel { transform: none; }
.modal-panel[data-size="small"] { max-width: 460px; }
.modal-panel[data-size="medium"] { max-width: 720px; }
.modal-panel[data-size="large"] { max-width: 980px; }
.modal-panel[data-size="xl"] { max-width: 1180px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--link); }
.modal-icon:empty { display: none; }
.modal-icon .icon { width: 17px; height: 17px; }
.modal-body { padding: 20px; overflow-y: auto; overscroll-behavior: contain; min-width: 0; }
.view { display: none; }
.view.active { display: block; animation: fade-in var(--dur) var(--ease); }
.modal-body.leaving .view.active { opacity: 0; transition: opacity 0.1s; }
@keyframes fade-in { from { opacity: 0; } }

/* Tabs (Settings, Dashboard) */
.tabs { display: flex; gap: 2px; margin: -6px 0 18px; border-bottom: 1px solid var(--border-soft); }
.tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; background: none;
  color: var(--muted); font: 600 14px/1 var(--font); cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tabs .count-badge { margin-left: 2px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in var(--dur) var(--ease); }

/* Segmented control (whose files, eras) */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.space-tab {
  padding: 6px 12px; border-radius: 7px; border: 0; background: none; color: var(--muted);
  font: 600 13px/1.2 var(--font); cursor: pointer; transition: background var(--dur), color var(--dur);
}
.space-tab:hover { color: var(--text); }
.space-tab[aria-selected="true"] { background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .sub { margin: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.back-link { display: inline-block; margin-top: 16px; font-size: 14px; }

/* --- Forms ------------------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-size: 13px; font-weight: 600; color: var(--text); }
.optional { font-weight: 400; color: var(--muted); margin-left: 4px; }
input[type=text], input[type=password], input[type=url], input:not([type]), textarea, select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font: 14px/1.4 var(--font); outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 40px; }
textarea.code, .mono { font-family: var(--font-mono); font-size: 13px; }
select option { background: var(--surface-strong); color: var(--text); }
.input-group { display: flex; align-items: stretch; gap: 8px; }
.input-group input { flex: 1; min-width: 0; }
.input-prefix { display: flex; align-items: center; padding: 0 2px; color: var(--muted); font: 13px var(--font-mono); white-space: nowrap; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.form-foot { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.error, .success { display: none; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.error { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger-text); }
.success { background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok-text); }
.error.show, .success.show { display: block; }
.hp, .hidden-input { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.group { padding: 16px; border-radius: var(--radius); background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.group + .group { margin-top: 12px; }
.group-title { margin: 0 0 4px; font-size: 15px; font-weight: 650; }
.group .sub + * { margin-top: 12px; }
.view > .group-title { margin-top: 26px; margin-bottom: 10px; }

.toggle { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; font-size: 14px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 38px; height: 22px; border-radius: 99px; background: var(--border); position: relative; transition: background var(--dur); flex-shrink: 0; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--dur) var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.check-list { display: grid; gap: 6px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-soft); font-weight: 500; cursor: pointer; }
.check-list input { width: 16px; height: 16px; accent-color: var(--accent); }

/* --- Settings: theme picker & members ------------------------------------------------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-option {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  background: var(--surface); color: var(--text); text-align: left; font: inherit; transition: border-color var(--dur), box-shadow var(--dur);
}
.theme-option:hover { border-color: var(--muted); }
.theme-option[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
/* The swatch carries its own data-theme, so it shows that theme's real colors */
.theme-swatch { display: block; height: 70px; padding: 10px; background: var(--bg); border-bottom: 1px solid var(--border-soft); }
.theme-swatch .sw-card { display: block; height: 100%; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); padding: 8px; }
.theme-swatch .sw-line { display: block; height: 6px; border-radius: 3px; background: var(--muted); opacity: 0.6; width: 70%; }
.theme-swatch .sw-btn { display: block; margin-top: 8px; height: 10px; width: 40%; border-radius: 4px; background: var(--accent); }
.theme-name { display: flex; justify-content: space-between; align-items: center; padding: 9px 11px; font-size: 13.5px; font-weight: 600; }
.theme-name small { font-weight: 400; color: var(--muted); }

.account-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.account-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border-soft); }
.account-list .who { font-weight: 600; }
.account-list .who small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.account-list .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* --- Files ------------------------------------------------------------------------- */
.space-note { margin: -4px 0 12px; color: var(--muted); font-size: 13.5px; }
.space-note:empty { display: none; }
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); font-size: 14px;
  transition: border-color var(--dur), background var(--dur), color var(--dur);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.progress-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.progress-list:empty { display: none; }
.progress-item { background: var(--surface-sunk); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 9px 12px; }
.progress-item .row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.progress-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; border-radius: 99px; background: var(--border-soft); margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.progress-item.done .status { color: var(--ok); }
.progress-item.failed .status { color: var(--danger); }

table.files { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 14px; }
table.files th, table.files td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border-soft); }
table.files th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
table.files td.size, table.files th.size { text-align: right; white-space: nowrap; color: var(--muted); }
table.files td.date { color: var(--muted); white-space: nowrap; }
table.files td.actions { text-align: right; width: 1%; white-space: nowrap; }
table.files .row-actions { flex-wrap: nowrap; }
table.files th.thumb, table.files td.thumb { width: 52px; padding-right: 0; }
table.files tbody tr:hover { background: var(--surface-hover); }
.thumb-box { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--surface-sunk); border: 1px solid var(--border-soft); font-size: 1.1rem; cursor: pointer; padding: 0; }
.thumb-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-open { background: none; border: 0; padding: 0; font: 500 14px var(--font); color: var(--text); cursor: pointer; text-align: left; word-break: break-all; }
.file-open:hover { color: var(--link); text-decoration: underline; }
.file-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 14px; }

/* --- Dialogs and viewers (stack on top of pop-ups) ------------------------------------ */
.viewer, .dialog {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.viewer.open, .dialog.open { opacity: 1; visibility: visible; transition: opacity var(--dur) var(--ease), visibility 0s; }
.viewer-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.viewer-box {
  position: relative; width: min(1100px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  border-radius: var(--radius); background: var(--surface-strong); border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden;
}
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--border-soft); }
.viewer-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100vh - 130px); border-radius: var(--radius-sm); display: block; }
.viewer-body audio { width: min(520px, 100%); }
.viewer-body iframe { width: 100%; height: calc(100vh - 130px); border: 0; border-radius: var(--radius-sm); background: #fff; }
.viewer-body pre { width: 100%; margin: 0; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-sunk); max-height: calc(100vh - 130px); overflow: auto; white-space: pre-wrap; word-break: break-word; font: 13px/1.55 var(--font-mono); color: var(--text); }
.viewer-body .no-preview { text-align: center; color: var(--muted); padding: 40px 16px; }
.viewer-body .no-preview .big { font-size: 2.5rem; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-strong); color: var(--text); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.viewer-nav:hover { background: var(--surface-hover); }
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }
.dialog-box { position: relative; width: min(400px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 20px; border-radius: var(--radius); background: var(--surface-strong); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.dialog-box h3 { margin: 0 0 4px; font-size: 16px; }
.dialog-box .sub { word-break: break-all; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* --- Chat ---------------------------------------------------------------------------- */
.online { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.online::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }
.chat-log { height: min(52vh, 480px); overflow-y: auto; padding: 14px; border-radius: var(--radius); background: var(--surface-sunk); border: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 4px; }
.chat-msg { max-width: 78%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-msg .who { font-size: 12px; color: var(--muted); margin: 8px 4px 3px; }
.chat-msg .who b { color: var(--name-color, var(--text)); font-weight: 600; }
.chat-msg.cont .who { display: none; }
.bubble { display: inline-block; position: relative; text-align: left; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.chat-msg.mine .bubble { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.chat-msg.mine .bubble a { color: inherit; text-decoration: underline; }
.bubble .del { display: none; position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-strong); color: var(--muted); font-size: 11px; cursor: pointer; line-height: 1; }
.chat-msg.mine .bubble .del { right: auto; left: -8px; }
.bubble:hover .del, .bubble:focus-within .del { display: block; }
.chat-day { align-self: center; font-size: 12px; color: var(--muted); margin: 10px 0 2px; }
.composer { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 180px; }
.composer + .hint { margin-top: 6px; }

/* --- Pastes & links ------------------------------------------------------------------ */
.item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.item-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.item-list .main { min-width: 0; flex: 1; }
.item-list .main a, .item-list .main button.link { color: var(--text); font: 600 14px var(--font); background: none; border: 0; padding: 0; cursor: pointer; word-break: break-all; text-align: left; }
.item-list .main a:hover, .item-list .main button.link:hover { color: var(--link); text-decoration: underline; }
.item-list .main small { display: block; color: var(--muted); font-size: 12.5px; word-break: break-all; margin-top: 2px; }
.code-view { margin: 0; padding: 12px 0; border-radius: var(--radius); background: var(--surface-sunk); border: 1px solid var(--border-soft); max-height: 60vh; overflow: auto; font: 13px/1.6 var(--font-mono); counter-reset: line; }
.code-view .ln { display: block; padding: 0 16px 0 0; white-space: pre-wrap; word-break: break-word; }
.code-view .ln::before { counter-increment: line; content: counter(line); display: inline-block; width: 3.2em; margin-right: 14px; padding-right: 10px; text-align: right; color: var(--muted); opacity: 0.6; border-right: 1px solid var(--border-soft); user-select: none; }

/* --- Timeline & facts (used by the Mary, Queen of Scots page) -------------------------- */
.era-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 24px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline li { position: relative; margin-bottom: 6px; }
.timeline li::before { content: attr(data-glyph); position: absolute; left: -24px; top: 10px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 0.65rem; background: var(--surface-strong); border: 2px solid var(--accent); color: var(--link); }
.timeline details { background: var(--surface-sunk); border-radius: var(--radius-sm); border: 1px solid var(--border-soft); }
.timeline details[open] { border-color: var(--border); }
.timeline summary { list-style: none; cursor: pointer; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.timeline summary::-webkit-details-marker { display: none; }
.timeline summary .when { font-size: 12.5px; color: var(--link); font-weight: 600; min-width: 9.5em; }
.timeline summary .what { font-weight: 600; }
.timeline summary::after { content: "+"; margin-left: auto; color: var(--muted); }
.timeline details[open] summary::after { content: "–"; }
.timeline .body { padding: 0 14px 12px; }
.timeline .body .place { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.fact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fact { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-sunk); border: 1px solid var(--border-soft); }
.fact h4 { margin: 0 0 4px; }
.fact p { margin: 0; color: var(--muted); font-size: 14px; }

/* --- Toast ------------------------------------------------------------------------------ */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translateX(-50%); padding: 12px 18px; border-radius: 99px;
  background: var(--surface-strong); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500; animation: fade-in var(--dur) var(--ease);
}

/* --- Small screens ------------------------------------------------------------------------ */
@media (max-width: 640px) {
  .topbar-inner { padding: 0 14px; }
  .user-name { display: none; }
  .user-button { padding-right: 8px; }
  .page { padding: 0 14px; }
  .hero { padding: 44px 0 32px; }
  .app-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: end; }
  .modal-panel { max-height: 92vh; border-radius: var(--radius) var(--radius) 0 0; transform: translateY(24px); }
  .modal-body { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  table.files td.date, table.files th.date { display: none; }
  .chat-msg { max-width: 92%; }
}

/* --- Reduced motion (system setting or Settings → Appearance) ------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) *, html:not([data-motion="on"]) *::before, html:not([data-motion="on"]) *::after { animation: none !important; transition: none !important; }
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
