/* The site's own identity (src/styles/tokens.css): Ivory Paper, Midnight Ink,
   Electric Sapphire as the single accent; Instrument Serif and Montserrat.
   Light by default, dark when the computer is (or when it's chosen in the top bar). */
@font-face { font-family: 'Instrument Serif'; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/instrument-serif-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/instrument-serif-latin-400-italic.woff2) format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 400; font-display: swap; src: url(fonts/montserrat-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 500; font-display: swap; src: url(fonts/montserrat-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-display: swap; src: url(fonts/montserrat-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-display: swap; src: url(fonts/montserrat-latin-700-normal.woff2) format('woff2'); }

:root {
  --ink: #0d1019;
  --paper: #f6f3ee;
  --blue: #3032f9;
  --on-blue: #fff;
  --text: var(--ink);
  --bg: var(--paper);
  --card: #fdfbf8;
  --field: #fff;
  --side: #fdfbf8;
  --blue-soft: color-mix(in srgb, var(--blue) 9%, var(--card));
  --muted: color-mix(in srgb, var(--text) 58%, var(--bg));
  --line: color-mix(in srgb, var(--text) 10%, var(--bg));
  --line-strong: color-mix(in srgb, var(--text) 20%, var(--bg));
  --sunk: color-mix(in srgb, var(--text) 4%, var(--bg));
  --hover: color-mix(in srgb, var(--text) 6%, var(--card));
  --bad: #a3321f;
  --bad-bg: #f9e6df;
  --ok: #2f6b3f;
  --ok-bg: #e5efe2;
  --warn: #7a5a12;
  --warn-bg: #f6ebcf;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(13 16 25 / .04), 0 4px 18px rgb(13 16 25 / .05);
  --shadow-up: 0 -6px 24px rgb(13 16 25 / .07);
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Montserrat', system-ui, -apple-system, sans-serif;
  --side-w: 264px;
  --topbar-h: 60px;
  color-scheme: light;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #7c7eff; --on-blue: #0d1019; --text: #ece8e1; --bg: #0d1019; --card: #151a26; --field: #10141e; --side: #111520;
    --bad: #ff9b85; --bad-bg: #3a1d17; --ok: #93d3a2; --ok-bg: #16301e; --warn: #f0cd7a; --warn-bg: #3a2f12;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 18px rgb(0 0 0 / .25); --shadow-up: 0 -6px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #7c7eff; --on-blue: #0d1019; --text: #ece8e1; --bg: #0d1019; --card: #151a26; --field: #10141e; --side: #111520;
  --bad: #ff9b85; --bad-bg: #3a1d17; --ok: #93d3a2; --ok-bg: #16301e; --warn: #f0cd7a; --warn-bg: #3a2f12;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 18px rgb(0 0 0 / .25); --shadow-up: 0 -6px 24px rgb(0 0 0 / .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
::selection { background: color-mix(in srgb, var(--blue) 25%, transparent); }
a { color: var(--blue); }
h1 { font-family: var(--serif); font-weight: 400; font-size: 2.4rem; line-height: 1.05; letter-spacing: -.01em; margin: 0 0 .3rem; }
h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; line-height: 1.15; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88rem; line-height: 1.6; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* the logos: the ink one on light, the ivory one on dark */
.on-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .on-light { display: none !important; }
  :root:not([data-theme="light"]) .on-dark { display: block !important; }
}
:root[data-theme="dark"] .on-light { display: none !important; }
:root[data-theme="dark"] .on-dark { display: block !important; }
.when-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-light { display: none; }
  :root:not([data-theme="light"]) .when-dark { display: block; }
}
:root[data-theme="dark"] .when-light { display: none; }
:root[data-theme="dark"] .when-dark { display: block; }

/* ---- the menu on the left ---- */
.side { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--side-w); background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; transition: width .2s ease, transform .25s ease; }
.side .brand { display: flex; align-items: center; height: var(--topbar-h); padding: 0 1.4rem; flex: none; border-bottom: 1px solid var(--line); }
.side .brand-full { width: 158px; height: auto; }
:root:root .side .brand-mark { width: 34px; height: auto; display: none !important; }
.menu { flex: 1; overflow-y: auto; padding: .9rem .75rem 1rem; display: flex; flex-direction: column; gap: 2px; }
.menu .group { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); margin: 1.1rem 0 .35rem .8rem; white-space: nowrap; }
.menu a { display: flex; align-items: center; gap: .75rem; padding: .5rem .8rem; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.menu a .icon { color: var(--muted); transition: color .15s; }
.menu a span { overflow: hidden; text-overflow: ellipsis; }
.menu a:hover { background: var(--hover); }
.menu a:hover .icon { color: var(--text); }
.menu a.current { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.menu a.current .icon { color: var(--blue); }
.me { flex: none; display: flex; align-items: center; gap: .5rem; padding: .8rem .75rem; border-top: 1px solid var(--line); }
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: .65rem; padding: .35rem .45rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.who:hover { background: var(--hover); }
.who-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.who-text strong { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-family: var(--serif); font-size: 1.1rem; line-height: 1; }

/* narrowed (wide screens only): icons only, the names as tooltips */
@media (min-width: 901px) {
  :root[data-side="narrow"] { --side-w: 76px; }
  :root[data-side="narrow"] .side .brand { padding: 0; justify-content: center; }
  :root[data-side="narrow"] .side .brand-full { display: none !important; }
  :root[data-side="narrow"] .side .brand-mark.on-light { display: block !important; }
  :root[data-side="narrow"] .menu .group { margin: .9rem auto .3rem; width: 1.5rem; height: 1px; background: var(--line); }
  :root[data-side="narrow"] .menu .group span { display: none; }
  :root[data-side="narrow"] .menu a { justify-content: center; padding: .6rem; }
  :root[data-side="narrow"] .menu a span, :root[data-side="narrow"] .who-text { display: none; }
  :root[data-side="narrow"] .me { flex-direction: column; padding: .8rem .5rem; }
  :root[data-side="narrow"] .who { flex: none; padding: .2rem; }
  @media (prefers-color-scheme: dark) {
    :root[data-side="narrow"]:not([data-theme="light"]) .side .brand-mark.on-light { display: none !important; }
    :root[data-side="narrow"]:not([data-theme="light"]) .side .brand-mark.on-dark { display: block !important; }
  }
  :root[data-side="narrow"][data-theme="dark"] .side .brand-mark.on-light { display: none !important; }
  :root[data-side="narrow"][data-theme="dark"] .side .brand-mark.on-dark { display: block !important; }
}

.scrim { position: fixed; inset: 0; z-index: 25; background: rgb(13 16 25 / .45); }

/* ---- the top bar and the page ---- */
.shell { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.75rem 0 1rem; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .menu-open { display: none; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: .88rem; color: var(--muted); }
.crumbs li { display: flex; align-items: center; gap: .4rem; }
.crumbs li + li::before { content: ''; width: .4rem; height: .4rem; border-right: 1.5px solid var(--line-strong); border-top: 1.5px solid var(--line-strong); transform: rotate(45deg); margin-right: .2rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current] { color: var(--text); font-weight: 600; display: block; max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { width: 100%; max-width: 1180px; padding: 2.25rem 2.5rem 3rem; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; margin-bottom: 1.75rem; }
.head .muted { max-width: 64ch; }
.head-title { display: flex; gap: 1rem; align-items: flex-start; min-width: 0; }
.head-icon { flex: none; width: 3rem; height: 3rem; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); margin-top: .15rem; }
.head-icon .icon { width: 24px; height: 24px; }
.head .buttons { flex: none; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-head { margin-bottom: 1rem; }
.card-head h2 { font-size: 1.4rem; }

/* messages: problems at the top of the page, a save in the corner */
.flash { display: flex; gap: .75rem; align-items: flex-start; padding: .95rem 1.15rem; border-radius: 12px; margin-bottom: 1.25rem; font-weight: 500; }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.flash ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.toasts { position: fixed; z-index: 50; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2.5rem)); }
.toast { display: flex; align-items: center; gap: .75rem; padding: .8rem .6rem .8rem 1rem; border-radius: 14px; background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: 0 12px 40px rgb(13 16 25 / .18); font-weight: 500; animation: toast-in .3s ease both; }
.toast.ok > .icon { color: var(--ok); background: var(--ok-bg); border-radius: 50%; padding: 4px; width: 28px; height: 28px; }
.toast p { flex: 1; }
.toast.leaving { animation: toast-out .25s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }

/* ---- buttons ---- */
.button, button.primary, button.add { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-size: .88rem; font-weight: 600; padding: .55rem 1.05rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.button .icon, button.primary .icon, button.add .icon { width: 17px; height: 17px; }
.button:hover, button.add:hover { background: var(--hover); border-color: var(--text); }
.primary, .button.primary, button.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.primary:hover, .button.primary:hover, button.primary:hover { background: color-mix(in srgb, var(--blue) 85%, var(--text)); border-color: transparent; }
.button.ghost { border-color: transparent; background: transparent; }
.button.ghost:hover { background: var(--hover); border-color: transparent; }
.button.small { padding: .32rem .7rem; font-size: .82rem; }
.button.danger, button.danger { color: var(--bad); }
.button.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.icon-button { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; text-decoration: none; transition: background .15s, color .15s; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button.danger:hover { background: var(--bad-bg); color: var(--bad); }
form { margin: 0; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; padding: .18rem .65rem .18rem .55rem; border-radius: 999px; white-space: nowrap; }
.status::before { content: ''; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }

/* ---- the dashboard ---- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'icon label' 'value value' 'note note'; align-items: center; column-gap: .65rem; padding: 1.2rem 1.35rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-icon { grid-area: icon; width: 2.1rem; height: 2.1rem; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.stat-icon .icon { width: 18px; height: 18px; }
.stat-label { grid-area: label; font-size: .82rem; font-weight: 600; color: var(--muted); }
.stat-value { grid-area: value; font-family: var(--serif); font-weight: 400; font-size: 2.6rem; line-height: 1; margin: .9rem 0 .35rem; }
.stat-note { grid-area: note; font-size: .8rem; color: var(--muted); }
.dash { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.tile { display: flex; align-items: center; gap: .85rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; height: 100%; transition: border-color .15s, background .15s; }
.tile:hover { border-color: var(--blue); background: var(--blue-soft); }
.tile > .icon { color: var(--muted); width: 16px; }
.tile-icon { flex: none; width: 2.25rem; height: 2.25rem; border-radius: 10px; display: grid; place-items: center; background: var(--sunk); color: var(--text); }
.tile-icon .icon { width: 18px; height: 18px; }
.tile:hover .tile-icon { background: var(--card); color: var(--blue); }
.tile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tile-text strong { font-weight: 600; }
.tile-text span { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline-icon { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--muted); }
.timeline-icon .icon { width: 16px; height: 16px; }
.timeline a { color: var(--text); font-weight: 600; text-decoration: none; }
.timeline a:hover { color: var(--blue); }
.empty { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; }

/* ---- long forms: the jump to a section, and the save bar ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.jump { list-style: none; margin: 0; padding: 0; display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.jump::-webkit-scrollbar { display: none; }
.jump a { display: block; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .8rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
.jump a:hover { color: var(--text); border-color: var(--line-strong); }
.toolbar-buttons { display: flex; gap: .2rem; flex: none; }
.section { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.savebar { position: sticky; bottom: 1rem; z-index: 10; display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; padding: .7rem .7rem .7rem 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-up), var(--shadow); }
.savebar-state { display: flex; align-items: center; gap: .55rem; font-size: .88rem; font-weight: 500; color: var(--muted); }
.savebar-state .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--ok); }
.savebar.dirty .savebar-state { color: var(--warn); }
.savebar.dirty .savebar-state .dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.savebar-hint { margin-left: auto; }
.savebar button.primary { padding: .7rem 1.5rem; font-size: .92rem; box-shadow: 0 6px 20px color-mix(in srgb, var(--blue) 30%, transparent); }

/* ---- forms ---- */
.section > summary { list-style: none; cursor: pointer; display: flex; align-items: flex-start; gap: 1rem; }
.section > summary::-webkit-details-marker { display: none; }
.section-title { flex: 1; display: flex; flex-direction: column; gap: .2rem; }
.section-title .muted { font-size: .88rem; }
.section-chevron { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: transform .2s, background .15s; transform: rotate(-90deg); }
.section[open] .section-chevron { transform: none; }
.section > summary:hover .section-chevron { background: var(--hover); color: var(--text); }
.section[open] > summary { margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.15rem 1.5rem; }
.fields.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field.wide { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.field label .req { color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], textarea, select {
  width: 100%; font: inherit; padding: .6rem .8rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
input[readonly] { background: var(--sunk); color: var(--muted); }
.has-error input, .has-error textarea, .has-error select { border-color: var(--bad); }
.error { color: var(--bad); font-size: .85rem; margin-top: .3rem; }
.help { color: var(--muted); font-size: .83rem; margin-top: .3rem; }
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix { display: flex; align-items: center; padding: 0 .75rem; border: 1px solid var(--line-strong); border-right: 0; border-radius: 10px 0 0 10px; background: var(--sunk); color: var(--muted); font-size: .88rem; white-space: nowrap; }
.prefixed input { border-radius: 0 10px 10px 0; }
.check { display: flex !important; align-items: center; gap: .55rem; font-weight: 500 !important; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--blue); }
.check.small { font-size: .85rem; font-weight: 400 !important; }
.static { padding: .5rem 0; }

/* files */
.file { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding: .85rem; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--sunk); transition: border-color .15s, background .15s; }
.file:hover, .file.dragging { border-color: var(--blue); background: var(--blue-soft); }
.file .preview { display: flex; align-items: center; gap: .7rem; }
.file img, .file video { display: block; max-height: 84px; max-width: 180px; border-radius: 8px; border: 1px solid var(--line); background: repeating-conic-gradient(#ece8e1 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.file input[type=file] { font: inherit; font-size: .85rem; color: var(--muted); }
.file input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: .82rem; margin-right: .75rem; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; }
.file input[type=file]::file-selector-button:hover { border-color: var(--text); }

/* lists */
.repeater .rows { display: flex; flex-direction: column; gap: .5rem; }
.repeater button.add { margin-top: .65rem; border-style: dashed; }
.row { border: 1px solid var(--line); border-radius: 12px; background: var(--sunk); }
.row > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .75rem; padding: .6rem .7rem .6rem .9rem; font-weight: 600; }
.row > summary::-webkit-details-marker { display: none; }
.row > summary::before { content: ''; flex: none; width: .45rem; height: .45rem; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; margin-right: .1rem; }
.row[open] > summary::before { transform: rotate(45deg); }
.row > summary .row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > .fields { padding: 1rem 1rem 1.15rem; border-top: 1px solid var(--line); background: var(--card); border-radius: 0 0 12px 12px; }
.row .row > .fields, .row .row { background: var(--card); }
.row-buttons { display: inline-flex; gap: .15rem; }
.row-buttons button { font: inherit; font-size: .85rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.row-buttons button:hover { color: var(--text); background: var(--bg); }
.row-buttons .remove:hover { color: var(--bad); }
.repeater.fixed .row-buttons .remove { display: none; }
.line { display: flex; gap: .5rem; align-items: flex-start; }
.line input, .line textarea { flex: 1; }
.line .row-buttons { padding-top: .2rem; }

/* ---- tables ---- */
.table-card { padding: 0; overflow: hidden; }
.table-tools { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.35rem; border-radius: 999px; }
.filters { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { font: inherit; font-size: .8rem; font-weight: 600; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; }
.chip span { font-size: .72rem; padding: 0 .4rem; border-radius: 999px; background: var(--sunk); }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on span { background: color-mix(in srgb, var(--bg) 20%, transparent); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: .75rem 1rem; background: var(--sunk); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--hover); }
tr:last-child td { border-bottom: 0; }
td form { display: inline; }
.title-link { color: var(--text); font-weight: 600; text-decoration: none; }
.title-link:hover { color: var(--blue); }
.thumb-col { width: 1%; padding-right: 0; }
.thumb { display: grid; place-items: center; width: 72px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--sunk); border: 1px solid var(--line); color: var(--muted); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .25rem; }
td.row-actions { display: table-cell; }
td.row-actions > * { vertical-align: middle; }
.person { display: flex; align-items: center; gap: .65rem; }
.person .avatar { width: 1.9rem; height: 1.9rem; font-size: 1rem; }
.table-card .empty { border-top: 1px solid var(--line); }
.show-sm { display: none; }

/* ---- the login: an ivory card on Midnight Ink, as the site's dark openings ---- */
body.signed-out { background: var(--ink); }
main.alone { max-width: none; min-height: 100vh; display: grid; place-items: center; align-content: center; padding: 2rem 1rem; }
.login-wrap { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; gap: 2rem; }
.login-logo { width: 210px; height: auto; }
.login { width: 100%; display: flex; flex-direction: column; gap: .35rem; padding: 2.25rem 2.25rem 2rem; border: 0; box-shadow: 0 24px 60px rgb(0 0 0 / .35); }
.login h1 { font-size: 2.4rem; margin-bottom: 0; }
.login > .muted { margin-bottom: .75rem; }
.login label { font-weight: 600; font-size: .85rem; margin-top: .65rem; }
.login .check { margin: .8rem 0 .4rem; font-size: .88rem; }
.login button { margin-top: .4rem; padding: .8rem; font-size: .95rem; }
body.signed-out .flash { width: min(400px, 100%); margin: 0 auto 1rem; }

/* ---- smaller screens ---- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  :root { --side-w: 280px; }
  .side { transform: translateX(-100%); box-shadow: none; }
  body.menu-open .side { transform: none; box-shadow: 0 0 60px rgb(0 0 0 / .3); }
  .shell { margin-left: 0; }
  .topbar { padding: 0 1rem 0 .6rem; }
  .topbar .menu-open { display: inline-grid; }
  .topbar .side-toggle { display: none; }
  main { padding: 1.5rem 1rem 2rem; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.9rem; }
  .head { flex-direction: column; }
  .head-icon { display: none; }
  .topbar .button.ghost span, .crumbs li:not(:last-child) { display: none; }
  .crumbs li + li::before { display: none; }
  .hide-sm { display: none; }
  .show-sm { display: block; margin: .15rem 0 0 2.55rem; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
  .stat { padding: 1rem; }
  .stat-value { font-size: 2rem; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .fields.cols-2, .fields.cols-3, .fields.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 1.15rem 1.1rem; }
  .table-card { padding: 0; }
  .toolbar-buttons, .savebar-hint { display: none; }
  .savebar { border-radius: 16px; bottom: .5rem; }
  .savebar button.primary { margin-left: auto; }
  /* a table's rows become cards: the name first, then its status and buttons */
  .table-card thead { display: none; }
  .table-card tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
  .table-card tbody tr:last-child { border-bottom: 0; }
  .table-card td { display: block; padding: 0; border: 0; background: none !important; }
  .table-card td.hide-sm { display: none; }
  .table-card td.thumb-col { flex: none; width: auto; }
  .table-card td.cell-main { flex: 1 1 calc(100% - 100px); min-width: 0; }
  .table-card td.row-actions { display: flex; margin-left: auto; }
  .table-card td:has(.status) { white-space: normal; display: flex; flex-wrap: wrap; gap: .3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
