/* assets/style.css — Immortal Soul Wiki */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── THEME TOKENS ────────────────────────────────────────── */
/* Variables must be set on :root / [data-theme] directly (not nested),
   otherwise the swap can look "partial" or fail entirely. */

/* DARK THEME (default) */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1814;
  --bg-surface:   #201d18;
  --bg-card:      #272319;
  --bg-hover:     #2d2920;
  --border:       rgba(255,255,255,0.07);
  --border-mid:   rgba(255,255,255,0.13);
  --border-hi:    rgba(255,255,255,0.22);
  --text:         #dfd8c8;
  --text-muted:   #857e72;
  --text-dim:     #4a4740;
  --amber:        #c29040;
  --amber-light:  #dda85a;
  --amber-dim:    rgba(194,144,64,0.12);
  --amber-border: rgba(194,144,64,0.35);
  --red-dim:      rgba(162,45,45,0.2);
  --pill-b1-bg:   rgba(59,109,17,0.25);
  --pill-b1-text: #7abf43;
  --pill-b2-bg:   rgba(24,95,165,0.25);
  --pill-b2-text: #6aabf0;
  --pill-b3-bg:   rgba(194,144,64,0.25);
  --pill-b3-text: #dda85a;
  --pill-cat-bg:  rgba(255,255,255,0.06);
  --pill-cat-text:#4a4740;
}

/* LIGHT THEME */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f3ec;
  --bg-surface:   #ede8df;
  --bg-card:      #e4ddd2;
  --bg-hover:     #ddd6c9;
  --border:       rgba(0,0,0,0.08);
  --border-mid:   rgba(0,0,0,0.14);
  --border-hi:    rgba(0,0,0,0.25);
  --text:         #2a251e;
  --text-muted:   #6b6358;
  --text-dim:     #b0a898;
  --amber:        #8a5f10;
  --amber-light:  #7a540f;
  --amber-dim:    rgba(138,95,16,0.1);
  --amber-border: rgba(138,95,16,0.3);
  --red-dim:      rgba(162,45,45,0.1);
  --pill-b1-bg:   rgba(59,109,17,0.15);
  --pill-b1-text: #2e6609;
  --pill-b2-bg:   rgba(24,95,165,0.15);
  --pill-b2-text: #0d4f8f;
  --pill-b3-bg:   rgba(138,95,16,0.15);
  --pill-b3-text: #7a540f;
  --pill-cat-bg:  rgba(0,0,0,0.06);
  --pill-cat-text:#6b6358;
}

:root {
  --serif:    Georgia, 'Times New Roman', serif;
  --sans:     system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --radius:   6px;
  --sidebar-w:220px;
  --topbar-h: 52px;
  --reader-topbar-h: 48px;
}

html, body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.wiki-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 300px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-mid);
  background: var(--bg-surface);
}

.topbar-mobile {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { border-color: var(--amber-border); color: var(--amber); }

.topbar-brand {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--sans);
  white-space: nowrap;
}

.topbar-brand strong {
  color: var(--amber);
  font-weight: 600;
  letter-spacing: 0.12em;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
}

.topbar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.topbar-search input:focus        { border-color: var(--amber-border); }
.topbar-search input::placeholder { color: var(--text-dim); }

.topbar-auth {
  font-size: 0.8rem;
  font-family: var(--sans);
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-auth a { color: var(--amber); }

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: var(--sans);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--amber-border);
  color: var(--amber);
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 1.5rem; }

.sidebar-label {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 1.1rem 0.5rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 1.1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
  user-select: none;
}

.sidebar-item:hover          { background: var(--bg-hover); color: var(--text); }
.sidebar-item.active         { color: var(--amber); border-left-color: var(--amber); background: var(--amber-dim); }
.sidebar-item .count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── ENTRY LIST ─────────────────────────────────────────── */
.list-pane {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg);
}

.list-pane-header {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.entry-card {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background 0.1s;
}

.entry-card-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.entry-card:hover  { background: var(--bg-hover); }
.entry-card.active { background: var(--amber-dim); border-left: 2px solid var(--amber); }

.entry-card-bookmark,
.entry-header-bookmark {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-top: 0.1rem;
  padding: 0;
  border: none;
  border-radius: var(--radius, 4px);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

.entry-card-bookmark:hover,
.entry-header-bookmark:hover {
  color: var(--amber);
  background: var(--bg-hover);
}

.entry-card-bookmark .ti-bookmark-filled,
.entry-header-bookmark .ti-bookmark-filled {
  color: var(--amber);
}

.entry-meta-row .entry-header-bookmark {
  margin-top: 0;
  width: 1.85rem;
  height: 1.85rem;
}

.entry-card-title {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.3;
}

.entry-card-sub {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.pill {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
}

.pill-cat { background: var(--pill-cat-bg);  color: var(--pill-cat-text); }
.pill-b1  { background: var(--pill-b1-bg);   color: var(--pill-b1-text); }
.pill-b2  { background: var(--pill-b2-bg);   color: var(--pill-b2-text); }
.pill-b3  { background: var(--pill-b3-bg);   color: var(--pill-b3-text); }

.entry-card-date {
  margin-left: auto;
  font-size: 0.65rem;
  font-family: var(--sans);
  color: var(--text-dim);
}

/* ── CONTENT PANE ───────────────────────────────────────── */
.content-pane { overflow-y: auto; padding: 2rem 2.5rem; }

.content-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  color: var(--text-dim);
  font-family: var(--sans);
  text-align: center;
  gap: 0.5rem;
}

.content-empty-title { font-size: 1.1rem; color: var(--text-muted); font-family: var(--serif); }
.content-empty-sub   { font-size: 0.8rem; }

.content-empty-hint {
  display: none;
  font-size: 0.78rem;
  max-width: 16rem;
  line-height: 1.45;
}

/* ── ENTRY VIEW ─────────────────────────────────────────── */
.entry-header { margin-bottom: 1.5rem; }

.entry-meta-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0.6rem; }

.entry-title {
  font-size: 2rem;
  font-weight: normal;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.entry-subtitle { font-size: 0.95rem; color: var(--text-muted); font-style: italic; }

.entry-divider { border: none; border-top: 1px solid var(--border-mid); margin: 1.25rem 0; }

.infobox {
  float: right;
  width: 210px;
  margin: 0 0 1.25rem 1.75rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--sans);
  font-size: 0.8rem;
}

.infobox-head {
  background: var(--bg-card);
  padding: 7px 12px;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.infobox-row      { display: flex; border-bottom: 1px solid var(--border); }
.infobox-row:last-child { border-bottom: none; }
.infobox-key { padding: 6px 10px; color: var(--text-muted); min-width: 72px; background: var(--bg-card); border-right: 1px solid var(--border); }
.infobox-val { padding: 6px 10px; color: var(--text); flex: 1; }

.entry-body         { overflow: hidden; }
.entry-body p       { margin-bottom: 1rem; line-height: 1.85; color: var(--text); }
.entry-body p:last-child { margin-bottom: 0; }

.section-head {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 1.75rem 0 0.85rem;
  clear: both;
}

.lock-block {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lock-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.lock-label { font-family: var(--sans); font-size: 0.85rem; color: var(--text); }
.lock-sub   { font-family: var(--sans); font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ── LOGIN ──────────────────────────────────────────────── */
.login-wrap { max-width: 360px; margin: 100px auto; padding: 0 1rem; }
.login-title { font-size: 1.5rem; font-weight: normal; margin-bottom: 0.25rem; color: var(--text); }
.login-sub { font-family: var(--sans); font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2rem; }

.field              { margin-bottom: 1rem; }
.field label        { display: block; font-family: var(--sans); font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.field input        { width: 100%; background: var(--bg-card); border: 1px solid var(--border-mid); border-radius: var(--radius); padding: 9px 12px; font-size: 0.95rem; font-family: var(--sans); color: var(--text); outline: none; }
.field input:focus  { border-color: var(--amber-border); }

.btn-submit {
  width: 100%;
  padding: 10px;
  background: var(--amber-dim);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  color: var(--amber);
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.5rem;
}

.btn-submit:hover { background: rgba(194,144,64,0.22); }

.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(162,45,45,0.4);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: #c05050;
  margin-bottom: 1rem;
}

/* ── LOADING ─────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text-dim); font-family: var(--sans); font-size: 0.85rem; gap: 8px; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-mid); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ── INLINE EDITOR ──────────────────────────────────────── */
.inline-editor { max-width: 980px; margin: 0 auto; }
.inline-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.inline-editor-title {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.inline-editor-actions { display: flex; gap: 0.5rem; }
.inline-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-family: var(--sans);
  color: var(--text);
  cursor: pointer;
}
.inline-btn:hover { border-color: var(--amber-border); color: var(--amber); }
.inline-btn--primary { background: var(--amber-dim); border-color: var(--amber-border); color: var(--amber); }

.inline-field { margin-bottom: 1rem; }
.inline-field label {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.inline-field input,
.inline-field textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 0.95rem;
  font-family: var(--sans);
  color: var(--text);
  outline: none;
}
.inline-field textarea { resize: vertical; }
.inline-field input:focus,
.inline-field textarea:focus { border-color: var(--amber-border); }
.inline-hint {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.inline-status {
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-dim);
}
.inline-status.error { color: #c05050; }
.inline-status.ok { color: var(--pill-b1-text); }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

 
/* Fix: WebKit scrollbar selectors */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ── MOBILE / RESPONSIVE (2026 layout) ───────────────────── */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 80;
}
.mobile-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Compact: phones, tablet portrait, iPad landscape, touch devices up to ~14" */
@media (max-width: 1100px), ((pointer: coarse) and (max-width: 1400px)) {
  :root { --sidebar-w: min(92vw, 320px); }

  .wiki-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
    gap: 0.5rem;
    padding-top: env(safe-area-inset-top);
    min-height: var(--topbar-h);
  }

  .topbar-mobile { display: flex; flex-shrink: 0; }

  .topbar-search {
    flex: 1;
    min-width: 0;
    max-width: none;
    margin-left: 0;
  }

  .topbar-search input { font-size: 16px; }

  .topbar-brand { display: none; }

  .topbar-auth {
    gap: 0.35rem;
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .topbar-auth-extra { display: none; }

  .mobile-overlay {
    top: var(--topbar-h);
  }

  .sidebar,
  .list-pane {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    max-width: 92vw;
    box-shadow: 0 18px 60px rgba(0,0,0,0.45);
    transform: translateX(-110%);
    transition: transform 0.2s ease, visibility 0.2s;
    border-right: 1px solid var(--border-mid);
    visibility: hidden;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .sidebar { z-index: 100; }
  .list-pane { z-index: 101; background: var(--bg); }

  body.panel-sidebar-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  body.panel-list-open .list-pane {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .content-pane-stack {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 0;
    overflow: hidden;
  }

  .content-pane-with-rail {
    flex: 1;
    min-height: 0;
  }

  .content-pane {
    grid-column: 1 / -1;
    padding: 1.25rem max(1rem, env(safe-area-inset-right)) 2.25rem max(1rem, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .content-pane-stack .read-progress-track {
    margin: 0 1rem;
  }

  .content-empty-hint { display: block; }

  .infobox {
    float: none;
    width: 100%;
    margin: 0 0 1rem 0;
  }
}

@media (max-width: 420px) {
  .topbar-auth a:not(.topbar-auth-keep) { display: none; }
}

/* If a mobile browser ignores the (invalid) ::: scrollbar selectors above,
   this keeps scrollbars styled where supported. */
html::-webkit-scrollbar       { width: 6px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ── READING PROGRESS BAR (scroll depth) ─────────────────── */
.read-progress-track {
  flex-shrink: 0;
  height: 3px;
  margin: 0;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.read-progress-track.read-progress-track--visible {
  opacity: 1;
}

.read-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(194, 144, 64, 0.35),
    var(--amber),
    var(--amber-light)
  );
  box-shadow: 0 0 12px rgba(194, 144, 64, 0.35);
  transition: width 0.06s linear;
}

[data-theme="light"] .read-progress-fill {
  box-shadow: 0 0 10px rgba(138, 95, 16, 0.25);
}

.content-pane-stack {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.content-pane-stack .read-progress-track {
  margin: 0 2.5rem;
  align-self: stretch;
}

.content-pane-stack .content-pane-with-rail {
  flex: 1;
  min-height: 0;
}

.read-progress--viewport {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  height: 3px;
  margin: 0;
  border-radius: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.read-progress--viewport.read-progress-track--visible {
  opacity: 1;
}

.read-progress--viewport .read-progress-fill {
  border-radius: 0;
}

/* ── FLOATING READING BOOKMARK (edge ribbon, tracks scroll depth) ── */
.content-pane-with-rail {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.content-pane-with-rail .content-pane {
  flex: 1;
  min-width: 0;
}

.reading-bookmark-rail {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  align-self: stretch;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.reading-bookmark-rail.reading-bookmark-rail--visible {
  opacity: 1;
}

.reading-bookmark-rail::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(
    180deg,
    transparent,
    var(--border-hi) 15%,
    var(--border-hi) 85%,
    transparent
  );
  opacity: 0.55;
}

.reading-bookmark-flag {
  position: absolute;
  left: 1px;
  top: 0;
  width: 24px;
  min-height: 32px;
  padding: 6px 0 8px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  color: var(--bg);
  background: linear-gradient(165deg, var(--amber-light) 0%, var(--amber) 55%, #9a7028 100%);
  border-radius: 5px 5px 4px 4px;
  box-shadow:
    -3px 3px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: top 0.07s linear;
  pointer-events: none;
}

.reading-bookmark-flag::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .reading-bookmark-flag {
  color: #f7f3ec;
  box-shadow:
    -2px 3px 8px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.reading-bookmark-rail--viewport {
  position: fixed;
  right: 10px;
  top: 6px;
  bottom: 12px;
  width: 30px;
  z-index: 9997;
  flex: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.reading-bookmark-rail--viewport.reading-bookmark-rail--visible {
  opacity: 1;
}

@media (max-width: 1100px), ((pointer: coarse) and (max-width: 1400px)) {
  .reading-bookmark-rail:not(.reading-bookmark-rail--viewport) {
    flex-basis: 22px;
    width: 22px;
  }

  .reading-bookmark-flag {
    width: 20px;
    min-height: 28px;
    font-size: 13px;
  }
}

/* ── GUEST BOOK ─────────────────────────────────────────── */
.gb-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
}

.gb-hero {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.gb-title {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.gb-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.gb-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.gb-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.gb-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.gb-entry-meta time {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.gb-delete {
  font-family: var(--sans);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-mid);
  background: var(--red-dim);
  color: var(--text);
  cursor: pointer;
}

.gb-delete:hover {
  border-color: var(--border-hi);
}

.gb-entry-text {
  font-size: 1rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.gb-empty {
  color: var(--text-muted);
  font-style: italic;
}

.gb-form {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.25rem;
}

.gb-form-title {
  font-family: var(--sans);
  font-weight: 600;
  margin-bottom: 0.85rem;
  font-size: 0.95rem;
}

.gb-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.gb-req {
  font-weight: normal;
  color: var(--text-dim);
}

.gb-input,
.gb-textarea {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.55rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
}

.gb-input:focus,
.gb-textarea:focus {
  outline: none;
  border-color: var(--amber-border);
  box-shadow: 0 0 0 2px var(--amber-dim);
}

.gb-input-narrow {
  max-width: 6rem;
}

.gb-textarea {
  resize: vertical;
  min-height: 4.5rem;
  margin-bottom: 0.25rem;
}

.gb-counter {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 0.75rem;
}

.gb-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.gb-status {
  font-family: var(--sans);
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}

.gb-status.gb-ok {
  color: var(--pill-b1-text);
}

.gb-status.gb-err {
  color: #c45c5c;
}

[data-theme="light"] .gb-status.gb-err {
  color: #a33;
}

.gb-submit {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--amber-border);
  background: var(--amber-dim);
  color: var(--amber-light);
  cursor: pointer;
}

[data-theme="light"] .gb-submit {
  color: var(--amber);
}

.gb-submit:hover {
  background: var(--amber-border);
}