/* ==========================================================================
   LLCOA (Long Lake and Loucks Lake & Area Cottager Owners Association) — Members' Portal
   Design tokens (README §11) normalized onto one coherent scale.
   ========================================================================== */

/* --- Self-hosted Source Serif 4 (variable weight 400–700) -----------------
   Vendored under /static/fonts; no CDN at runtime. One woff2 per subset
   covers all weights via the variable `wght` axis. Ranges copied from the
   upstream Google Fonts CSS so each subset loads only when needed. */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/sourceserif4-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/sourceserif4-latinext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Palette (§11) */
  --lake: #1d4e6b;
  --lake-dark: #173f57;
  --tabbar: #17435c;
  --tab-accent: #8fb4c7;
  --pine: #2c5e46;
  --pine-dark: #234c38;

  --paper: #f7f5f0;
  --canvas: #e9e5da;
  --surface: #ffffff;

  --text: #26343d;
  --body: #4d4a40;
  --body-strong: #3d3a30;
  --muted: #8a8272;
  --date: #5a5648;
  --login-body: #6d6a5e;

  /* Borders consolidated to a small set (§11 asks for this). */
  --border: #e2ddd2;
  --divider: #e7e2d5;
  --border-strong: #d8d2c4;
  --input-border: #cfc8b8;

  --row-hover: #efeadf;
  --sidebar-hover: #ece7da;
  --masthead-text: #f7f5f0;
  --tab-inactive: #dbe7ee;

  /* Type */
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;

  /* Radius scale */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Spacing scale (4px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  /* Shadows (§11) */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-pin: 0 2px 10px rgba(29, 78, 107, 0.10);
  --shadow-logo: 0 3px 10px rgba(29, 78, 107, 0.30);
  --shadow-sheet: 0 6px 20px rgba(0, 0, 0, 0.12);

  /* Reference widths (§11) */
  --w-container: 1040px;
  --w-sidebar: 230px;
  --w-rail: 330px;
  --w-login: 480px;
}

/* --- Light reset ---------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p {
  margin: 0;
}
a {
  color: var(--lake);
}
a:hover {
  color: var(--lake-dark);
}
img {
  max-width: 100%;
}

/* --- Accessibility helpers ------------------------------------------------ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--lake);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  z-index: 10;
}
.skip-link:focus {
  left: var(--s-3);
  top: var(--s-3);
}
:focus-visible {
  outline: 2px solid var(--lake);
  outline-offset: 2px;
}

/* --- Layout --------------------------------------------------------------- */
.container {
  max-width: var(--w-container);
  margin: 0 auto;
  padding-left: var(--s-8);
  padding-right: var(--s-8);
}
.page {
  padding-top: var(--s-6);
  padding-bottom: var(--s-10);
}

/* --- Masthead ------------------------------------------------------------- */
.masthead {
  background: var(--lake);
  color: var(--masthead-text);
}
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-4);
  padding-top: 18px;
  padding-bottom: 18px;
}
.assoc-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.masthead-sub {
  font-family: var(--font-sans);
  font-size: 12.5px;
  opacity: 0.78;
  margin-top: 2px;
}
.masthead-account {
  font-family: var(--font-sans);
  font-size: 12.5px;
  opacity: 0.85;
  white-space: nowrap;
}
.account-link {
  color: inherit;
  text-decoration: underline;
}
.masthead .account-link:hover {
  color: #fff;
}
/* Light focus ring where the background is dark. */
.masthead .account-link:focus-visible,
.tab:focus-visible {
  outline-color: #fff;
}

/* --- Tab bar (primary navigation, §7.2) ----------------------------------- */
.tabbar {
  background: var(--tabbar);
}
.tabbar-inner {
  display: flex;
  gap: 0;
}
.tab {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 16px;
  color: var(--tab-inactive);
  text-decoration: none;
  padding: 15px 34px;
  border-bottom: 3px solid transparent;
}
.tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.tab-active,
.tab-active:hover {
  color: #fff;
  border-bottom-color: var(--tab-accent);
}

/* --- Generic panel -------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 28px 32px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-3);
}
.lede {
  font-size: 15px;
  line-height: 1.6;
  color: var(--body);
  max-width: 62ch;
  margin-bottom: var(--s-3);
}
.muted-note {
  font-size: 13.5px;
  color: var(--muted);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 12px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn-primary {
  background: var(--lake);
  color: #fff;
}
.btn-primary:hover {
  background: var(--lake-dark);
  color: #fff;
}
.btn-block {
  width: 100%;
}
.btn-secondary {
  background: var(--pine);
  color: #fff;
}
.btn-secondary:hover {
  background: var(--pine-dark);
  color: #fff;
}
.btn-outline {
  background: var(--surface);
  color: var(--lake);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover {
  background: var(--row-hover);
  color: var(--lake-dark);
}
.btn-danger {
  background: var(--surface);
  color: #8c3b2a;
  border: 1px solid #e0c3b8;
}
.btn-danger:hover {
  background: #f2e2da;
  color: #6f2f22;
}
.btn-small {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

/* --- Utilities ------------------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* --- Login (§7.1) --------------------------------------------------------- */
.login-body {
  background: #f0eee9;
}
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-10) var(--s-4);
}
.login-card {
  width: 100%;
  max-width: var(--w-login);
  background: var(--paper);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(29, 78, 107, 0.10), var(--shadow-card);
}
.login-band {
  position: relative;
  height: 110px;
  background: linear-gradient(180deg, #1d4e6b 0%, #2a6285 70%, #8fb4c7 100%);
}
.login-band-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  background: linear-gradient(180deg, rgba(247, 245, 240, 0) 0%, var(--paper) 100%);
}
.login-inner {
  padding: var(--s-2) 44px 44px;
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  margin: -46px auto var(--s-4);
  border-radius: var(--r-lg);
  background: var(--lake);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--shadow-logo);
  position: relative;
}
.login-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.3;
  color: var(--text);
}
.login-instruction {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--login-body);
  margin: var(--s-4) 0 var(--s-6);
}
.login-input {
  width: 100%;
  padding: 15px 18px;
  font-family: var(--font-sans);
  font-size: 17px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  letter-spacing: 0.08em;
}
.login-input::placeholder {
  color: #9aa3ad;
  letter-spacing: normal;
}
.login-input:focus {
  outline: none;
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(29, 78, 107, 0.15);
}
.login-submit {
  margin-top: var(--s-3);
  padding: 15px;
  font-size: 16.5px;
}
.login-error {
  background: #f2e2da;
  color: #7a4a33;
  border: 1px solid #e6cdbf;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: var(--s-4);
  text-align: center;
}
.login-help {
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--s-5);
}
.login-help a {
  color: var(--muted);
  text-decoration: underline;
}

/* --- Category pill -------------------------------------------------------- */
.pill {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

/* --- Archive (§7.3) ------------------------------------------------------- */
.archive-grid {
  display: grid;
  grid-template-columns: var(--w-sidebar) 1fr;
  gap: var(--s-8);
  align-items: start;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-heading {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 8px;
}
.sidebar-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--body-strong);
  text-decoration: none;
}
.sidebar-btn:hover {
  background: var(--sidebar-hover);
  color: var(--body-strong);
}
.sidebar-active,
.sidebar-active:hover {
  background: var(--lake);
  color: var(--paper);
  font-weight: 700;
}
.cat-count {
  font-family: var(--font-sans);
  font-size: 11.5px;
  opacity: 0.6;
}
.sidebar-help {
  margin-top: var(--s-4);
  padding: 14px 12px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.sidebar-help a {
  color: var(--muted);
  text-decoration: underline;
}

/* Search */
.search-form {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  margin-bottom: var(--s-4);
}
.search-input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
}
.search-input:focus {
  outline: none;
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(29, 78, 107, 0.15);
}

/* Results */
.results-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--s-2);
}
.results-count {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
}
.doc-table {
  display: flex;
  flex-direction: column;
}
.doc-table-head {
  display: grid;
  grid-template-columns: 1fr 150px 120px;
  gap: 0 16px;
  padding: 0 14px 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
}
.col-date {
  text-align: right;
}
.doc-row {
  display: grid;
  grid-template-columns: 1fr 150px 120px;
  gap: 0 16px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--divider);
  border-radius: var(--r-sm);
  text-decoration: none;
  color: inherit;
}
.doc-row:hover {
  background: var(--row-hover);
  color: inherit;
}
.doc-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.doc-meta {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.doc-cell-date {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--date);
}
.empty-state {
  padding: 48px 0;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--muted);
}

/* Pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: var(--s-6);
}
.pager-page {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--lake);
  text-decoration: none;
  background: var(--surface);
}
.pager-page:hover {
  background: var(--row-hover);
  color: var(--lake-dark);
}
.pager-current,
.pager-current:hover {
  background: var(--lake);
  border-color: var(--lake);
  color: #fff;
  font-weight: 600;
}
.pager-gap {
  min-width: 24px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* Mobile category picker — hidden on desktop (sidebar is used instead). */
.cat-picker {
  display: none;
}

/* --- Admin (§9, §13) ------------------------------------------------------ */
.admin {
  max-width: 860px;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: var(--s-6);
}
.admin-h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--s-5);
}
.admin-h3 {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin: var(--s-6) 0 var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid var(--divider);
}
.admin-count {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

/* Banners */
.banner {
  border-radius: var(--r-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: var(--s-5);
}
.banner-ok {
  background: #dfeae2;
  color: #234c38;
  border: 1px solid #c4dccb;
}
.banner-error {
  background: #f2e2da;
  color: #7a4a33;
  border: 1px solid #e6cdbf;
}

/* Forms */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--s-5);
}
.form-row {
  display: flex;
  gap: var(--s-5);
}
.form-row .form-field {
  flex: 1;
  min-width: 0;
}
.form-field-grow {
  flex: 2;
}
.form label,
.form-field > label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  color: var(--body-strong);
}
.form-opt {
  font-weight: 400;
  color: var(--muted);
}
.form input[type="text"],
.form input[type="date"],
.form input[type="number"],
.form input[type="file"],
.form textarea {
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  width: 100%;
}
.form textarea {
  resize: vertical;
}
.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(29, 78, 107, 0.15);
}
.form-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--body-strong);
  margin-bottom: var(--s-5);
  cursor: pointer;
}
.form-check input {
  width: 18px;
  height: 18px;
}
.form-actions {
  display: flex;
  gap: var(--s-3);
  align-items: center;
}

/* Admin tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--border-strong);
}
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
.admin-nowrap {
  white-space: nowrap;
  color: var(--date);
}
.col-action {
  text-align: right;
  white-space: nowrap;
}
.admin-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
}
.admin-actions form {
  display: inline;
}
.admin-tag {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  margin-left: 4px;
}
/* Flags a download-only document that no browser can render (§9). */
.admin-tag-warn {
  color: #8a5a2e;
  border-color: #d8b98e;
  background: #f6ecdc;
}

/* --- Home / landing (§7.2) ------------------------------------------------ */
.section-label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.section-divider {
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 8px;
  margin-bottom: 6px;
}
.home-section {
  margin-bottom: var(--s-8);
}

/* Pinned "Frequently used" cards */
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.pin-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
}
.pin-card:hover {
  border-color: var(--lake);
  box-shadow: var(--shadow-pin);
  color: inherit;
}
.pin-tile {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 12px;
}
.pin-text {
  min-width: 0;
}
.pin-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.pin-sub {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* Announcements + Recently added columns */
.home-columns {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--s-8);
  align-items: start;
}
.announce {
  padding: 18px 0;
  border-bottom: 1px solid var(--divider);
}
.announce-date {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.announce-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}
.announce-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--body);
  margin: 6px 0 0;
}
.announce-link {
  display: inline-block;
  margin-top: 9px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  color: var(--lake);
  text-decoration: underline;
}
.recent-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.recent-seeall {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  color: var(--lake);
  text-decoration: none;
  white-space: nowrap;
}
.recent-seeall:hover {
  text-decoration: underline;
}
.recent-row {
  display: block;
  padding: 13px 0;
  border-bottom: 1px solid var(--divider);
  text-decoration: none;
  color: inherit;
}
.recent-row:hover {
  opacity: 0.75;
  color: inherit;
}
.recent-title {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.recent-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
}
.recent-date {
  font-size: 12px;
  color: var(--muted);
}

/* --- Document view (§7.4) ------------------------------------------------- */
.docview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.docview-topbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.docview-back {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--lake);
  text-decoration: none;
  white-space: nowrap;
}
.docview-back:hover {
  text-decoration: underline;
}
.docview-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docview-download {
  flex: none;
  padding: 10px 18px;
  font-size: 14px;
}
.docview-body {
  display: grid;
  grid-template-columns: 1fr var(--w-rail);
  min-height: 560px;
}
.reader {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px;
  background: var(--canvas);
}
/* PDF reader: the embedded frame stacked under its escape-hatch link. */
.reader-pdf {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.reader-frame {
  width: 100%;
  height: 660px;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}
/* "View all pages" is off by default: desktop browsers embed a PDF properly, so
   the link would be a control nobody there needs. It is revealed on coarse
   (touch) pointers — the devices running WebKit's single-page iframe render,
   which includes iPad at desktop widths, so this is a pointer query and not a
   width breakpoint. */
.reader-open {
  display: none;
}
@media (pointer: coarse) {
  .reader-open {
    display: flex;
  }
}
.reader-image {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}
.reader-fallback {
  align-self: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 36px 40px;
  max-width: 360px;
}
.reader-fallback-type {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: var(--s-3);
}
.reader-fallback-text {
  font-size: 14.5px;
  color: var(--body);
  margin-bottom: var(--s-5);
}
.rail {
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.rail-block {
  padding: 22px 24px;
  border-bottom: 1px solid var(--divider);
}
.rail-heading {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-4);
}
.rail-details {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px 12px;
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
}
.rail-details dt {
  color: var(--muted);
}
.rail-details dd {
  margin: 0;
}
.rail-description {
  line-height: 1.55;
  color: var(--body);
}
.rail-note {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
}
/* Collapsible details rail (§7.4). The rail's padding lives on the <details>
   itself so the closed state can tighten it down to a tab. */
.rail-collapse {
  padding: 22px 24px;
}
.rail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
}
.rail-summary::-webkit-details-marker {
  display: none;
}
.rail-summary:hover {
  color: var(--text);
}
.rail-collapse[open] .rail-summary {
  margin-bottom: var(--s-4);
}
/* Caret points the way the rail goes: right to close it, left to reopen
   (down/up at the mobile breakpoint, where the rail is stacked instead). */
.rail-caret {
  flex: none;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--muted);
}
.rail-collapse:not([open]) .rail-caret {
  transform: rotate(180deg);
}
/* Desktop: closing the rail has to give the width to the reader, otherwise it
   just leaves a dead 330px column. The grid track shrinks to the tab and the
   heading turns on its side. Gated on :has() — browsers without it keep the
   full-width rail, which is the old behaviour, not a tab in an empty column. */
@media (min-width: 769px) {
  @supports selector(:has(*)) {
    .docview-body:has(.rail-collapse:not([open])) {
      grid-template-columns: 1fr auto;
    }
    .rail-collapse:not([open]) {
      padding: 22px 13px;
    }
    .rail-collapse:not([open]) .rail-summary {
      flex-direction: column;
      gap: var(--s-2);
    }
    .rail-collapse:not([open]) .rail-summary-label {
      writing-mode: vertical-rl;
    }
  }
}

/* --- Comments / discussion (§14) ------------------------------------------ */
.discussion {
  margin-top: var(--s-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  padding: 24px;
}
.discussion-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 10px;
}
.discussion-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}
.discussion-count {
  font-size: 13px;
  color: var(--muted);
}
.discussion-note {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 16px;
}
.discussion-empty {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0 2px;
}

/* Composer + reply forms */
.comment-form {
  margin: 0;
}
.comment-form-top {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 22px;
}
.comment-input-name,
.comment-input-body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  width: 100%;
}
.comment-input-name {
  max-width: 280px;
  margin-bottom: 10px;
}
.comment-input-body {
  display: block;
  resize: vertical;
}
.comment-input-name:focus,
.comment-input-body:focus {
  outline: none;
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(29, 78, 107, 0.15);
}
.comment-form-actions {
  margin-top: 10px;
}
.comment-error {
  margin-bottom: 12px;
}
/* Honeypot: off-screen for people, tempting to bots (§14.2). */
.comment-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Thread list */
.comment-list,
.comment-replies {
  list-style: none;
  margin: 0;
  padding: 0;
}
.comment {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--divider);
}
.comment-list > .comment:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 2px;
}
.comment-replies {
  margin: 14px 0 0 18px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}
.comment-replies > .comment {
  border-top: none;
  margin-top: 12px;
  padding-top: 0;
}
.comment-resolved > .comment-main {
  opacity: 0.72;
}
.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.comment-author {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.comment-time {
  font-size: 12px;
  color: var(--muted);
}
.comment-edited {
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
}
.comment-badge {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.comment-badge-resolved {
  background: #dfeae2;
  color: #2c5e46;
}
.comment-badge-hidden {
  background: #f2e2da;
  color: #7a4a33;
}
.comment-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--body);
}
.comment-full {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment-removed {
  font-size: 13.5px;
  font-style: italic;
  color: var(--muted);
}

/* Read-more (§14.7): native <details>, no JS. */
.comment-more > summary {
  list-style: none;
  cursor: pointer;
}
.comment-more > summary::-webkit-details-marker {
  display: none;
}
.comment-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment-more-link::after {
  content: " Read more";
  font-weight: 600;
  color: var(--lake);
}
.comment-more[open] .comment-preview {
  display: none;
}
.comment-more[open] .comment-more-link::after {
  content: "Show less";
}

/* Actions row */
.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
}
.comment-action-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--lake);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.comment-action-btn:hover {
  text-decoration: underline;
}
.comment-action-danger {
  color: #8c3b2a;
}
.comment-inline-form {
  display: inline;
  margin: 0;
}
.comment-mod {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.comment-reply,
.comment-reply > summary {
  display: inline;
}
.comment-reply > summary {
  list-style: none;
}
.comment-reply > summary::-webkit-details-marker {
  display: none;
}
.comment-form-reply {
  margin-top: 12px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  max-width: 560px;
}

/* Admin audit disclosure */
.comment-audit {
  margin-top: 8px;
  font-size: 12px;
}
.comment-audit > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.comment-audit-body {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  color: var(--body);
}
.comment-audit-body code {
  word-break: break-all;
}

/* Archive row comment count (§14.9) */
.doc-comment-count {
  color: var(--muted);
}

/* Home "Recent comments" (§14.9) */
.home-comments {
  max-width: 640px;
}
.rcomment {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  text-decoration: none;
  color: inherit;
}
.rcomment:hover {
  color: inherit;
  opacity: 0.8;
}
.rcomment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.rcomment-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.rcomment-time {
  font-size: 11.5px;
  color: var(--muted);
}
.rcomment-snippet {
  font-size: 13.5px;
  color: var(--body);
  margin-top: 3px;
}
.rcomment-doc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* Narrow single-column admin panel (comment edit) */
.panel-narrow {
  max-width: 620px;
}

/* --- Responsive: single breakpoint at 768px (§8) -------------------------- */
@media (max-width: 768px) {
  .container {
    padding-left: var(--s-4);
    padding-right: var(--s-4);
  }
  .masthead-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
  }
  .assoc-name {
    font-size: 16px;
    line-height: 1.3;
  }
  .page {
    padding-top: var(--s-4);
  }
  /* Two equal, full-width tabs. */
  .tab {
    flex: 1;
    justify-content: center;
    text-align: center;
    padding: 12px 0;
    font-size: 15px;
    border-bottom-width: 2px;
  }
  .panel {
    padding: 20px 18px;
  }
  .login-inner {
    padding: var(--s-2) var(--s-6) var(--s-8);
  }

  /* Archive: single column; sidebar hidden in favor of the picker sheet. */
  .archive-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sidebar {
    display: none;
  }
  .cat-picker {
    display: block;
    margin-bottom: var(--s-3);
  }
  .cat-picker-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 15px;
    border: 1px solid var(--input-border);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
    list-style: none;
  }
  .cat-picker-btn::-webkit-details-marker {
    display: none;
  }
  .cat-picker-caret {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
  }
  .cat-picker[open] .cat-picker-caret {
    transform: rotate(180deg);
  }
  .cat-picker-sheet {
    margin-top: 6px;
    background: var(--surface);
    border: 1px solid var(--input-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sheet);
    overflow: hidden;
  }
  .cat-picker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--row-hover);
    font-family: var(--font-serif);
    font-size: 15.5px;
    color: var(--body-strong);
    text-decoration: none;
  }
  .cat-picker-item:last-child {
    border-bottom: none;
  }
  .cat-picker-item.cat-active {
    background: var(--lake);
    color: var(--paper);
    font-weight: 700;
  }

  /* Documents become stacked rows: (pill + date) / title / type · size. */
  .doc-table-head {
    display: none;
  }
  .doc-row {
    grid-template-columns: auto auto 1fr;
    grid-template-areas:
      "cat date ."
      "main main main";
    gap: 6px 8px;
    padding: 15px 4px;
  }
  .doc-cell-main {
    grid-area: main;
  }
  .doc-cell-cat {
    grid-area: cat;
  }
  .doc-cell-date {
    grid-area: date;
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    align-self: center;
  }
  .doc-title {
    font-size: 16.5px;
    line-height: 1.35;
  }

  /* Admin: form rows stack on narrow screens. */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  /* Home: pins single column; "Recently added" is dropped (§7.2). */
  .pin-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .home-columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .home-recent {
    display: none;
  }

  /* Document view stacks: reader above, details rail below. */
  .docview-body {
    grid-template-columns: 1fr;
  }
  .docview-topbar {
    flex-wrap: wrap;
    padding: 14px 16px;
  }
  .docview-title {
    order: 3;
    flex-basis: 100%;
    white-space: normal;
  }
  .reader {
    padding: 16px;
  }
  .reader-frame {
    height: 70vh;
  }
  .rail {
    border-left: none;
    border-top: 1px solid var(--border);
  }
  /* The rail is stacked below the reader here, so there is no width to hand
     back: it stays a plain disclosure and the caret points down/up. */
  .rail-caret {
    border: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
  }
  .rail-collapse:not([open]) .rail-caret {
    transform: rotate(-90deg);
  }

  /* Comments: tighter reply indentation and full-width composer name. */
  .discussion {
    padding: 16px;
  }
  .comment-replies {
    margin-left: 8px;
    padding-left: 10px;
  }
  .comment-input-name {
    max-width: 100%;
  }
}
