/* BJJ Gallery — design system and components.
   Fonts are self-hosted (SIL OFL, see static/fonts/*.txt). */

@font-face { font-family: "Archivo"; font-weight: 400; font-display: swap; src: url("fonts/archivo-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 500; font-display: swap; src: url("fonts/archivo-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 600; font-display: swap; src: url("fonts/archivo-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Archivo"; font-weight: 700; font-display: swap; src: url("fonts/archivo-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --ground: #F3F3F1;
  --surface: #FFFFFF;
  --surface-sunk: #FAFAF8;
  --ink: #121316;
  --ink-2: #2E3137;
  --muted: #5B5F66;
  --muted-2: #4A4E55;
  --line: #E2E2DE;
  --line-strong: #D5D5D0;
  --accent: #B42318;
  --accent-hover: #8F1C13;
  --accent-soft: #FBEAE8;
  --accent-line: #F0C7C2;
  --avatar: #E8E7E2;
  --placeholder-1: #D9D8D3;
  --placeholder-2: #CFCFC9;
  --placeholder-3: #DEDCD5;
  --placeholder-4: #C9CAC5;
  --success-bg: #E7F4EC; --success-ink: #1D5E36;
  --error-bg: var(--accent-soft); --error-ink: #8F1C13;
  --info-bg: #E9EEF8; --info-ink: #1F3F86;

  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
  --max: 1280px;
  --gutter: 24px;
  --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; color: #fff; }

.display {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1;
}
.page-title { font-size: 48px; }
.muted { color: var(--muted); }
.container { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.page { max-width: var(--max); margin: 0 auto; padding: 32px var(--gutter) 72px; }
.page-narrow { max-width: 640px; margin: 0 auto; padding: 32px var(--gutter) 72px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-nav { max-width: var(--max); margin: 0 auto; padding: 10px var(--gutter); display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand:hover { color: var(--ink); }
.brand-mark { display: flex; justify-content: flex-end; width: 34px; height: 12px; background: var(--ink); border-radius: 2px; }
.brand-mark::after { content: ""; width: 10px; background: var(--accent); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: 0.04em; }
.nav-links { display: flex; gap: 4px; }
.nav-link { display: flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: 15px; color: var(--muted-2); }
.nav-link[aria-current="page"] { background: var(--ground); color: var(--ink); font-weight: 600; }
.nav-search { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; height: var(--tap); padding: 0 14px; min-width: 0; background: var(--ground); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.nav-search:focus-within { border-color: var(--ink); }
.nav-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--ink); }
.nav-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border: 0; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; }
.icon-button:hover { background: var(--ground); color: var(--ink); }
.icon-button[aria-current="page"] { background: var(--ground); }
.count-badge { position: absolute; top: 5px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* Dropdowns built on <details> so they work without JS. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(18, 19, 22, 0.14); padding: 8px; z-index: 30; }
.menu-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 10px; }
.menu-panel-head h2 { font-size: 15px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font-size: 14px; cursor: pointer; }
.menu-item:hover { background: var(--ground); color: var(--ink); }
.menu-empty { padding: 16px 10px 20px; color: var(--muted); font-size: 14px; }
.notice { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.notice:hover { background: var(--ground); }
.notice > a { flex: 1; display: flex; gap: 10px; align-items: center; padding: 8px 10px; font-size: 14px; min-width: 0; }
.notice time { display: block; font-size: 12px; color: var(--muted); }
.notice .icon-button { width: 36px; height: 36px; flex: none; color: var(--muted-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border: 1px solid transparent; border-radius: 999px; font-weight: 600; font-size: 15px; line-height: 1; cursor: pointer; text-align: center; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2A2C31; color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { background: var(--surface); border-color: var(--accent-line); color: var(--accent); }
.btn-danger:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn-danger-solid { background: var(--accent); color: #fff; }
.btn-danger-solid:hover { background: var(--accent-hover); color: #fff; }
.btn-light { background: #fff; color: var(--ink); }
.btn-light:hover { color: var(--ink); background: #ECECEA; }
.btn-ghost-light { background: transparent; border-color: #5B5F66; color: #fff; }
.btn-ghost-light:hover { border-color: #fff; color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.text-button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0; border: 0; background: none; font-size: 13px; font-weight: 600; color: var(--muted-2); cursor: pointer; }
.text-button:hover { color: var(--accent); }
.text-button[aria-pressed="true"] { color: var(--accent); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-size: 15px; font-weight: 600; color: var(--muted-2); }

/* ---------- Flash messages ---------- */
.flash-stack { max-width: var(--max); margin: 16px auto 0; padding: 0 var(--gutter); display: grid; gap: 8px; }
.flash { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 16px; border-radius: var(--radius-sm); font-size: 15px; background: var(--info-bg); color: var(--info-ink); }
.flash p { flex: 1; }
.flash-success { background: var(--success-bg); color: var(--success-ink); }
.flash-error, .flash-warning { background: var(--error-bg); color: var(--error-ink); }
.flash .icon-button { width: 36px; height: 36px; color: inherit; }
.flash .icon-button:hover { background: rgba(0, 0, 0, 0.06); }

/* ---------- Toolbar: chips, density, sort ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin-top: 8px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-size: 14px; color: var(--muted); }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 14px; font-weight: 600; color: var(--ink); }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; }
.segmented button, .segmented a { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; font-weight: 600; color: var(--muted-2); cursor: pointer; }
.segmented [aria-pressed="true"], .segmented [aria-current="true"] { background: var(--ink); color: #fff; }
.density-toggle[hidden] { display: none; }

/* ---------- Avatars and belts ---------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 999px; background: var(--avatar); color: var(--ink); font-size: 12px; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-xl { width: 132px; height: 132px; font-size: 44px; font-family: var(--font-display); background: #2A2C31; color: #fff; border: 4px solid #fff; }
.avatar-dark { background: var(--ink); color: #fff; }

.belt { --belt: #F5F5F2; --belt-ink: var(--ink); --bar: #121316; display: inline-flex; align-items: stretch; height: 26px; border-radius: 4px; overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.18); vertical-align: middle; }
.belt-label { display: flex; align-items: center; padding: 0 10px; background: var(--belt); color: var(--belt-ink); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.belt-bar { display: flex; align-items: center; justify-content: flex-end; gap: 3px; min-width: 26px; padding: 0 4px; background: var(--bar); }
.belt-stripe { width: 3px; height: 16px; background: #fff; border-radius: 1px; }
.belt-sm { height: 20px; }
.belt-sm .belt-label { padding: 0 7px; font-size: 10px; }
.belt-sm .belt-bar { min-width: 18px; }
.belt-sm .belt-stripe { height: 12px; width: 2px; }
.belt-white  { --belt: #F5F5F2; }
.belt-grey   { --belt: #8A8D91; --belt-ink: #fff; }
.belt-yellow { --belt: #E7B416; }
.belt-orange { --belt: #E07B24; }
.belt-green  { --belt: #2F7D46; --belt-ink: #fff; }
.belt-blue   { --belt: #1F4FB8; --belt-ink: #fff; }
.belt-purple { --belt: #6B3FA0; --belt-ink: #fff; }
.belt-brown  { --belt: #6E4423; --belt-ink: #fff; }
.belt-black  { --belt: #000; --belt-ink: #fff; --bar: var(--accent); border-color: #5B5F66; }

/* ---------- Gallery grid with density ---------- */
.gallery { columns: 4 260px; column-gap: 20px; }
.gallery[data-density="compact"] { columns: 6 180px; column-gap: 12px; }
.gallery[data-density="large"] { columns: 3 400px; column-gap: 28px; }
.card { break-inside: avoid; margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gallery[data-density="compact"] .card { margin-bottom: 12px; border-radius: var(--radius-sm); }
.gallery[data-density="large"] .card { margin-bottom: 28px; }
.card-media { display: block; background: var(--placeholder-1); }
.card-media img { width: 100%; height: auto; }
.card-body { display: block; padding: 14px 16px 4px; }
.card-body:hover { color: var(--ink); }
.card-body:hover .card-title { color: var(--accent); }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.gallery[data-density="large"] .card-title { font-size: 18px; }
.card-tags { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--accent); }
.card-meta { display: flex; align-items: center; gap: 10px; padding: 8px 16px 12px; }
.card-author { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; font-size: 14px; font-weight: 500; }
.card-author span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.like-small { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 6px; border: 0; background: none; font-size: 13px; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); }
.like-small:hover { color: var(--accent); }
.like-small[aria-pressed="true"] { color: var(--accent); }
.like-small[aria-pressed="true"] .icon { fill: var(--accent); }
.gallery[data-density="compact"] .card-body { padding: 8px 10px 10px; }
.gallery[data-density="compact"] .card-title { font-size: 13px; }
.gallery[data-density="compact"] .card-tags,
.gallery[data-density="compact"] .card-meta { display: none; }

.empty-state { padding: 64px 16px; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--ink); font-size: 20px; margin-bottom: 8px; }
.empty-state .btn { margin-top: 20px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; font-size: 14px; color: var(--muted); }

/* ---------- Photo detail ---------- */
.photo-layout { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; margin-top: 8px; }
.photo-stage { flex: 999 1 560px; min-width: 0; display: flex; align-items: center; justify-content: center; min-height: 360px; background: var(--ink); border-radius: var(--radius-lg); overflow: hidden; }
.photo-stage img { max-height: 80vh; width: auto; }
.photo-panel { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 20px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-author { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-author > a { display: flex; align-items: center; gap: 12px; flex: 1 1 200px; min-width: 0; }
.panel-author strong { display: block; font-size: 15px; }
.panel-author small { display: block; font-size: 13px; color: var(--muted); }
.photo-title { font-size: 34px; line-height: 1.05; }
.photo-description { margin-top: 12px; font-size: 15px; line-height: 1.6; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.tag-link { color: var(--accent); font-weight: 600; }
.tag-link:hover { color: var(--accent-hover); text-decoration: underline; }
.photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.like-button { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 15px; cursor: pointer; }
.like-button:hover { border-color: var(--ink); }
.like-button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.like-button[aria-pressed="true"] .icon { fill: var(--accent); }
.photo-actions .report-link { margin-left: auto; }

.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { font-size: 14px; }
.comment-head a { font-weight: 600; }
.comment-head time { color: var(--muted); }
.comment-text { margin: 4px 0 2px; font-size: 14px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.comment-tools { display: flex; flex-wrap: wrap; gap: 14px; }
.comment-tools .delete { color: var(--accent); }
.replies { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.reply-form { display: flex; gap: 8px; margin-top: 6px; }
.reply-form[hidden] { display: none; }
.reply-form input { flex: 1; min-width: 0; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form .btn { align-self: flex-end; }

/* ---------- Forms ---------- */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; }
.form-card > h1 { font-size: 40px; margin-bottom: 6px; }
.form-card > .lede { color: var(--muted); margin-bottom: 24px; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-size: 14px; font-weight: 600; }
.field fieldset { border: 0; margin: 0; padding: 0; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="search"],
.field input[type="date"], .field input[type="number"], .field input[type="url"], .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 16px; color: var(--ink);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(18, 19, 22, 0.12); }
.field input[type="file"] { font-size: 14px; }
.field input[type="file"]::file-selector-button { margin-right: 12px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-weight: 600; cursor: pointer; }
.field .help { font-size: 13px; color: var(--muted); }
.field .help ul { margin: 4px 0 0; padding-left: 18px; }
.field .errors { margin: 0; padding: 0; list-style: none; font-size: 13px; font-weight: 600; color: var(--error-ink); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--accent); }
.field-radio-list { display: flex; flex-direction: column; gap: 6px; }
.field-radio-list label { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; font-weight: 500; cursor: pointer; }
.field-radio-list label:has(input:checked) { border-color: var(--ink); background: var(--ground); }
.field-radio-list input { accent-color: var(--accent); width: 18px; height: 18px; }
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.form-errors { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--error-bg); color: var(--error-ink); font-size: 14px; font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.current-image { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.current-image img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); }
.confirm-preview { display: flex; gap: 16px; align-items: center; padding: 16px; margin-bottom: 20px; background: var(--ground); border-radius: var(--radius); }
.confirm-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm); }
.confirm-preview blockquote { margin: 0; font-size: 15px; color: var(--ink-2); }

/* ---------- Profile ---------- */
.profile-hero { background: var(--ink); color: #fff; }
.profile-hero-inner { max-width: var(--max); margin: 0 auto; padding: 40px var(--gutter) 36px; display: flex; flex-wrap: wrap; align-items: center; gap: 28px; }
.profile-info { flex: 999 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.profile-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.profile-name { font-size: 52px; }
.profile-handle { color: #C9CBD0; font-size: 15px; }
.profile-bio { max-width: 640px; color: #E6E7EA; line-height: 1.55; white-space: pre-line; }
.profile-facts { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 4px; font-size: 14px; color: #C9CBD0; }
.profile-facts span { display: inline-flex; align-items: center; gap: 6px; }
.profile-cta { flex: 0 1 auto; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-left: auto; }
.tabs-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 16px; border-bottom: 3px solid transparent; font-weight: 500; font-size: 15px; color: var(--muted-2); white-space: nowrap; }
.tab[aria-current="page"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 700; }
.tab .tab-count { font-size: 13px; color: var(--muted); font-weight: 500; }
.tabs-row .toolbar { padding-bottom: 8px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile-grid[data-density="compact"] { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.tile-grid[data-density="large"] { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 24px; }
.tile { position: relative; display: block; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--placeholder-2); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s ease; }
.tile:hover img { transform: scale(1.03); }
.tile-caption { position: absolute; inset: auto 0 0 0; padding: 28px 14px 12px; background: linear-gradient(to top, rgba(18, 19, 22, 0.78), rgba(18, 19, 22, 0)); color: #fff; font-size: 14px; font-weight: 600; }
.tile-grid[data-density="large"] .tile-caption { font-size: 17px; }
.tile-grid[data-density="compact"] .tile { border-radius: 6px; }
.tile-grid[data-density="compact"] .tile-caption { display: none; }

/* ---------- Search ---------- */
.search-hero { display: flex; gap: 10px; margin: 0 0 20px; }
.search-hero .nav-search { height: 52px; background: var(--surface); font-size: 16px; }
.member-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.member { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.member:hover { border-color: var(--ink); color: var(--ink); }
.member-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.member-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-text small { font-size: 13px; color: var(--muted); }
.member-text .belt { align-self: flex-start; }
.tag-list { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-list .chip small { margin-left: 6px; color: var(--muted); font-weight: 500; }

/* ---------- Inbox ---------- */
.inbox { display: flex; flex-wrap: wrap; min-height: 640px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.inbox-list { flex: 1 1 300px; min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.inbox-list-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.inbox-list-head h1 { font-size: 32px; }
.threads { list-style: none; margin: 0; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.thread-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; }
.thread-link:hover { background: var(--ground); color: var(--ink); }
.thread-link[aria-current="page"] { background: var(--ground); }
.thread-link strong { flex: 1; font-size: 15px; }
.unread-dot { width: 10px; height: 10px; flex: none; border-radius: 999px; background: var(--accent); }
.inbox-pane { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; }
.pane-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.pane-head a { font-weight: 600; }
.pane-head small { display: block; color: var(--muted); font-size: 13px; }
.message-list { flex: 1; list-style: none; margin: 0; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-sunk); overflow-y: auto; max-height: 64vh; }
.message { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.message.mine { align-items: flex-end; }
.bubble { max-width: min(70%, 520px); padding: 10px 14px; border-radius: 16px; border-bottom-left-radius: 4px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.message.mine .bubble { background: var(--ink); border-color: var(--ink); color: #fff; border-radius: 16px; border-bottom-right-radius: 4px; }
.bubble img { margin-top: 8px; border-radius: 10px; max-height: 280px; }
.message time { font-size: 11px; color: var(--muted); padding: 0 4px; }
.composer { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.composer input[type="text"] { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 15px; }
.attach { position: relative; overflow: hidden; border: 1px solid var(--line-strong); }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attach.has-file { border-color: var(--accent); color: var(--accent); }
.pane-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; background: var(--surface); }
.auth-brand { flex: 1 1 420px; min-height: 320px; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; background: var(--ink); color: #fff; }
.auth-brand .brand, .auth-brand .brand:hover { color: #fff; }
.auth-brand .brand-mark { width: 44px; height: 16px; background: #000; border: 1px solid #3A3D43; }
.auth-brand .brand-mark::after { width: 13px; }
.auth-brand .brand-name { font-size: 30px; }
.auth-photo { flex: 1; min-height: 200px; border-radius: var(--radius-lg); background: #2A2C31 center / cover no-repeat; }
.auth-brand .auth-tagline { margin: 0; font-size: 56px; line-height: 0.95; color: #fff; }
.auth-brand p:not(.auth-tagline) { margin-top: 14px; max-width: 460px; color: #C9CBD0; line-height: 1.55; }
.auth-main { flex: 1 1 420px; padding: 48px var(--gutter); display: flex; align-items: center; justify-content: center; }
.auth-form { width: 100%; max-width: 400px; }
.auth-form h2 { font-size: 40px; }
.auth-form .lede { margin: 6px 0 24px; color: var(--muted); }
.auth-form a { color: var(--accent); font-weight: 600; }
.auth-form a:hover { color: var(--accent-hover); }
.auth-alt { margin-top: 18px; text-align: center; font-size: 15px; color: var(--muted-2); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

/* ---------- Settings ---------- */
.settings-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 14px 24px; }
.settings-list dt { font-weight: 600; color: var(--muted-2); }
.settings-list dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Error pages ---------- */
.error-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px var(--gutter); text-align: center; }
.error-page .display { font-size: 96px; color: var(--accent); }

/* ---------- Mobile tab bar ---------- */
.tabbar { display: none; }
.mobile-only { display: none !important; }

@media (max-width: 719px) {
  :root { --gutter: 16px; }
  body { padding-bottom: 76px; }
  .site-nav { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand-name { font-size: 22px; }
  .brand-mark { width: 28px; height: 10px; }
  .brand-mark::after { width: 8px; }
  .nav-links, .nav-search, .nav-actions .hide-mobile { display: none; }
  .page, .page-narrow { padding-top: 20px; }
  .page-title { font-size: 34px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 0 var(--gutter); }
  .chip { flex: none; }
  .toolbar .density-label, .toolbar .segmented span { display: none; }
  .segmented button { width: var(--tap); justify-content: center; padding: 0; }

  /* On phones the density levels mean 3, 2 or 1 photos per row. */
  .gallery { columns: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gallery[data-density="compact"] { columns: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .gallery[data-density="large"] { columns: auto; grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .gallery .card, .gallery[data-density] .card { margin: 0; }
  .gallery:not([data-density="large"]) .card-media { aspect-ratio: 4 / 5; }
  .gallery[data-density="compact"] .card-media { aspect-ratio: 1; }
  .gallery:not([data-density="large"]) .card-media img { height: 100%; object-fit: cover; }
  .gallery:not([data-density="large"]) .card-meta, .gallery:not([data-density="large"]) .card-tags { display: none; }
  .gallery:not([data-density="large"]) .card-body { padding: 8px 10px 10px; }
  .gallery:not([data-density="large"]) .card-title { font-size: 13px; }
  .gallery[data-density="compact"] .card { border: 0; border-radius: 4px; }
  .gallery[data-density="compact"] .card-body { display: none; }

  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-grid[data-density="compact"] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  .tile-grid[data-density="large"] { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  .photo-stage { margin: 0 calc(-1 * var(--gutter)); border-radius: 0; }
  .photo-panel { padding: 18px; }
  .photo-title { font-size: 28px; }
  .profile-hero-inner { padding-top: 28px; gap: 18px; }
  .avatar-xl { width: 96px; height: 96px; font-size: 32px; }
  .profile-name { font-size: 38px; }
  .profile-cta { justify-content: flex-start; }
  .inbox { margin: 0 calc(-1 * var(--gutter)); border-radius: 0; border-left: 0; border-right: 0; }
  .inbox-list { border-right: 0; }
  .inbox.is-thread .inbox-list { display: none; }
  .inbox:not(.is-thread) .inbox-pane { display: none; }
  .message-list { max-height: none; }
  .auth-brand { padding: 28px var(--gutter); min-height: 0; }
  .auth-photo { display: none; }
  .auth-brand .auth-tagline { font-size: 40px; }
  .form-card { padding: 20px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }

  .mobile-only { display: inline-flex !important; }
  .tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; font-size: 11px; font-weight: 500; color: var(--muted-2); }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
  .tabbar .tab-upload span { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 999px; background: var(--accent); color: #fff; }
  .tabbar .count-badge { top: 2px; right: calc(50% - 22px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
