@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: 150ms ease-out both vt-fade-out;
}

::view-transition-new(root) {
  animation: 150ms ease-in both vt-fade-in;
}

@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

:root {
  --bg: #ffffff;
  --ink: #121212;
  --muted: #6a6a6a;
  --line: #b7b7b7;
  --accent: #c1121f;
  --card: #ffffff;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Georgia", "Times New Roman", serif;
  --header-serif: "Garamond", "Baskerville", "Didot", "Times New Roman", serif;
  --mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background-color: var(--bg);
  overflow-x: hidden;
}

body.theme-dark {
  --bg: #121212;
  --ink: #f5f5f5;
  --muted: #b0b0b0;
  --line: #3f3f3f;
  --card: #1a1a1a;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

:root {
  --sidebar-w: 220px;
  --sidebar-w-collapsed: 64px;
  --header-h: 60px;
  --corner: 14px;
}

/* ── Content panel: nestled into the header/sidebar corner ──────────────── */
.page {
  margin-top: var(--header-h);
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: margin-left 0.2s ease;
}

/* The framing border + rounded inner corner is a FIXED overlay pinned to the
   header/sidebar intersection, so it stays put while the content scrolls
   beneath it (rather than scrolling away with .page). */
.page::before {
  content: "";
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-top-left-radius: var(--corner);
  pointer-events: none;
  z-index: 5;
  transition: left 0.2s ease;
}

body.sidebar-collapsed .page {
  margin-left: var(--sidebar-w-collapsed);
}

body.sidebar-collapsed .page::before {
  left: var(--sidebar-w-collapsed);
}

body.no-chrome .page {
  margin: 0;
  min-height: 100vh;
}

body.no-chrome .page::before {
  display: none;
}

body.no-chrome .site-header {
  display: none;
}

/* ── Global sidebar (sits below the header) ─────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  z-index: 20;
  overflow: hidden;
  transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 32px;
  margin-bottom: 12px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--ink);
  flex: 0 0 auto;
}

.logo-mark svg {
  width: 100%;
  height: 100%;
}

.logo-bird {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sidebar-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex: 0 0 auto;
  transition: color 0.15s ease;
}

.sidebar-toggle:hover {
  color: var(--accent);
}

.sidebar-toggle .nav-icon {
  transition: transform 0.2s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--header-serif);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-item:hover,
.nav-item:focus {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-section {
  margin-top: 16px;
}

.nav-section-label {
  font-family: var(--header-serif);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
  padding: 0 12px 6px;
}

.nav-section-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Collapsed: icons only. */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
}

body.sidebar-collapsed .nav-label {
  display: none;
}

body.sidebar-collapsed .sidebar-top {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-toggle .nav-icon {
  transform: rotate(180deg);
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}

/* Collapsed: hide section labels and group each section's icons in a hairline box. */
body.sidebar-collapsed .nav-section {
  margin-top: 12px;
}

body.sidebar-collapsed .nav-section-label {
  display: none;
}

body.sidebar-collapsed .nav-section-items {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0px 0;
}

/* ── Top header (full width): logo + theme toggle ───────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 30;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--header-serif);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 20px;
  color: var(--ink);
  min-width: 0;
}

.header-brand:hover,
.header-brand:focus {
  color: var(--accent);
  text-decoration: none;
}

.header-brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-spacer {
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  border: 0;
  background: transparent;
  padding: 4px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: color 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus {
  color: var(--accent);
}

.theme-toggle-icon {
  width: 20px;
  height: 20px;
  display: block;
}

/* ── Notifications bell + dropdown ───────────────────────────────────────── */
.notif {
  position: relative;
  display: inline-flex;
}

.notif-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  transition: color 0.15s ease;
}

.notif-toggle:hover,
.notif-toggle:focus {
  color: var(--accent);
}

.notif-toggle svg {
  width: 21px;
  height: 21px;
}

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--bg);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 60;
  padding: 6px 0;
}

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}

.notif-panel-title {
  font-family: var(--header-serif);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 13px;
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

a.notif-item-inner:hover .notif-item-text {
  color: var(--accent);
}

.notif-item-text {
  font-size: 14px;
  color: var(--muted);
}

.notif-item.is-unread .notif-item-text {
  color: var(--ink);
  font-weight: 600;
}

.notif-item.is-unread {
  border-left: 2px solid var(--accent);
  padding-left: 12px;
}

.notif-item-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.notif-empty {
  margin: 0;
  padding: 16px 14px;
  color: var(--muted);
  font-size: 14px;
}

.header-profile,
.header-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--ink);
  transition: color 0.15s ease;
}

.header-profile svg,
.header-help svg {
  width: 21px;
  height: 21px;
}

.header-profile:hover,
.header-profile:focus,
.header-help:hover,
.header-help:focus {
  color: var(--accent);
}

.theme-icon-sun {
  display: none;
}

body.theme-dark .theme-icon-sun {
  display: block;
}

body.theme-dark .theme-icon-moon {
  display: none;
}

main {
  flex: 1;
  width: 100%;
  padding: 40px clamp(20px, 4vw, 48px) 56px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

.page-title {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.04em;
  margin: 0 0 6px;
}

.page-lead {
  margin: 0 0 40px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  max-width: 640px;
}

.footer {
  padding: 24px clamp(20px, 4vw, 48px) 40px;
  font-size: 14px;
  color: var(--muted);
}

.footer-inner {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}

.footer-text {
  justify-self: start;
}

.back-to-top {
  justify-self: center;
  border: 0;
  background: none;
  font-family: var(--header-serif);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
}

.back-to-top:hover,
.back-to-top:focus {
  color: var(--accent);
}

.footer-links {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover,
.footer-links a:focus {
  color: var(--accent);
}

/* ── Shared components ──────────────────────────────────────────────────── */

.btn-text {
  font-family: var(--header-serif);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 14px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s ease;
}

.btn-text:hover {
  color: var(--accent);
}

.btn-solid {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--bg);
  background: var(--ink);
  border: none;
  border-radius: 4px;
  padding: 9px 20px;
  cursor: pointer;
}

.btn-solid:hover {
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 35%, transparent));
}

.input {
  padding: 9px 12px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  width: 100%;
}

.input:focus {
  border-color: var(--ink);
}

.divider {
  border: 0;
  border-top: 1px solid var(--line);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Phones keep the SAME layout (persistent sidebar + chevron toggle); they just
   default to the collapsed icon rail (see the pre-paint script) and use a
   slightly narrower expanded width to stay space-efficient. */
@media (max-width: 600px) {
  :root {
    --sidebar-w: 200px;
  }

  .site-header {
    padding: 0 16px;
  }

  .header-actions {
    gap: 8px;
  }

  main {
    padding: 28px 16px 48px;
  }

  .footer {
    padding: 24px 16px 32px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .footer-text,
  .footer-links {
    justify-self: center;
  }

  /* Slightly smaller type on phones, across the shared reading surfaces. */
  .page-title { font-size: clamp(24px, 6vw, 30px); }
  .page-lead { font-size: 14px; }
  .section-title { font-size: 16px; }
  .input,
  .note-body-input,
  .note-title-input,
  .anniv-description,
  .date-description,
  .wall-composer-input { font-size: 14px; }
  .post-body { font-size: 15px; }
  .comment { font-size: 14px; }
  .note-item-title,
  .anniv-item-title { font-size: 15px; }
  .date-card-title { font-size: 17px; }
  .date-card-desc { font-size: 14px; }
  .nav-item { font-size: 13px; }
  .notif-item-text { font-size: 13px; }
}
