/* ══════════════════════════════════════════════════════════════════════════
   Aria — styles.css
   All site styles in one file: foundation → layout → components → pages.
   (Previously split as base.css + site.css.)
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --text:          #275c9d;
  --text-title:    #275c9d;
  --text-muted:    #5a6f8a;
  --border:        #aebac9;
  --accent:        #275c9d;
  --accent-soft:   #9cbae4;
  /* Optional underlined in-copy links (About, FAQ, static pages); much darker than body --text */
  --link-inline:       #062038;
  --link-inline-hover: #041018;
  --bg-page:       #ffffff;
  --bg-header:     #fefefe;
  --bg-rail:       #e9eef5;
  --bg-overlay:    #fefefe;
  /* Side padding shrinks to 0 once viewport is at/near content width (rail + main column). */
  --layout-gutter: clamp(0px, calc((100vw - 1052px) / 2), 1.125rem);
  --bg-subtle:     rgba(156, 186, 228, 0.22);
  --danger:        #c53030;
  --success:       #2d7a4d;
  --main-font:     'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --heading-font:  'Georgia', 'Times New Roman', serif;
  --header-height: 48px;
  --max-width:     920px;
  --site-rail-width: 132px;
  --kb-height:     0px;
  --radius:        0px;
  --radius-sm:     2px;
  --page-gutter:   1.5rem;
  /* Single source for main column insets (home, chat, profile, post inner, etc.) */
  --app-main-padding-x: 0.75rem;
  --app-main-padding-y: 0.85rem;
  --app-main-padding-bottom: 1.25rem;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

/* ── Body ─────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--main-font);
  color: var(--text);
  background-color: var(--bg-page);
  line-height: 1.6;
  letter-spacing: 0.02em;
  padding-top: var(--header-height);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(156, 186, 228, 0.45), transparent 55%),
    linear-gradient(180deg, #fefefe 0%, #ffffff 40%, #f6f9fc 100%);
  pointer-events: none;
}

body.sidebar-open {
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1200;
}

header .header-inner {
  display: grid;
  align-items: center;
  gap: 0.5rem 0.75rem;
  height: 100%;
  width: 100%;
  max-width: min(100%, calc(var(--max-width) + var(--site-rail-width) + 2 * var(--layout-gutter)));
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--layout-gutter);
  /* Extra inset so username / Sign out do not sit flush against the main column edge */
  padding-right: calc(var(--layout-gutter) + 0.55rem);
  box-sizing: border-box;
}

@media (max-width: 959.98px) {
  header .header-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  header .menu-toggle { grid-column: 1; }
  header .brand { grid-column: 2; justify-self: center; }
  header .user-actions { grid-column: 3; }
}

@media (min-width: 960px) {
  header .header-inner {
    grid-template-columns: var(--site-rail-width) minmax(0, 1fr) auto;
  }
  header .menu-toggle { display: none !important; }
  header .brand { grid-column: 1; justify-self: start; }
  header .user-actions { grid-column: 3; justify-self: end; }
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0;
  flex-shrink: 0;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  background: transparent;
}

.menu-bar {
  display: block;
  height: 2px;
  width: 20px;
  background: var(--accent);
  border-radius: 1px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  justify-self: start;
  width: fit-content;
  max-width: min(100%, max-content);
  align-self: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  background-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.brand:hover { text-decoration: none; }
.brand:focus { outline: none; background-color: transparent; box-shadow: none; }
.brand:active { background-color: transparent; box-shadow: none; transform: none; }
.brand:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: var(--radius-sm); }

/* Fixed box so layout does not shift while the logo decodes (same URL → disk cache on repeat visits). */
.brand-logo-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: transparent;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 36px;
  max-height: 36px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  border-radius: var(--radius);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  backface-visibility: hidden;
  transform: translateZ(0);
  image-rendering: auto;
}

.site-title {
  font-family: var(--heading-font);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1;
  color: var(--text-title);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
}

.user-actions {
  justify-self: end;
  justify-content: flex-end;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 0;
  width: max-content;
  max-width: 100%;
}

.user-actions a { text-decoration: none; color: var(--text); }
.user-actions a:hover { color: var(--accent); }
.user-actions a.username { color: var(--text-muted); text-decoration: none; }
.user-actions a.username:hover { color: var(--text); }

.username { color: var(--text-muted); }
.username.owner-link { cursor: pointer; }
.username.owner-link:hover { color: var(--accent); }

.signout-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--main-font);
}
.signout-btn:hover { color: var(--danger); }

/* ── App shell (desktop rail + vertical rules) ───────────────────────────── */
.app-frame {
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: min(100%, calc(var(--max-width) + var(--site-rail-width) + 2 * var(--layout-gutter)));
  margin-left: auto;
  margin-right: auto;
  min-height: calc(100vh - var(--header-height) - 4rem);
  box-sizing: border-box;
  padding-left: var(--layout-gutter);
  padding-right: var(--layout-gutter);
}

.desktop-site-rail {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--site-rail-width);
  padding: 1rem 0.35rem 1rem 0;
  gap: 0.1rem;
  letter-spacing: normal;
  background: transparent;
  border-radius: 0;
  box-sizing: border-box;
}

.desktop-site-rail a.desktop-site-rail-split {
  margin-top: 0.55rem;
}

.desktop-site-rail a {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.32rem 0.45rem;
  border-radius: var(--radius-sm);
  opacity: 0.88;
}
.desktop-site-rail a:hover {
  color: var(--text);
  background: rgba(156, 186, 228, 0.1);
  opacity: 1;
}
.desktop-site-rail a.sidebar-link-active {
  color: var(--accent);
  font-weight: 600;
  background: transparent;
  opacity: 1;
}
.desktop-site-rail a.sidebar-link-active:hover {
  background: transparent;
}
.app-main-well {
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  box-sizing: border-box;
  background: var(--bg-page);
}

.app-main-well > main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--app-main-padding-y) var(--app-main-padding-x) var(--app-main-padding-bottom);
  min-height: calc(100vh - var(--header-height));
  height: calc(100vh - var(--header-height));
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Post detail: main scrolls with article + in-place editor + comments */
body.app-shell .app-main-well > main:has(.post-page-inner) {
  height: auto;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: transparent !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
}
body.app-shell .app-main-well > main:has(.post-page-inner)::-webkit-scrollbar {
  display: none;
}

@media (min-width: 960px) {
  .desktop-site-rail { display: flex; }
  header .menu-toggle { display: none !important; }
}

@media (max-width: 959.98px) {
  .app-frame {
    flex-direction: column;
    max-width: 100%;
    min-height: 0;
    padding-left: var(--layout-gutter);
    padding-right: var(--layout-gutter);
  }
  .desktop-site-rail { display: none !important; }
  .app-main-well {
    border-left: none;
    border-right: none;
  }
  .app-main-well > main {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .modal-overlay { align-items: flex-start; padding-top: calc(var(--header-height) + 0.5rem); }
  .modal, .modal-wide {
    max-width: calc(100vw - 1rem);
    max-height: calc(100svh - var(--header-height) - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
  }

  .admin-table { font-size: 0.78rem; }
  .admin-table th, .admin-table td { padding: 0.45rem 0.4rem; }

  body.app-shell.admin-page .admin-panel { padding: 1rem; }
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
main {
  width: min(calc(100% - 2rem), var(--max-width));
  margin: 2rem auto;
  background-color: transparent;
  padding: 2.5rem var(--page-gutter);
  border-radius: var(--radius);
  border: none;
  box-shadow: none;
  height: calc(100vh - var(--header-height) - 4rem);
  overflow: hidden;
}

/* ── Scrollable inner panels ─────────────────────────────────────────────── */
.posts-panel,
.chat-messages,
.admin-panel {
  overflow-y: auto;
  scrollbar-width: none;
}

.posts-panel::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.admin-panel::-webkit-scrollbar {
  display: none;
}

/* ── Letter-spacing resets ───────────────────────────────────────────────── */
.md,
.post-content,
.comment,
.chat-messages,
.post-card,
.about-section p {
  letter-spacing: normal;
}

/* ── Typography ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--heading-font);
  color: var(--text-title);
  margin-bottom: 0.75rem;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover,
a:focus-visible {
  text-decoration: none;
}

a.inline-text-link {
  color: var(--link-inline);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
}
a.inline-text-link:hover,
a.inline-text-link:focus-visible {
  color: var(--link-inline-hover);
  text-decoration: underline;
}

hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Tags ────────────────────────────────────────────────────────────────── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.tag {
  background: rgba(156, 186, 228, 0.2);
  border: 1px solid rgba(39, 92, 157, 0.3);
  color: var(--accent);
  font-size: 0.74rem;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  padding: 0.48rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-family: var(--main-font);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.btn:hover,
.btn:focus-visible {
  filter: brightness(0.97);
  text-decoration: none;
}

button:hover,
button:focus-visible {
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(180deg, #9cbae4 0%, #275c9d 100%);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(39, 92, 157, 0.5);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: var(--border);
  color: var(--text);
  background: rgba(156, 186, 228, 0.12);
  opacity: 1;
}

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.81rem; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.06); opacity: 1; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.83rem; color: var(--text-muted); margin-bottom: 0.4rem; }

.form-group input,
.form-group textarea,
.comment-input,
.chat-input {
  width: 100%;
  background: var(--bg-page);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.58rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: var(--main-font);
}

.form-group input:focus,
.form-group textarea:focus,
.comment-input:focus,
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea { min-height: 200px; resize: vertical; line-height: 1.6; }
.form-hint { font-size: 0.77rem; color: var(--text-muted); margin-top: 0.3rem; }
.label-optional { font-size: 0.74rem; color: var(--text-muted); font-weight: normal; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.empty-state {
  display: block;
  width: 100%;
  margin: 0;
  padding: 2.25rem 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.55;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

#posts-container > .empty-state,
#post-container > .empty-state {
  min-height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-muted { color: var(--text-muted); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Markdown ────────────────────────────────────────────────────────────── */
.md { line-height: 1.85; font-size: 0.97rem; }
.md h1, .md h2, .md h3 { margin-top: 1.5rem; }
.md ul, .md ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.md code {
  background: var(--bg-header);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.87em;
}
.md pre {
  background: var(--bg-header);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.75rem 0;
}
.md pre code { background: none; border: none; padding: 0; }
.md blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.75rem 0;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(39, 92, 157, 0.22);
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2rem;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 2px 12px rgba(39, 92, 157, 0.08);
}
.modal-wide { max-width: 720px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.modal-header h2 { margin-bottom: 0; font-size: 1.25rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); background: rgba(156, 186, 228, 0.15); }

.auth-error {
  color: var(--danger);
  font-size: 10px;
  letter-spacing: 4px;
  margin: 8px 0;
  display: none;
}
.auth-error.visible { display: block; }

/* ── Context menu ────────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 2000;
  background: var(--bg-header);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 6px rgba(39, 92, 157, 0.12);
  min-width: 120px;
  display: none;
  letter-spacing: normal;
}
.ctx-menu.open { display: block; }
.ctx-item { padding: 0.45rem 0.9rem; font-size: 0.82rem; cursor: pointer; color: var(--text); }
.ctx-item:hover { background: rgba(156, 186, 228, 0.12); color: var(--text); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(248,81,73,0.1); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar-root {
  position: fixed;
  inset: 0;
  z-index: 1100;
  pointer-events: none;
}

.sidebar-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.sidebar-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: min(280px, 88vw);
  height: 100%;
  background: var(--bg-header);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  padding: calc(var(--header-height) + 0.75rem) 1rem 1.25rem;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  box-sizing: border-box;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar-nav a {
  display: block;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: normal;
}
.sidebar-nav a:hover { background: rgba(156, 186, 228, 0.1); color: var(--text); }
.sidebar-nav a.sidebar-link-active {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a.sidebar-link-active:hover {
  background: transparent;
}

.sidebar-nav a.sidebar-nav-split {
  margin-top: 0.55rem;
}

body.sidebar-open #sidebar-root { pointer-events: auto; }
body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
body.sidebar-open .sidebar-panel { transform: translateX(0); }

/* ── File upload ─────────────────────────────────────────────────────────── */
.file-upload-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.file-name-label {
  font-size: 0.84rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon-clear:hover { color: var(--danger); background: rgba(248,81,73,0.1); }

.upload-status { font-size: 0.8rem; color: var(--success); flex: 1; }

.file-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-family: monospace;
  background: rgba(63,185,80,0.1);
  border: 1px solid rgba(63,185,80,0.35);
  color: var(--success);
  padding: 0.08rem 0.4rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 0.3rem;
}
.tag.file-badge {
  font-size: 0.74rem;
  padding: 0.12rem 0.5rem;
  font-family: monospace;
  margin-left: 0;
  letter-spacing: normal;
  vertical-align: baseline;
}

/* ── PDF viewer ──────────────────────────────────────────────────────────── */
.doc-viewer {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-page);
}
.pdf-embed { display: block; width: 100%; height: clamp(380px, 52vh, 680px); border: none; }
.doc-actions {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
  display: flex;
  gap: 0.5rem;
}

/* ── App shell pages (rail + main well): shared main / column behavior ───── */
body.app-shell .app-main-well > main:not(:has(.post-page-inner)) {
  background: transparent !important;
  border: none;
}

.post-page-inner {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Posts panel (post detail page) ─────────────────────────────────────── */
.posts-panel {
  padding: 0;
  min-width: 0;
}

body.app-shell .app-main-well > main:has(.post-page-inner) .posts-panel {
  border-right: none;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* ── Chat layout (flex column inside main) ──────────────────────────────── */
body.app-shell .app-main-well > main:has(.chat-layout) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-layout {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 960px) {
  body.app-shell .app-main-well > main:has(.chat-layout) .chat-layout {
    max-width: none;
    width: 100%;
    margin: 0;
  }
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: transparent;
}

/* Chat title row: same visual as former .chat-panel-header */
body.app-shell .chat-panel > h1.page-title {
  padding: 0 0 0.85rem;
  margin-top: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 0;
}

.chat-msg {
  font-size: 0.87rem;
  line-height: 1.45;
  padding: 0.2rem 0.35rem;
  word-break: break-word;
  transition: background-color 0.55s ease;
}
.chat-msg:hover { background: rgba(156, 186, 228, 0.06); }

.chat-msg-pending {
  opacity: 0.55;
  border-left: 2px solid rgba(139, 148, 158, 0.45);
  padding-left: 0.45rem;
  margin-left: -0.05rem;
}
.chat-msg-pending .msg-author { opacity: 0.75; }

.chat-msg-edited {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.45;
}
.chat-msg.msg-selected { background: rgba(255, 255, 255, 0.11); }

.msg-author,
.chat-msg .author-link {
  font-weight: 600;
  color: var(--text-title);
  margin-right: 0.4rem;
}

.chat-msg-cell--author .author-link {
  margin-right: 0;
}

.chat-msg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  column-gap: 0.65rem;
  row-gap: 0.1rem;
  align-items: start;
}

.chat-msg-cell--author {
  min-width: 0;
}

.chat-msg-cell--time {
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  line-height: 1.2;
}

.chat-msg-cell--body {
  min-width: 0;
}

.chat-msg-cell--edited {
  justify-self: end;
  align-self: start;
  text-align: right;
  line-height: 1.45;
}

.chat-msg-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: normal;
  white-space: nowrap;
}

.chat-msg .msg-body { display: block; width: 100%; }
.chat-msg .msg-body .katex { font-size: 0.95em; }

.chat-msg.system-msg {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.78rem;
  text-align: center;
  padding: 0.3rem 0;
}

.chat-input-area {
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.chat-input { flex: 1; }

/* ── Author links ────────────────────────────────────────────────────────── */
a.author-link { color: inherit; text-decoration: none; font-weight: 600; }
a.author-link:hover { color: var(--accent); }
.comment-meta .author-link { font-weight: 600; }

/* ── Post catalog (list view) ────────────────────────────────────────────── */
.post-catalog {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  width: 100%;
}

.post-catalog-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  color: inherit;
  transition: background-color 0.12s ease;
  overflow: visible;
}

.card-actions-col {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0.5rem 0 0 0.35rem;
  position: relative;
  z-index: 4;
}
.card-kebab-wrap {
  position: relative;
}
.card-kebab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  letter-spacing: normal;
}
.card-kebab-btn:hover,
.card-kebab-btn:focus-visible {
  color: var(--accent);
  background: rgba(156, 186, 228, 0.12);
}
.card-kebab-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 7.5rem;
  padding: 0.25rem 0;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(39, 92, 157, 0.12);
  z-index: 80;
  letter-spacing: normal;
}
.card-kebab-dropdown.open {
  display: block;
}
.card-kebab-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-family: var(--main-font);
  color: var(--text);
  cursor: pointer;
}
.card-kebab-item:hover {
  background: rgba(156, 186, 228, 0.12);
}
.card-kebab-item.danger {
  color: var(--danger);
}
.post-catalog-card:first-child { border-top: 1px solid var(--border); }
.post-catalog-card:hover { background: rgba(156, 186, 228, 0.08); }

.post-catalog-card .card-body {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 0.85rem 0 0.95rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Full-card link for middle-click / new tab; author links stay above via pointer-events */
.card-body-link {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.card-body-content {
  position: relative;
  z-index: 1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card-body-content a.author-link {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.card-title {
  font-family: var(--heading-font);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-title);
  margin: 0;
  line-height: 1.35;
  letter-spacing: normal;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.card-top {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

@media (min-width: 600px) {
  .card-top:has(.card-tags) {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 1rem;
  }
  .card-top:has(.card-tags) .card-left { flex: 1 1 12rem; min-width: 0; }
  .card-top .card-tags { flex: 0 1 auto; max-width: min(42%, 14rem); justify-content: flex-end; }
}

.card-left { min-width: 0; flex: 1 1 auto; }
.card-top .card-title { width: 100%; }
.card-top .card-tags {
  position: static;
  width: auto;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 0.3rem;
}

.card-meta-col {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0;
  min-width: 0;
  margin-top: 0.15rem;
}
.card-meta-col > .card-meta:not(:first-child)::before {
  content: '·';
  margin: 0 0.45rem;
  color: var(--text-muted);
  opacity: 0.45;
  font-weight: normal;
}

.card-tags .tag { display: inline-flex; align-items: center; line-height: 1; }
.card-meta, .card-tags, .tags, .tag { letter-spacing: normal; }
.card-meta { font-size: 0.72rem; color: var(--text-muted); }

/* ── Comments ────────────────────────────────────────────────────────────── */
.comments-label {
  font-family: var(--heading-font);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-title);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.comment {
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
  font-size: 0.87rem;
}
.comment:last-of-type { border-bottom: none; }
.comment-meta { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.15rem; }
.comment-meta strong { color: var(--text-title); }

.comment-meta-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.15rem;
}
.comment-meta-bar .comment-meta-main {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.comment-kebab-wrap {
  position: relative;
  flex-shrink: 0;
}
.comment-kebab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.comment-kebab-btn:hover,
.comment-kebab-btn:focus-visible {
  color: var(--accent);
  background: rgba(156, 186, 228, 0.1);
}
.comment-kebab-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.1rem;
  min-width: 6.5rem;
  padding: 0.2rem 0;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(39, 92, 157, 0.1);
  z-index: 40;
}
.comment-kebab-dropdown.open {
  display: block;
}
.comment-kebab-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.65rem;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-family: var(--main-font);
  color: var(--text);
  cursor: pointer;
}
.comment-kebab-item:hover {
  background: rgba(156, 186, 228, 0.1);
}
.comment-kebab-item.danger {
  color: var(--danger);
}

.comment-form { margin-top: 0.75rem; display: flex; gap: 0.5rem; }
.comment-input { width: auto; flex: 1; }
.login-prompt { font-size: 0.82rem; color: var(--text-muted); padding-top: 0.65rem; }

/* ── Home feed ───────────────────────────────────────────────────────────── */
.home-feed-section {
  margin-top: 0;
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}
body.app-shell .app-main-well > main:has(.home-feed-section) {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
body.app-shell .app-main-well > main:has(.home-feed-section)::-webkit-scrollbar {
  display: none;
}

.feed-toolbar {
  margin-top: 0;
  margin-bottom: 0.85rem;
  letter-spacing: normal;
  padding-bottom: 0.35rem;
}
.feed-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.65rem;
}
.feed-toolbar-top .page-title {
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.feed-toolbar-top .feed-new-post {
  flex-shrink: 0;
  margin-left: auto;
}
.feed-toolbar-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
}
.feed-toolbar-bottom .feed-post-count {
  flex: 1 1 auto;
  min-width: 0;
}
.feed-post-count {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.feed-explore-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
.feed-sort-pills {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-page);
}
.feed-sort-pill {
  font-family: var(--main-font);
  font-size: 0.78rem;
  padding: 0.38rem 0.75rem;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  min-height: 2.125rem;
  box-sizing: border-box;
}
.feed-sort-pill:last-child { border-right: none; }
.feed-sort-pill:hover { background: rgba(156, 186, 228, 0.12); color: var(--text); }
.feed-sort-pill.is-active {
  background: rgba(156, 186, 228, 0.22);
  color: var(--accent);
  font-weight: 600;
}
.feed-filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: 0.35rem;
  min-height: 2.125rem;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: var(--main-font);
  line-height: 1.25;
  letter-spacing: 0.02em;
  box-sizing: border-box;
}
.feed-filter-label { font-weight: 600; }
.feed-filter-icon { flex-shrink: 0; opacity: 0.9; }
.feed-filter-trigger:hover,
.feed-filter-trigger.is-open {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: rgba(156, 186, 228, 0.1);
}

.feed-filter-panel {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(254, 254, 254, 0.95);
  letter-spacing: normal;
}
.feed-filter-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}
.feed-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin-bottom: 0.85rem;
  max-height: 12rem;
  overflow-y: auto;
}
.feed-tag-chip {
  font-family: var(--main-font);
  font-size: 0.8rem;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
}
.feed-tag-chip.is-selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(156, 186, 228, 0.15);
  font-weight: 600;
}
.feed-filter-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.home-feed { display: flex; flex-direction: column; }
#feed-posts > .empty-state { min-height: 6rem; display: flex; align-items: center; justify-content: center; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer.muted-footer {
  margin-top: 1.5rem;
  padding: 1.25rem 1rem 2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.site-footer.muted-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer.muted-footer a:hover { color: var(--text); }
.footer-sep { margin: 0 0.5rem; opacity: 0.7; }

/* ── FAQ ─────────────────────────────────────────────────────────────────── */
.faq-list { max-width: 40rem; margin: 1rem 0 0; letter-spacing: normal; }
.faq-list dt { font-weight: 600; color: var(--text-title); margin-top: 1rem; }
.faq-list dd { margin: 0.35rem 0 0; color: var(--text-muted); line-height: 1.55; }
.faq-list dd > p {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
}
.faq-list dd > p:last-child {
  margin-bottom: 0;
}
.faq-list dd ol {
  margin: 0;
  padding-left: 1.35rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.faq-list dd ol li {
  margin: 0 0 0.55rem;
  padding-left: 0.25rem;
}
.faq-list dd ol li:last-child {
  margin-bottom: 0;
}
.faq-list dd ol li strong {
  color: var(--text-title);
  font-weight: 600;
}

/* ── Post detail page ────────────────────────────────────────────────────── */
.post-detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-link { font-size: 0.84rem; color: var(--text-muted); text-decoration: none; letter-spacing: normal; }
.back-link:hover { color: var(--text); }

.post-full { flex: 1; min-height: 0; }

.post-conservatory-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.post-conservatory-link { color: #4a8c2a; text-decoration: none; font-weight: 600; }
.post-conservatory-link:hover { color: #3a7a24; }
.post-conservatory-path { font-variant-numeric: tabular-nums; opacity: 0.7; }

.post-full-title {
  font-family: var(--heading-font);
  font-size: 1.5rem;
  color: var(--text-title);
  margin-bottom: 0.35rem;
  line-height: 1.25;
}

.post-tags-below-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0 0.5rem;
  letter-spacing: normal;
}
.post-tags-below-title[hidden] {
  display: none !important;
}

.post-edit-blurb {
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}
.post-edit-blurb[hidden] {
  display: none !important;
}

.post-full-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: normal;
}
.post-full-meta .author-link { font-weight: 600; }

.post-full-body { margin-top: 1.25rem; margin-bottom: 1.5rem; }

.comments-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid rgba(39, 92, 157, 0.2);
}

.comment-textarea {
  width: 100%;
  min-height: 3rem;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--main-font);
  resize: none;
  overflow-y: hidden;
  field-sizing: content;
}

.comment-body.md { letter-spacing: normal; }
.comment-body.md .katex,
.post-full-body.md .katex { font-size: 1em; }

.comment-form-actions { margin-top: 0.4rem; display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.comment-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
}
.comment-meta-main { min-width: 0; }
.comment-meta-actions { flex-shrink: 0; margin-left: 0.35rem; }

.comment.comment-pending {
  opacity: 0.78;
  border-left: 2px solid rgba(139, 148, 158, 0.45);
  padding-left: 0.45rem;
  margin-left: 0;
}

.comment-reply-to { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.35rem; letter-spacing: normal; }

.comment-reply-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
  background: rgba(156, 186, 228, 0.12);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  letter-spacing: normal;
}

.open-post-btn { font-size: 0.78rem; padding: 0.2rem 0.6rem; letter-spacing: normal; }

/* ── Admin page ──────────────────────────────────────────────────────────── */
body.app-shell.admin-page .app-main-well > main {
  padding: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-panel { padding: 2rem; height: 100%; letter-spacing: normal; min-width: 0; }
body.admin-page .admin-panel > div[id^="section-"] {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.admin-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-header h2 { margin-bottom: 0; }

.admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.87rem;
}
.admin-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid rgba(48,54,61,0.5); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }

.admin-actions-cell { vertical-align: middle; text-align: right; white-space: nowrap; }
.admin-actions-cell.admin-actions-empty { text-align: center; }
.admin-actions-cell.admin-actions-empty .admin-actions-dash { display: inline-block; width: 100%; }
.admin-username { font-weight: 500; color: var(--text-title); }
.admin-actions { display: flex; gap: 0.4rem; align-items: center; }

.admin-ip-cell { font-size: 0.78rem; vertical-align: middle; max-width: 9rem; word-break: break-all; }
.admin-ip { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.78rem; letter-spacing: 0.02em; color: var(--text-muted); }
.admin-ip-empty { font-style: italic; }

.admin-tier-wrap { display: inline-block; min-width: 7.5rem; }
.admin-tier-select { font: inherit; font-size: 0.8rem; color: var(--text); background: var(--bg-page); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.2rem 0.35rem; max-width: 10rem; }

.admin-dropdown {
  position: relative;
  display: inline-block;
  text-align: left;
}
.admin-dropdown summary.admin-dropdown-summary { list-style: none; cursor: pointer; user-select: none; }
.admin-dropdown summary.admin-dropdown-summary::-webkit-details-marker { display: none; }

/* Position set in admin.html. While [open], keep off-screen + hidden until JS sets final coords (avoids in-flow flash). */
.admin-dropdown-panel {
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(39, 92, 157, 0.18);
}
details.admin-dropdown[open] > .admin-dropdown-panel {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  inset: auto;
  top: 0;
  left: -10000px;
  z-index: 15000;
}

.admin-dropdown-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: normal;
  text-align: left;
  cursor: pointer;
  font-family: var(--main-font, inherit);
}
.admin-dropdown-item:hover { background: rgba(156, 186, 228, 0.12); }
.admin-dropdown-item-danger { color: #f85149; }
.admin-dropdown-item-danger:hover { background: rgba(248, 81, 73, 0.12); }

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.admin-section-header:hover h2 { color: var(--text); }
.admin-section-header h2 { margin-bottom: 0; font-size: 1.1rem; transition: color 0.15s; }

.admin-section-meta { display: flex; align-items: center; gap: 0.75rem; }
.admin-chevron { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
.admin-chevron.collapsed { transform: rotate(-90deg); }

/* ── Role / tier badges (shared: userlist, profile, admin — use .role-badge, not .tag) ── */
.profile-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.35rem;
}
.profile-title-row .page-title {
  margin-bottom: 0;
}
.profile-role-inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.profile-edit-profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}
.profile-edit-profile-btn:hover,
.profile-edit-profile-btn:focus-visible {
  color: var(--accent);
  background: rgba(156, 186, 228, 0.12);
}
.profile-role-row { margin: 0.25rem 0 0.6rem; }

.profile-edit-panel {
  margin: 0.5rem 0 1rem;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--border);
  letter-spacing: normal;
}
.profile-edit-field { margin-bottom: 0.75rem; }
.profile-edit-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.profile-username-input {
  width: 100%;
  max-width: 22rem;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--main-font);
  font-size: 0.95rem;
}
.profile-edit-error {
  color: var(--danger);
  font-size: 0.82rem;
  letter-spacing: normal;
}

.role-badge {
  display: inline-block;
  font-family: var(--main-font);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: rgba(156, 186, 228, 0.12);
  white-space: nowrap;
  line-height: 1.35;
}

.role-badge.role-owner {
  border-color: #b8983a;
  color: #6b5a24;
  background: rgba(232, 210, 120, 0.45);
}

.role-badge.role-tier-member {
  border-color: rgba(90, 111, 138, 0.45);
  color: var(--text-muted);
  background: rgba(90, 111, 138, 0.1);
}

.role-badge.role-tier-gardener {
  border-color: #5a8f6a;
  color: #2d6a3e;
  background: rgba(45, 106, 62, 0.08);
}

/* Vibrant deep ocean blue */
.role-badge.role-tier-admin {
  border-color: #0096c7;
  color: #023e8a;
  background: linear-gradient(180deg, rgba(0, 180, 216, 0.28) 0%, rgba(0, 119, 182, 0.2) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* ── Auth page ───────────────────────────────────────────────────────────── */
@keyframes auth-screen-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.auth-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 0; /* no header on auth page */
}

body.auth-page header {
  display: none;
}

body.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(254, 254, 254, 0.72) 0%, rgba(246, 249, 252, 0.65) 50%, rgba(255, 255, 255, 0.78) 100%),
    url('/images/lake.jpg') center / cover no-repeat;
}

body.auth-page .auth-screen { text-align: center; flex: 1 1 auto; min-height: 0; animation: auth-screen-fade-in 0.7s ease-out both; }

body.auth-page .site-footer.muted-footer.auth-footer {
  margin-top: 0;
  padding-top: 0.5rem;
  padding-bottom: 1.75rem;
  flex-shrink: 0;
}

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 5rem 1rem 2rem;
}

body.auth-page img.auth-logo {
  opacity: 1;
  user-select: none;
  -webkit-user-drag: none;
  width: auto;
  max-width: min(320px, 92vw);
  height: auto;
}

.opacityContent, .opacityContent2 { opacity: 1; }
.opacityContent2 p { margin-bottom: 2px; }

#auth-intro {
  font-family: var(--heading-font);
  font-weight: normal;
  font-size: 30px;
  letter-spacing: 0.12em;
  color: var(--text-title);
  margin-top: 30px;
  margin-bottom: -10px;
}

.auth-hr {
  border-color: var(--text);
  display: inline-block;
  width: 340px;
  border-style: solid;
  border-bottom: 0;
  box-shadow: none;
}

.auth-text {
  background-color: #c9d1d9;
  height: 22px;
  text-align: center;
  margin-bottom: 12px;
  transition: background-color 0.5s ease-out;
  width: 170px;
  border: 2px solid transparent;
  color: #0d1117;
  font-family: var(--main-font);
  letter-spacing: 2px;
}
.auth-text::placeholder {
  color: #6b7f96;
  opacity: 1;
}
.auth-text:hover { background-color: #b8c4d4; }
.auth-text:focus { background-color: rgba(156, 186, 228, 0.35); outline: none; box-shadow: none; border: 2px solid var(--text); }

.auth-button {
  color: #5f6f84;
  background-color: transparent;
  width: 100px;
  cursor: pointer;
  padding-left: 12px;
  padding-top: 2px;
  padding-bottom: 2px;
  letter-spacing: 8px;
  transition: color 0.5s ease-out, border-color 0.5s ease-out;
  text-align: center;
  border-radius: var(--radius-sm);
  border: 2px solid #5f6f84;
  line-height: 16px;
  margin-top: 12px;
  margin-bottom: 40px;
  font-family: var(--main-font);
  font-size: 0.8rem;
}
.auth-button:hover { color: var(--text); border-color: var(--text); background: rgba(156, 186, 228, 0.1); }

/* ── Users list / profile (scroll inside main) ───────────────────────────── */
body.app-shell .app-main-well > main:has(.userlist-wrap) {
  overflow-y: auto;
}

body.app-shell .app-main-well > main:has(.profile-wrap) {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
body.app-shell .app-main-well > main:has(.profile-wrap)::-webkit-scrollbar {
  display: none;
}

.userlist-wrap,
.profile-wrap {
  letter-spacing: normal;
  max-width: 920px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.page-title {
  font-family: var(--heading-font);
  color: var(--text-title);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.page-lead {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.userlist-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.userlist-header .page-lead {
  margin-bottom: 0;
}

.users-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.users-list > li.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.users-list-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.users-list-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  letter-spacing: normal;
  min-width: 0;
  min-height: 100%;
  text-decoration: none !important;
  color: inherit;
  box-sizing: border-box;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.users-list-card:hover,
.users-list-card:focus-visible {
  text-decoration: none !important;
}
.users-list-card * {
  text-decoration: none;
}
.users-list-card:hover {
  border-color: rgba(156, 186, 228, 0.65);
  background: rgba(156, 186, 228, 0.06);
}
.users-list-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.users-list-nameblock {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.65rem;
  min-width: 0;
}
.users-list-name { font-weight: 600; color: var(--accent); }
.users-list-roles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.users-list-right {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(174, 186, 201, 0.55);
}

.users-list-stats {
  display: grid;
  grid-template-columns: 1fr minmax(2.25rem, max-content);
  column-gap: 0.5rem;
  row-gap: 0.1rem;
  font-size: 0.78rem;
  line-height: 1.25;
  align-items: baseline;
  justify-items: start;
}

.users-list-stat-label {
  justify-self: start;
  text-align: left;
  color: var(--text-muted);
}

.users-list-stat-value {
  justify-self: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-title);
  min-width: 2.25rem;
}

.users-list-joined {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  text-align: left;
}

.users-list-joined time {
  font-variant-numeric: tabular-nums;
}

.profile-posts-heading { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; letter-spacing: 0.03em; }

/* ── User bio ────────────────────────────────────────────────────────────── */
.profile-bio {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.profile-bio-edit { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }

.profile-bio-textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  font-family: var(--main-font);
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.5;
}

.profile-bio-actions { display: flex; gap: 0.5rem; }

.profile-stat-row {
  display: flex;
  gap: 1.25rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.profile-stat-row strong { color: var(--text); }

/* ── Conservatory page ───────────────────────────────────────────────────── */
body.app-shell .app-main-well > main:has(.conservatory-wrap) {
  overflow-y: auto;
}

.conservatory-wrap {
  letter-spacing: normal;
  max-width: 920px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-top: 0;
}

.conservatory-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.conservatory-header .page-lead:last-child {
  margin-bottom: 0;
}
.conservatory-garden-hint { color: var(--text-muted); max-width: 42rem; margin-left: auto; margin-right: auto; }

/* ── About (narrow column, left-aligned; centered horizontally only) ───── */
.about-page {
  letter-spacing: normal;
  width: min(32rem, 100%);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  text-align: left;
}

.about-page .page-title {
  margin-bottom: 0.85rem;
  text-align: left;
}

.about-page-body {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.65;
  text-align: left;
}

.about-page-body p {
  margin: 0 0 1rem;
  text-align: left;
}
.about-page-body p:last-child {
  margin-bottom: 0;
}

.cons-outline-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(39, 92, 157, 0.16);
  z-index: 1500;
}
.cons-outline-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(85vh, 640px);
  overflow: auto;
  padding: 1.25rem 1.35rem;
  background: var(--bg-page);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(39, 92, 157, 0.12);
  z-index: 1510;
  letter-spacing: normal;
}
.cons-outline-title {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
  font-family: var(--heading-font);
  color: var(--text-title);
}
.cons-outline-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  line-height: 1.45;
}
.cons-outline-help code { font-size: 0.76rem; }
.cons-outline-text {
  width: 100%;
  min-height: 260px;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  resize: vertical;
}
.cons-outline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.toc-outline-hit {
  flex: 0 0 12px;
  min-height: 1.4rem;
  align-self: stretch;
  cursor: cell;
}
.conservatory-toc.garden-mode .toc-outline-hit:hover {
  background: rgba(156, 186, 228, 0.22);
}
.toc-pending-inner {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}
.toc-pending .toc-title { color: var(--accent); font-weight: 600; }
.toc-pending-actions { flex-shrink: 0; }

.toc-entry-filled .toc-title { color: var(--text-title); font-weight: 600; }
.toc-entry-empty .toc-title { color: var(--text-muted); }
.toc-entry-empty .toc-path { opacity: 0.75; }

.toc-kebab-wrap { position: relative; flex-shrink: 0; margin-left: auto; }
.toc-kebab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.toc-kebab-btn:hover {
  color: var(--accent);
  background: rgba(156, 186, 228, 0.1);
}
.toc-kebab-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.1rem;
  min-width: 10rem;
  padding: 0.2rem 0;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(39, 92, 157, 0.1);
  z-index: 60;
}
.toc-kebab-dropdown.open { display: block; }
.toc-kebab-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.65rem;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-family: var(--main-font);
  color: var(--text);
  cursor: pointer;
}
.toc-kebab-item:hover { background: rgba(156, 186, 228, 0.1); }
.toc-kebab-item.danger { color: var(--danger); }

.conservatory-toc .toc-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.conservatory-toc .toc-item-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  box-sizing: border-box;
}
.conservatory-toc.garden-mode .toc-item-row {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}
.conservatory-toc.garden-mode .toc-item-row .toc-link {
  flex: 1;
  min-width: 0;
}
.conservatory-toc ul.toc-children {
  width: 100%;
  box-sizing: border-box;
}
/* ── Post page in-place editor ───────────────────────────────────────────── */
.post-edit-title-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--heading-font);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-title);
  line-height: 1.25;
  margin-bottom: 0.35rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
}
.post-edit-title-input[hidden] { display: none !important; }
.post-edit-body {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 14rem;
  margin-top: 1.25rem;
  margin-bottom: 1.5rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  line-height: 1.5;
  font-family: var(--main-font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text);
  resize: vertical;
}
.post-edit-body[hidden] { display: none !important; }
.post-edit-tags-row {
  margin: 0.35rem 0 0.5rem;
  letter-spacing: normal;
}
.post-edit-tags-row[hidden] {
  display: none !important;
}
.post-edit-tags-row label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.post-edit-tags-row input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--main-font);
  font-size: 0.9rem;
}
.post-view-meta[hidden] {
  display: none !important;
}
.post-edit-toolbar {
  margin-top: 1rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
  letter-spacing: normal;
}
.post-edit-toolbar[hidden] { display: none !important; }
.post-full-title[hidden] { display: none !important; }
.post-full-body[hidden] { display: none !important; }
.page-title-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .25rem; }
.page-title-row .page-title { margin-bottom: 0; }

.conservatory-toc { list-style: none; padding: 0; margin: 0; }
.conservatory-toc ul.toc-children { list-style: none; padding: 0; margin: 0; }

.toc-item { border-bottom: 1px solid var(--border); }
.toc-item:last-child { border-bottom: none; }
.toc-section-only > .toc-children > .toc-item:last-child { border-bottom: 1px solid var(--border); }

nav.conservatory-toc li.toc-item {
  border-bottom: none;
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0;
  text-decoration: none;
  color: var(--text);
  transition: color 0.1s;
}
.toc-link:hover { color: var(--accent); }

.toc-path {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
}
.toc-title { font-size: 0.95rem; flex: 1; }
.toc-section-only { padding: 0.5rem 0 0; }
.toc-section-only .toc-path { font-size: 0.78rem; color: var(--text-muted); }

.toc-depth-1 > .toc-item-row .toc-link { font-weight: 600; font-size: 1rem; padding-top: 0.9rem; padding-bottom: 0.5rem; }
.toc-depth-2 > .toc-item-row .toc-link { padding-left: 1.25rem; }
.toc-depth-3 > .toc-item-row .toc-link { padding-left: 2.5rem; font-size: 0.88rem; color: var(--text-muted); }
.toc-depth-3 > .toc-item-row .toc-link:hover { color: var(--accent); }

/* ── Virtual keyboard ────────────────────────────────────────────────────── */
/* --kb-height is set by JS; chat input area lifts above keyboard */
