/* ---------- OSR typography theme ---------- */

:root {
  --paper: #f5ecd7;
  --paper-dim: #ebe0c4;
  --ink: #2a1f14;
  --ink-soft: #5c4a35;
  --ink-muted: #7a6648;
  --rule: #8b2e2e;
  --rule-dark: #621f1f;
  --border: #a89873;
  --border-soft: #c7b992;
  --accent-green: #3a5a30;
  --accent-blue: #2a4a6a;
  --text-col: min(86ch, 100%);
  --wide-col: min(1500px, 100%);
  --sidebar-w: 280px;
}

@font-face {
  font-family: "Alegreya Sans";
  src: local("Alegreya Sans"),
       url("/static/fonts/alegreya-sans-regular.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
}
@font-face {
  font-family: "Alegreya Sans";
  src: local("Alegreya Sans Italic"),
       url("/static/fonts/alegreya-sans-italic.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
  font-style: italic;
}
@font-face {
  font-family: "Alegreya Sans SC";
  src: local("Alegreya Sans"),
       url("/static/fonts/alegreya-sans-regular.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Alverta";
  src: local("Alverta Bold"),
       url("/static/fonts/alverta-bold.woff2") format("woff2");
  font-display: swap;
  font-weight: 700;
}
@font-face {
  font-family: "The Antiqua";
  src: local("The Antiqua"),
       url("/static/fonts/the-antiqua-regular.woff2") format("woff2");
  font-display: swap;
  font-weight: 400;
}
@font-face {
  font-family: "The Antiqua";
  src: local("The Antiqua Italic"),
       url("/static/fonts/the-antiqua-italic.woff2") format("woff2");
  font-display: swap;
  font-style: italic;
}
@font-face {
  font-family: "The Antiqua";
  src: local("The Antiqua Bold"),
       url("/static/fonts/the-antiqua-bold.woff2") format("woff2");
  font-display: swap;
  font-weight: 700;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "The Antiqua", "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.6;
}

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

/* ---------- Layout ---------- */

.site-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--paper-dim);
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
  padding: 1.4rem 1rem 2rem;
}

.sidebar-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;
}
.site-title {
  font-family: "Alegreya Sans SC", "Alegreya Sans", "Cinzel", Georgia, serif;
  font-size: 1.3rem;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.site-title:hover { text-decoration: none; color: var(--rule); }

.sidebar-nav { font-size: 0.92rem; }
.tree, .tree ul {
  list-style: none;
  padding-left: 0.9rem;
  margin: 0;
}
.tree > li { list-style: none; }
.tree-item { padding: 1px 0; }
.tree-item > a {
  color: var(--ink-soft);
  display: inline-block;
  padding: 1px 0;
}
.tree-item > a:hover { color: var(--rule); }
.tree-item > a.current {
  color: var(--rule-dark);
  font-weight: bold;
  background: var(--paper);
  border-left: 3px solid var(--rule);
  padding-left: 0.4em;
  margin-left: -0.7em;
}
.tree-item > a.pdf-link::before {
  content: "\1F4D6"; /* 📖 */
  font-size: 0.85em;
  margin-right: 0.35em;
  opacity: 0.7;
}
.tree-group {
  font-family: "Alegreya Sans SC", "Alegreya Sans", serif;
  color: var(--ink-muted);
  font-variant: small-caps;
  letter-spacing: 0.04em;
  font-size: 0.88em;
}
.tree-branch > details > summary > .tree-group {
  color: var(--ink);
}

/* Collapsible folder sections */
.tree-branch > details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  padding: 1px 0;
  user-select: none;
}
.tree-branch > details > summary::-webkit-details-marker { display: none; }
.tree-branch > details > summary::before {
  content: "\25B8"; /* ▸ right-pointing small triangle */
  color: var(--ink-muted);
  font-size: 0.8em;
  transition: transform 120ms ease;
  display: inline-block;
  flex-shrink: 0;
  width: 0.8em;
  text-align: center;
}
.tree-branch > details[open] > summary::before {
  transform: rotate(90deg);
}
.tree-branch > details > summary:hover::before {
  color: var(--rule);
}
.tree-branch > details > summary > a,
.tree-branch > details > summary > .tree-group {
  flex: 1;
}

.content {
  flex: 1;
  padding: 1.8rem clamp(1rem, 3vw, 3rem) 4rem;
  min-width: 0;
  max-width: var(--wide-col);
  margin: 0 auto;
  width: 100%;
}

.note {
  margin: 0 auto;
  max-width: var(--wide-col);
}

.note-body { max-width: 100%; }

/* Center the note header (h1) in the text column */
.note-header {
  max-width: var(--text-col);
  margin-left: auto;
  margin-right: auto;
}

/* Text children are capped to readable width */
.note-body > p,
.note-body > ul,
.note-body > ol,
.note-body > dl,
.note-body > blockquote,
.note-body > h1,
.note-body > h2,
.note-body > h3,
.note-body > h4,
.note-body > h5,
.note-body > h6,
.note-body > hr,
.note-body > pre,
.note-body > aside.statblock,
.home-body > p,
.home-body > ul,
.home-body > ol {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--text-col);
}

/* Wide media fills the full content column */
.note-body > .leaflet-wrap,
.note-body > figure,
.note-body > table,
.note-body > img,
.home-body > .leaflet-wrap,
.note-body > .map-container,
.home-body > .map-container {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--wide-col);
}

.breadcrumbs {
  max-width: var(--text-col);
  margin: 0 auto 1.2rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
}
.breadcrumbs a { color: var(--ink-muted); }
.breadcrumbs a:hover { color: var(--rule); }
.bc-sep { margin: 0 0.4em; color: var(--border); }

/* ---------- Typography ---------- */

h1, h2, h3, h4, h5, h6 {
  font-family: "Alegreya Sans SC", "Alegreya Sans", "Cinzel", Georgia, serif;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 1.6em 0 0.5em;
}
h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  padding-bottom: 0.25em;
  border-bottom: 2px solid var(--rule);
  margin-top: 0;
}
h2 {
  font-size: 1.55rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.15em;
}
h3 { font-size: 1.25rem; color: var(--rule-dark); }
h4 { font-size: 1.08rem; font-variant: small-caps; letter-spacing: 0.05em; }

.heading-anchor {
  color: var(--border);
  text-decoration: none;
  margin-left: 0.35em;
  opacity: 0;
  transition: opacity 120ms ease;
  font-size: 0.8em;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor { opacity: 1; }

p, ul, ol { margin: 0.6em 0; }

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

blockquote {
  border-left: 3px solid var(--border);
  color: var(--ink-soft);
  margin: 1em 0;
  padding: 0.2em 0 0.2em 1em;
  font-style: italic;
}

blockquote.transclusion {
  border-left: 3px double var(--rule);
  background: var(--paper-dim);
  padding: 0.8em 1.2em;
  font-style: normal;
}
.transclusion-title {
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6em;
  padding-bottom: 0.2em;
}

code {
  background: var(--paper-dim);
  padding: 0.1em 0.3em;
  border: 1px solid var(--border-soft);
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}
pre {
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink-muted);
  padding: 0.8em;
  overflow-x: auto;
}
pre code { background: transparent; border: none; padding: 0; }

/* ---------- Tables ---------- */

table {
  border-collapse: collapse;
  margin: 1.2em 0;
  width: 100%;
  max-width: 100%;
  background: var(--paper-dim);
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
}
th, td {
  padding: 0.45em 0.7em;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
}
th {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-weight: normal;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
}
tbody tr:last-child td { border-bottom: none; }

/* Dice tables use the same style but with a narrow first column */
table th:first-child, table td:first-child {
  text-align: center;
  white-space: nowrap;
  color: var(--rule-dark);
  font-family: "The Antiqua", Georgia, serif;
  width: 4.5em;
}

/* ---------- Statblock ---------- */

aside.statblock {
  background: var(--paper-dim);
  border-top: 4px double var(--ink);
  border-bottom: 4px double var(--ink);
  padding: 1em 1.2em;
  margin: 1.2em 0;
  font-size: 0.96em;
}
.stat-name {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 1.4em;
  color: var(--rule-dark);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.3em;
  padding-bottom: 0.15em;
}
.stat-meta {
  font-style: italic;
  color: var(--ink-muted);
  margin-bottom: 0.5em;
}
.stat-header {
  border-bottom: 1px solid var(--border);
  padding: 0.2em 0;
  margin-bottom: 0.4em;
}
.stat-header .hd { color: var(--ink-muted); }
.stat-saves {
  display: flex;
  gap: 0.8em;
  flex-wrap: wrap;
  margin: 0.4em 0;
  padding: 0.2em 0 0.4em;
  border-bottom: 1px solid var(--border-soft);
}
.save-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
}
.save-label {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--ink-muted);
  font-size: 0.9em;
}
.save-val {
  font-weight: bold;
  color: var(--ink);
}
.stat-line { margin: 0.15em 0; }
.stat-label {
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-right: 0.3em;
}
.stat-section {
  margin-top: 0.6em;
  padding-top: 0.3em;
  border-top: 1px solid var(--border-soft);
}
.stat-section-title {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  color: var(--rule-dark);
  font-size: 1em;
  margin: 0 0 0.3em;
  border: none;
}
.stat-action { margin: 0.3em 0; }
.stat-action-name {
  font-style: italic;
  color: var(--ink);
  font-weight: bold;
}

/* ---------- Map wrap ---------- */

.leaflet-wrap {
  margin: 1.2em auto;
  max-width: var(--wide-col);
  width: 100%;
}
.leaflet-missing {
  background: var(--paper-dim);
  border: 1px dashed var(--rule);
  padding: 1em;
  color: var(--rule-dark);
  font-style: italic;
}

/* ---------- Home ---------- */

.home-page .content { padding: 1rem 1.2rem 2rem; }
.home-hero {
  text-align: center;
  padding: 1rem 0 0.5rem;
  border-bottom: 2px double var(--rule);
  margin-bottom: 1rem;
}
.home-title {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 2.8rem;
  border: none;
  padding: 0;
  margin: 0;
}
.home-subtitle {
  font-family: "The Antiqua", Georgia, serif;
  font-style: italic;
  color: var(--ink-muted);
  margin: 0.2em 0 0.6em;
}
.home-body .map-container { min-height: 78vh; }
.home-link {
  text-align: center;
  color: var(--ink-muted);
  margin-top: 1em;
}

/* ---------- Two-column NPC / location layout ---------- */

.npc-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 32%);
  gap: 1.6em;
  margin: 1em 0;
  align-items: start;
}
.npc-layout-text > *:first-child { margin-top: 0; }
.npc-layout-text > p,
.npc-layout-text > ul,
.npc-layout-text > ol,
.npc-layout-text > blockquote,
.npc-layout-text > h1,
.npc-layout-text > h2,
.npc-layout-text > h3,
.npc-layout-text > h4 {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}
.npc-layout-img { grid-column: 2; grid-row: 1; }
.npc-layout-img img,
.npc-layout-img > p img {
  width: 100%;
  height: auto;
  margin: 0;
  border: 1px solid var(--border);
}
.npc-layout-img > p { margin: 0; }

@media (max-width: 720px) {
  .npc-layout { grid-template-columns: 1fr; }
  .npc-layout-img { grid-column: 1; grid-row: auto; }
}

/* ---------- Calendar month grid ---------- */

.calendar-month {
  margin: 1.2em 0;
}
.cal-month-title {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  color: var(--rule-dark);
  border-bottom: 2px double var(--rule);
  padding-bottom: 0.2em;
  margin-bottom: 0.6em;
  text-align: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--ink);
  border: 2px solid var(--ink);
}
.cal-weekday {
  background: var(--paper-dim);
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 0.4em 0.3em;
  font-size: 0.92rem;
  color: var(--ink);
}
.cal-cell {
  background: var(--paper);
  padding: 0.45em 0.55em;
  aspect-ratio: 1 / 1;
  position: relative;
  font-size: 0.82rem;
  line-height: 1.3;
  overflow: hidden;
}
.cal-cell-blank { aspect-ratio: 1 / 1; }
.cal-cell-blank { background: var(--paper-dim); }
.cal-cell-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px dotted var(--border);
  padding-bottom: 0.15em;
  margin-bottom: 0.3em;
}
.cal-cell-date {
  font-family: "The Antiqua", Georgia, serif;
  font-size: 1.2em;
  color: var(--ink);
  font-weight: bold;
}
.cal-cell-weekday {
  font-variant: small-caps;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  font-size: 0.85em;
}
.cal-has-entry { background: #fbf5e2; }
.cal-past { opacity: 0.78; }
.cal-future .cal-cell-date { color: var(--ink-muted); }
.cal-today {
  box-shadow: 0 0 0 3px var(--rule);
  background: #fcefd4;
  position: relative;
  z-index: 1;
}
.cal-today .cal-cell-date { color: var(--rule-dark); font-weight: bold; }
.cal-today-badge {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--rule-dark);
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 1px 5px;
  line-height: 1;
  align-self: center;
  white-space: nowrap;
}
.cal-cell-weather {
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 0.2em;
}
.cal-icon {
  font-style: normal;
  margin-right: 0.15em;
  display: inline-block;
}
.cal-cell-moon {
  position: absolute;
  bottom: 0.3em;
  right: 0.4em;
  line-height: 1;
  opacity: 0.85;
  display: flex;
  align-items: baseline;
  gap: 0.3em;
}
.cal-cell-moon-major { opacity: 1; }
.cal-moon-glyph { font-size: 1.1em; }
.cal-moon-label {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  font-size: 0.78em;
  color: var(--ink-muted);
}
.cal-cell { position: relative; }
.cal-cell-events,
.cal-cell-feasts,
.cal-cell-sessions,
.cal-cell-notes { margin: 0.15em 0; }
.cal-cell-events { color: var(--rule-dark); font-weight: bold; }
.cal-tag {
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-size: 0.82em;
  margin-right: 0.3em;
}
.cal-cell-notes { font-style: italic; color: var(--ink-soft); }

.calendar-error { color: var(--rule-dark); background: var(--paper-dim); padding: 0.5em; }

@media (max-width: 720px) {
  .cal-grid { grid-template-columns: repeat(1, 1fr); }
  .cal-weekday { display: none; }
  .cal-cell { aspect-ratio: auto; padding: 0.6em 0.8em; }
  .cal-cell-blank { display: none; }
}

/* ---------- Folder index ---------- */

.folder-children {
  list-style: none;
  padding-left: 0;
  margin: 1em 0;
}
.folder-child {
  padding: 0.6em 0;
  border-bottom: 1px solid var(--border-soft);
}
.folder-child:last-child { border-bottom: none; }
.folder-child > a,
.folder-child > span {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}
.folder-child-folder > a::before { content: "▸ "; color: var(--ink-muted); }
.folder-child-pdf > a::before { content: "📖 "; opacity: 0.7; font-size: 0.9em; }
.folder-child-excerpt {
  margin: 0.2em 0 0;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.92rem;
}
.folder-empty { color: var(--ink-muted); }

/* ---------- Backlinks ---------- */

.backlinks {
  max-width: var(--text-col);
  margin: 3em auto 0;
  border-top: 2px double var(--rule);
  padding-top: 1em;
}
.backlinks h2 {
  font-size: 1.15rem;
  border: none;
  margin: 0 0 0.4em;
  color: var(--ink-muted);
  font-variant: small-caps;
  letter-spacing: 0.05em;
}
.backlinks ul {
  list-style: none;
  padding-left: 0;
  columns: 2;
  column-gap: 2em;
}
.backlinks li {
  padding: 0.1em 0;
  break-inside: avoid;
}

/* ---------- Images ---------- */

img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
}
.note-body img { margin: 0.5em 0; }

/* ---------- Link preview tooltip ---------- */

.link-preview {
  position: fixed;
  z-index: 1000;
  max-width: 340px;
  min-width: 220px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.12);
  padding: 0.7em 0.9em;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.link-preview.visible { opacity: 1; }
.link-preview-title {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-size: 1.02rem;
  color: var(--rule-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25em;
  margin-bottom: 0.4em;
  letter-spacing: 0.03em;
}
.link-preview-thumb {
  margin: 0 0 0.4em;
  display: flex;
  justify-content: center;
}
.link-preview-thumb img {
  max-width: 100%;
  max-height: 120px;
  border: 1px solid var(--border);
  display: block;
}
.link-preview-excerpt {
  color: var(--ink-soft);
  font-style: italic;
  overflow: hidden;
}

/* Embedded PDFs (`![[file.pdf]]`) */
.pdf-embed {
  width: 100%;
  height: 85vh;
  border: 1px solid var(--ink-muted);
  background: var(--paper-dim);
  margin: 1.2em auto;
  max-width: var(--wide-col);
}
.pdf-embed object { display: block; border: none; }
.note-body > .pdf-embed {
  max-width: var(--wide-col);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .site-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    max-height: none;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 1rem 1rem 3rem; }
}

/* ============================================================
   Dynamic feature additions (auth, comments, editor, etc.)
   Uses the same CSS variables as the OSR base theme.
   ============================================================ */

/* ---------- Auth Bar in Sidebar ---------- */

.sidebar-auth {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.user-greeting {
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.user-greeting strong {
  color: var(--ink);
}

.logout-link,
.login-link {
  color: var(--rule);
  font-size: 0.8rem;
  white-space: nowrap;
  font-family: "Alegreya Sans SC", Georgia, serif;
}

.logout-link:hover,
.login-link:hover {
  color: var(--rule-dark);
  text-decoration: underline;
}

/* ---------- Private Badge ---------- */

.private-badge {
  font-size: 0.75rem;
  margin-left: 0.3rem;
  opacity: 0.7;
}

/* ---------- Flash Messages ---------- */

.flashes {
  max-width: var(--text-col);
  margin: 0 auto 1rem;
}

.flash {
  padding: 0.6rem 1rem;
  border-radius: 2px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  animation: flash-fadein 0.3s ease;
}

.flash-success {
  background: #e8f0e4;
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.flash-error {
  background: #f5e4e4;
  color: var(--rule-dark);
  border: 1px solid var(--rule);
}

.flash-info {
  background: #e4ecf5;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

@keyframes flash-fadein {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-dismissing {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* ---------- Note Header & Actions ---------- */

.note-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--rule);
}

.note-header h1 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.note-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-top: 0.3rem;
}

.btn-edit,
.btn-delete,
.btn-new-note {
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
  font-size: 0.8rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  cursor: pointer;
  border: 1px solid var(--border);
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.btn-edit {
  background: var(--paper-dim);
  color: var(--ink);
}

.btn-edit:hover {
  background: var(--border-soft);
  color: var(--ink);
  text-decoration: none;
}

.btn-delete {
  background: transparent;
  color: var(--rule);
  border-color: var(--rule);
}

.btn-delete:hover {
  background: var(--rule);
  color: var(--paper);
}

.btn-delete-form {
  display: inline;
}

.btn-new-note {
  background: var(--paper-dim);
  color: var(--ink);
}

.btn-new-note:hover {
  background: var(--border-soft);
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Folder Page ---------- */

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.folder-title {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-size: 1.5rem;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin: 0;
  border: none;
  padding: 0;
}

.folder-subfolders {
  margin-bottom: 1.5rem;
}

.folder-subfolders h2,
.folder-notes h2 {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-size: 1rem;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
  border: none;
  padding: 0;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

.subfolder-list {
  list-style: none;
  padding: 0;
}

.subfolder-item {
  padding: 0.25rem 0;
}

.subfolder-item a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.subfolder-item a:hover {
  color: var(--rule);
}

.subfolder-icon {
  font-size: 1rem;
  color: var(--ink-muted);
}

.note-list {
  list-style: none;
  padding: 0;
}

.note-list-item {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-soft);
}

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

.note-list-item a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.note-list-item a:hover {
  color: var(--rule);
}

.note-list-title {
  flex: 1;
}

.folder-empty {
  color: var(--ink-muted);
  font-style: italic;
}

/* ---------- Comments Section ---------- */

.comments-section {
  max-width: var(--text-col);
  margin: 3em auto 0;
  padding-top: 1em;
  border-top: 2px double var(--rule);
}

.comments-section h2 {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-size: 1.15rem;
  border: none;
  margin: 0 0 0.75rem;
  color: var(--ink-muted);
  font-variant: small-caps;
  letter-spacing: 0.05em;
  padding: 0;
}

.comment {
  display: flex;
  gap: 0.75rem;
  background: transparent;
  margin-bottom: 0.75rem;
  align-items: flex-start;
}

.comment-right {
  flex-direction: row-reverse;
}

.comment-content {
  flex: 1;
  min-width: 0;
  max-width: 75%;
}

.comment-right .comment-content {
  text-align: right;
}

.comment-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.comment-left .comment-meta {
  justify-content: flex-start;
}

.comment-right .comment-meta {
  justify-content: flex-end;
}

/* ---------- Speech Bubble ---------- */

.comment-bubble {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.08);
}

/* Left comment: tail on the left */
.comment-left .comment-bubble::before {
  content: '';
  position: absolute;
  top: 14px;
  left: -10px;
  border: 8px solid transparent;
  border-right-color: var(--paper);
  border-left: 0;
}

.comment-left .comment-bubble::after {
  content: '';
  position: absolute;
  top: 13px;
  left: -11px;
  border: 9px solid transparent;
  border-right-color: var(--border-soft);
  border-left: 0;
  z-index: -1;
}

/* Right comment: tail on the right */
.comment-right .comment-bubble::before {
  content: '';
  position: absolute;
  top: 14px;
  right: -10px;
  border: 8px solid transparent;
  border-left-color: var(--paper);
  border-right: 0;
}

.comment-right .comment-bubble::after {
  content: '';
  position: absolute;
  top: 13px;
  right: -11px;
  border: 9px solid transparent;
  border-left-color: var(--border-soft);
  border-right: 0;
  z-index: -1;
}

.comment-author {
  color: var(--rule-dark);
  font-weight: 600;
  font-family: "Alegreya Sans SC", Georgia, serif;
}

.comment-date {
  color: var(--ink-muted);
}

.comment-body {
  font-size: 0.9rem;
  color: var(--ink-soft);
  overflow-wrap: break-word;
  word-break: break-word;
}

.comment-body p {
  margin-bottom: 0.3rem;
}

.comment-body p:last-child {
  margin-bottom: 0;
}

.comment-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.comment-left .comment-actions {
  justify-content: flex-start;
}

.comment-right .comment-actions {
  justify-content: flex-end;
}

.comment-icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 120ms ease, color 120ms ease;
}

.comment:hover .comment-icon-btn,
.comment-actions:hover .comment-icon-btn {
  opacity: 1;
}

.comment-icon-btn:hover {
  color: var(--ink);
  background: var(--paper-dim);
}

.comment-delete:hover {
  color: var(--rule);
}

.comment-edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 6px 8px;
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  resize: vertical;
  box-sizing: border-box;
}

.comment-edit-textarea:focus {
  outline: none;
  border-color: var(--rule);
}

.comment-save,
.comment-cancel {
  opacity: 1;
  font-size: 0.75rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  padding: 2px 8px;
  border: 1px solid var(--border);
}

#comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#comment-form textarea {
  width: 100%;
  min-height: 60px;
  padding: 0.5rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.9rem;
  resize: vertical;
}

#comment-form textarea:focus {
  outline: none;
  border-color: var(--rule);
}

#comment-form button[type="submit"] {
  align-self: flex-end;
  padding: 0.3rem 1rem;
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

#comment-form button[type="submit"]:hover {
  background: var(--border-soft);
}

/* ---------- Comment Form with Avatar ---------- */

.comment-form-with-avatar {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.comment-form-avatar {
  flex-shrink: 0;
  padding-top: 0.2rem;
}

.comment-form-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.no-comments {
  color: var(--ink-muted);
  font-style: italic;
}

/* ---------- Deleted Comment Placeholder ---------- */

.comment-deleted .comment-deleted-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.9rem;
  background: var(--paper-dim);
  border: 1px dashed var(--border-soft);
  border-radius: 12px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-style: italic;
  opacity: 0.7;
  min-height: 2.2rem;
}

.comment-deleted .comment-avatar-link {
  opacity: 0.3;
}

.comment-deleted .comment-avatar {
  background: var(--border-soft);
  color: var(--ink-muted);
}

.comment-deleted .comment-avatar img {
  opacity: 0.3;
  filter: grayscale(1);
}

.comment-login-prompt {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ---------- Auth Forms ---------- */

.auth-form {
  max-width: 400px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--paper-dim);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.auth-form h2 {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  color: var(--ink);
  margin-bottom: 1rem;
  font-size: 1.3rem;
  border: none;
  padding: 0;
}

.auth-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.25rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.9rem;
}

.auth-form input[type="text"]:focus,
.auth-form input[type="password"]:focus {
  outline: none;
  border-color: var(--rule);
}

.auth-form button[type="submit"] {
  width: 100%;
  padding: 0.5rem;
  background: var(--paper-dim);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 0.9rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  cursor: pointer;
  margin-top: 0.5rem;
}

.auth-form button[type="submit"]:hover {
  background: var(--border-soft);
}

.auth-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* ---------- Editor ---------- */

.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  height: calc(100vh - 200px);
  max-width: var(--wide-col);
  margin: 0 auto;
}

.editor-pane, .preview-pane {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.editor-pane textarea {
  width: 100%;
  height: 100%;
  border: none;
  padding: 1rem;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  resize: none;
  background: var(--paper);
  color: var(--ink);
}

.preview-pane {
  padding: 1rem;
  background: var(--paper);
}

.editor-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  max-width: var(--text-col);
  margin-left: auto;
  margin-right: auto;
}

.editor-toolbar input, .editor-toolbar select {
  padding: 0.25rem 0.5rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.85rem;
}

.editor-toolbar input:focus, .editor-toolbar select:focus {
  outline: none;
  border-color: var(--rule);
}

.slug-preview {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-left: auto;
  font-style: italic;
}

@media (max-width: 768px) {
  .editor-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  .editor-pane textarea {
    min-height: 300px;
  }
  .preview-pane {
    min-height: 300px;
  }
}

/* ---------- Map Markers (shared with map-viewer modal) ---------- */

.marker-modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.marker-btn {
  padding: 0.3rem 1rem;
  border-radius: 2px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
}

.marker-btn-save {
  background: var(--paper-dim);
  color: var(--ink);
}

.marker-btn-save:hover {
  background: var(--border-soft);
}

.marker-btn-cancel {
  background: transparent;
  color: var(--ink-muted);
}

.marker-btn-cancel:hover {
  background: var(--paper-dim);
}

.marker-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Sidebar Delete Confirmation Modal */

.sidebar-delete-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(42, 31, 20, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fadein 0.2s ease;
}

.sidebar-delete-modal-closing {
  animation: modal-fadeout 0.2s ease forwards;
}

@keyframes modal-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-fadeout {
  from { opacity: 1; }
  to { opacity: 0; }
}

.sidebar-delete-modal-content {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1.5rem;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

.sidebar-delete-modal-content h3 {
  font-family: "Alegreya Sans SC", Georgia, serif;
  color: var(--rule-dark);
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  border: none;
  padding: 0;
}

.sidebar-delete-modal-content p {
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.sidebar-delete-modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---------- Sidebar New Note Controls ---------- */

.sidebar-new-note {
  display: block;
  margin-top: 0.8rem;
  padding: 0.4rem 0.6rem;
  color: var(--ink-muted);
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 0.85rem;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: 2px;
  text-align: center;
}

.sidebar-new-note:hover {
  color: var(--rule);
  border-color: var(--rule);
  text-decoration: none;
}

/* ---------- Sidebar Tree Item Actions ---------- */

.tree-branch > details > summary {
  position: relative;
  padding-right: 3rem;
}

.tree-item.tree-leaf {
  position: relative;
  padding-right: 3rem;
}

.tree-item.tree-leaf > a {
  display: inline-block;
  max-width: calc(100% - 3rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.tree-folder-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 0.1rem;
}

.tree-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 0.1rem;
  vertical-align: middle;
}

.tree-item:hover .tree-folder-actions,
.tree-item:hover .tree-actions {
  display: inline-flex;
}

.tree-btn-new-note,
.tree-btn-new-folder {
  text-decoration: none;
}

.tree-btn-new-folder:hover {
  color: var(--accent-green);
}

.tree-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--border);
  font-size: 0.75rem;
  padding: 0 0.15rem;
  line-height: 1;
}

.tree-btn:hover {
  color: var(--rule);
}

.tree-btn-delete {
  color: var(--border);
}

.tree-btn-delete:hover {
  color: var(--rule);
}

.tree-rename-input {
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.92rem;
  padding: 1px 0.3rem;
  width: 140px;
}

.tree-move-menu {
  position: absolute;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.1);
  min-width: 160px;
  max-height: 300px;
  overflow-y: auto;
}

.tree-move-menu a {
  display: block;
  padding: 0.35rem 0.6rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
  font-family: "The Antiqua", Georgia, serif;
}

.tree-move-menu a:hover {
  background: var(--paper-dim);
  color: var(--rule);
}

.tree-add-menu {
  position: absolute;
  z-index: 100;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.1);
  min-width: 140px;
}

.tree-add-menu a {
  display: block;
  padding: 0.35rem 0.6rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
  font-family: "The Antiqua", Georgia, serif;
}

.tree-add-menu a:hover {
  background: var(--paper-dim);
  color: var(--rule);
}

.tree-new-folder-input {
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.85rem;
  padding: 1px 0.3rem;
  width: 100px;
  margin-left: 0.3rem;
}

/* ---------- Undo Toast Notification ---------- */

.undo-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.2rem;
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: "The Antiqua", Georgia, serif;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.undo-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.undo-toast-dismissing {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.undo-toast-message {
  color: var(--paper);
}

.undo-toast-btn {
  background: transparent;
  border: none;
  color: var(--paper);
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  text-decoration: underline;
  transition: color 0.15s ease, background 0.15s ease;
}

.undo-toast-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- Empty State ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  min-height: 60vh;
}

.empty-state h1 {
  font-family: "Alegreya Sans SC", "Alegreya Sans", Georgia, serif;
  font-size: 2.4rem;
  border: none;
  padding: 0;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.empty-state-subtitle {
  color: var(--ink-muted);
  font-size: 1.1rem;
  font-style: italic;
  margin: 0 0 2.5rem;
}

.empty-state-actions {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem 2.5rem;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--paper-dim);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  min-width: 180px;
  cursor: pointer;
}

.empty-state-card:hover {
  border-color: var(--rule);
  background: var(--paper);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--ink);
}

.empty-state-icon {
  font-size: 2rem;
  line-height: 1;
}

.empty-state-label {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-variant: small-caps;
}

.empty-state-card-folder {
  position: relative;
}

.empty-state-form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  width: 100%;
}

.empty-state-form input[type="text"] {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  font-family: "The Antiqua", Georgia, serif;
  font-size: 0.9rem;
  min-width: 0;
}

.empty-state-form input[type="text"]:focus {
  outline: none;
  border-color: var(--rule);
}

.empty-state-form button[type="submit"] {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--paper-dim);
  color: var(--ink);
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.empty-state-form button[type="submit"]:hover {
  background: var(--border-soft);
  border-color: var(--rule);
}

/* Sidebar Context Menu */

.sidebar-context-menu {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.25rem 0;
  min-width: 120px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.1);
}

.sidebar-context-menu-item {
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-family: "The Antiqua", Georgia, serif;
}

.sidebar-context-menu-item:hover {
  background: var(--paper-dim);
  color: var(--rule);
}

/* Sidebar empty hint */

.sidebar-empty-hint {
  margin-top: 1.2rem;
  padding: 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 2px;
  text-align: center;
  background: var(--paper);
}

.sidebar-empty-hint p {
  margin: 0 0 0.5rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.sidebar-empty-hint .btn-new-note {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--paper-dim);
  color: var(--ink-soft);
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-variant: small-caps;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-empty-hint .btn-new-note:hover {
  background: var(--border-soft);
  color: var(--rule);
  border-color: var(--rule);
  text-decoration: none;
}

@media (max-width: 600px) {
  .empty-state-actions {
    flex-direction: column;
    align-items: center;
  }
  .empty-state-card {
    width: 100%;
    max-width: 260px;
  }
  .empty-state h1 {
    font-size: 1.8rem;
  }
}

/* ---------- User Avatar ---------- */

.user-avatar-link {
  display: flex;
  text-decoration: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  aspect-ratio: 1;
}

.user-avatar,
.user-avatar-default {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--ink-muted);
  background: var(--paper-dim);
  flex-shrink: 0;
}

.user-avatar-link:hover .user-avatar {
  border-color: var(--rule);
}

.avatar-upload-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  margin-left: 0.3rem;
}

.avatar-upload-btn:hover {
  color: var(--rule);
  border-color: var(--rule);
}

/* ---------- Comment Avatars ---------- */

.comment-avatar-link {
  display: flex;
  text-decoration: none;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  aspect-ratio: 1;
  align-items: center;
  justify-content: center;
}

.comment-avatar,
.comment-avatar-default {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  color: var(--ink-muted);
  background: var(--paper-dim);
  flex-shrink: 0;
}

/* ---------- Character Page Large Avatar ---------- */

.char-avatar-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.char-avatar-large,
.char-avatar-large.char-avatar-default {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: var(--ink-muted);
  background: var(--paper-dim);
  flex-shrink: 0;
}

.char-avatar-upload-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  font-family: "Alegreya Sans SC", Georgia, serif;
}

.char-avatar-upload-btn:hover {
  color: var(--rule);
  border-color: var(--rule);
}

/* ---------- Avatar Crop Modal ---------- */

.avatar-crop-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
}

.avatar-crop-content {
  position: relative;
  background: var(--paper);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.avatar-crop-content h3 {
  font-family: "Alegreya Sans SC", Georgia, serif;
  margin: 0 0 1rem;
  color: var(--ink);
}

.avatar-crop-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.avatar-crop-viewport {
  position: relative;
  width: 256px;
  height: 256px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: grab;
  background: var(--paper-dim);
}

.avatar-crop-viewport:active {
  cursor: grabbing;
}

.avatar-crop-viewport img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

.avatar-crop-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.avatar-crop-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.avatar-crop-controls label {
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 0.85rem;
  color: var(--ink-muted);
  min-width: 40px;
}

.avatar-crop-controls input[type="range"] {
  flex: 1;
  accent-color: var(--rule);
}

.avatar-crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.avatar-crop-cancel,
.avatar-crop-save {
  padding: 0.4rem 1rem;
  border-radius: 4px;
  font-family: "Alegreya Sans SC", Georgia, serif;
  font-size: 0.85rem;
  cursor: pointer;
}

.avatar-crop-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

.avatar-crop-cancel:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.avatar-crop-save {
  background: var(--rule);
  border: 1px solid var(--rule);
  color: var(--paper);
}

.avatar-crop-save:hover {
  background: var(--rule-dark);
  border-color: var(--rule-dark);
}
