/* ═══════════════════════════════════════════════════════════════════════
 * Saga & Seeker — Story Archive
 * Design System: OBSIDIAN (refined dark + gold)
 * ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #13110d;
  --bg-soft:   #1a1812;
  --bg-2:      #1f1c16;
  --bg-3:      #2a2620;
  --line:      rgba(216, 195, 142, 0.08);
  --line-2:    rgba(216, 195, 142, 0.16);
  --ink:       #f1ead8;
  --ink-2:     #ada593;
  --ink-3:     #6f6757;
  --gold:      #d8c38e;
  --gold-2:    #ecd9a3;
  --gold-dim:  #8a7547;
  --rose:      #d27e63;
  --danger:    #cf6e6e;
  --success:   #8fc08a;
  --ease:      cubic-bezier(0.2, 0, 0, 1);
  --radius:    6px;
  --radius-sm: 3px;

  /* Legacy aliases (used by player + audio widget code) */
  --accent:    #ecd9a3;
  --text:      #f1ead8;
  --text-dim:  #ada593;
  --shadow:    0 18px 50px rgba(0, 0, 0, 0.4);

  /* Typography */
  --serif:     'Fraunces', 'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --sans:      'Inter', system-ui, 'Hiragino Kaku Gothic ProN', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
*:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }

html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: 'palt';
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 12% 6%, rgba(216, 195, 142, 0.05), transparent 60%),
    radial-gradient(ellipse 40% 50% at 90% 92%, rgba(210, 126, 99, 0.04), transparent 60%);
}

a { color: inherit; text-decoration: none; }
a.link { color: var(--gold); transition: color 0.18s var(--ease); }
a.link:hover { color: var(--gold-2); }

em, .it {
  font-family: var(--serif);
  font-style: italic;
  font-variation-settings: 'opsz' 144;
}
.serif { font-family: var(--serif); font-variation-settings: 'opsz' 144; }

/* ═══ HEADER ════════════════════════════════════════════════════════ */
/* Header background spans the full viewport, but its content is inset to
   match the centered .app-layout (max-width: 1480px). On wide monitors
   the logo sits at the same x-position as the sidebar's content so the
   left edges line up. Uses 100% (not 100vw) so a vertical scrollbar
   doesn't introduce a horizontal one. */
.global-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1.6rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  padding-left: max(1.6rem, calc((100% - 1480px) / 2 + 1.6rem));
  padding-right: max(1.6rem, calc((100% - 1480px) / 2 + 1.6rem));
  background: rgba(19, 17, 13, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.gh-brand {
  font-family: var(--serif);
  font-weight: 500; font-style: italic;
  font-size: 1.45rem; letter-spacing: -0.005em;
  font-variation-settings: 'opsz' 144;
  color: var(--ink);
  transition: opacity 0.18s var(--ease);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.gh-brand:hover { opacity: 0.85; }
.gh-brand .amp { color: var(--gold); }
.gh-brand img {
  display: block;
  height: 36px; width: auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.gh-nav {
  display: flex; gap: 0.2rem; margin-left: 0.4rem;
}
.gh-nav-link {
  position: relative;
  padding: 0.6rem 0.95rem;
  font-size: 0.86rem; font-weight: 500;
  color: var(--ink-2); letter-spacing: 0.04em;
  transition: color 0.22s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.gh-nav-link::after {
  content: ''; position: absolute;
  left: 0.95rem; right: 0.95rem; bottom: 0.5rem;
  height: 1px; background: var(--gold);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.32s var(--ease);
}
.gh-nav-link:hover { color: var(--ink); }
.gh-nav-link:hover::after { transform: scaleX(1); }
.gh-nav-link.active { color: var(--gold-2); }
.gh-nav-link.active::after { transform: scaleX(1); }
.gh-nav-ico { display: none; }     /* hide decorative ico, text-only */

.gh-actions {
  margin-left: auto;
  display: flex; gap: 0.6rem; align-items: center;
}
.gh-auth { display: flex; gap: 0.45rem; align-items: center; }
.gh-login, .gh-login-btn {
  font-family: var(--serif); font-style: italic;
  font-size: 0.84rem; letter-spacing: 0.04em;
  color: var(--ink); text-decoration: none;
  background: transparent;
  border: 1px solid var(--gold-dim);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
  white-space: nowrap;
  cursor: pointer;
}
.gh-login:hover, .gh-login-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(216, 195, 142, 0.06); }
.gh-login.google::before { content: 'G '; color: var(--gold); font-weight: 600; font-style: normal; }
.gh-login.twitter::before { content: '𝕏 '; color: var(--gold); font-style: normal; }
.gh-login.disabled {
  color: var(--ink-3); border-style: dashed; cursor: help;
}
.gh-user {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.85rem 0.3rem 0.42rem;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  background: rgba(216, 195, 142, 0.1);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.gh-user:hover { border-color: var(--gold); background: rgba(216, 195, 142, 0.15); }
.gh-user::before {
  content: '✓';
  color: var(--gold);
  font-size: 0.7em;
  margin-right: 0.1rem;
}
.gh-user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-soft);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 0.85rem;
}
.gh-user-name {
  font-size: 0.84rem; color: var(--ink);
  letter-spacing: 0.02em; max-width: 12em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gh-logout {
  background: transparent; border: 0;
  color: var(--ink-3); font-size: 0.74rem; letter-spacing: 0.06em;
  cursor: pointer; padding: 0.2rem 0.4rem;
  transition: color 0.18s var(--ease);
}
.gh-logout:hover { color: var(--danger); }

/* Upload zone: dim + show "ログインが必要" hint when locked */
.upload-zone[data-locked="true"] { opacity: 0.55; }
.upload-zone[data-locked="true"]::after {
  content: '※ アップロードにはログインが必要です';
  display: block; margin-top: 0.6rem;
  font-size: 0.78rem; color: var(--gold-dim); letter-spacing: 0.04em;
}

/* Locked tag chip — tags added by other users we cannot remove */
.tag-chip-locked {
  background: rgba(216, 195, 142, 0.04) !important;
  color: var(--ink-3) !important;
  border-color: var(--line-2) !important;
  cursor: default;
}

.card-uploader { color: var(--ink-3); font-style: italic; }

/* ═══ MYPAGE ════════════════════════════════════════════════════════ */
.login-prompt {
  text-align: center;
  padding: 3rem 1.5rem;
  margin: 2rem 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: rgba(216, 195, 142, 0.04);
}
.login-prompt h2 {
  font-family: var(--serif); color: var(--gold);
  font-size: 1.2rem; font-weight: 400;
  margin-bottom: 0.6rem;
  font-variation-settings: 'opsz' 144;
}
.login-prompt p { color: var(--ink-2); margin-bottom: 1.6rem; }
.login-prompt-actions {
  display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap;
}
.myp-section { margin: 1.5rem 0 2rem; }
.myp-card {
  display: flex; align-items: center; gap: 1.2rem;
  padding: 1.2rem 1.4rem;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}
.myp-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  font-size: 1.4rem;
  flex-shrink: 0;
}
.myp-meta { flex: 1; min-width: 0; }
.myp-name {
  font-family: var(--serif); font-weight: 500;
  font-size: 1.2rem; color: var(--ink);
  letter-spacing: 0.02em;
  font-variation-settings: 'opsz' 144;
  display: flex; align-items: center; gap: 0.5rem;
}
.myp-name-edit {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  border-radius: 999px;
  width: 1.7rem; height: 1.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.18s var(--ease);
}
.myp-name-edit:hover { color: var(--gold); border-color: var(--gold-dim); }
.myp-sub {
  font-size: 0.82rem; color: var(--ink-3);
  margin-top: 0.2rem;
}
.myp-prov {
  font-size: 0.7rem; color: var(--gold-dim);
  letter-spacing: 0.18em; margin-top: 0.4rem;
  text-transform: uppercase;
}
.myp-logout {
  font-family: var(--serif); font-style: italic;
  font-size: 0.84rem;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2);
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.myp-logout:hover {
  color: var(--danger); border-color: var(--danger);
}
.myp-empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--ink-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.myp-empty p { margin: 0.4rem 0; }
.myp-empty-link { color: var(--gold); text-decoration: none; }
.myp-empty-link:hover { color: var(--gold-2); }
.del-btn {
  background: transparent; color: var(--ink-3);
  border: 0; cursor: pointer;
  font-size: 0.78rem; padding: 0.2rem 0.4rem;
  margin-left: auto;
  transition: color 0.18s var(--ease);
}
.del-btn:hover { color: var(--danger); }

/* Top page nav cards (3 collections side-by-side) */
.top-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}
.top-card {
  display: flex; flex-direction: column;
  padding: 1.6rem 1.4rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform 0.32s var(--ease), border-color 0.28s var(--ease), box-shadow 0.32s var(--ease);
}
.top-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
.top-card-icon {
  font-family: var(--serif); color: var(--gold);
  font-size: 2.2rem; line-height: 1;
  margin-bottom: 0.8rem;
  font-variation-settings: 'opsz' 144;
}
.top-card h3 {
  font-family: var(--serif); font-weight: 500;
  font-size: 1.2rem; color: var(--ink);
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
  font-variation-settings: 'opsz' 144;
}
.top-card p {
  flex: 1;
  font-size: 0.88rem; color: var(--ink-2);
  line-height: 1.7;
  margin-bottom: 1.2rem;
}
.top-card-cta {
  font-family: var(--serif); font-style: italic;
  font-size: 0.92rem; color: var(--gold);
  letter-spacing: 0.04em;
  font-variation-settings: 'opsz' 144;
}

/* Hero "ようこそ" greeting when logged in */
#heroWelcome {
  color: var(--gold);
  font-family: var(--serif); font-style: italic;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  font-variation-settings: 'opsz' 144;
}
#heroWelcome[hidden] { display: none; }
.gh-burger {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.gh-burger span {
  width: 18px; height: 1.2px;
  background: var(--gold);
  transition: all 0.22s var(--ease);
}
body.drawer-open .gh-burger span:nth-child(1) { transform: translateY(5.2px) rotate(45deg); }
body.drawer-open .gh-burger span:nth-child(2) { opacity: 0; }
body.drawer-open .gh-burger span:nth-child(3) { transform: translateY(-5.2px) rotate(-45deg); }

/* ═══ TOP-RIGHT AUDIO WIDGET ═════════════════════════════════════════ */
.audio-widget {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: rgba(19, 17, 13, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.22s var(--ease);
  /* Hoist into its own compositor layer so iOS Safari doesn't blink it
     in and out during smooth-scroll between scenes. */
  transform: translateZ(0);
  will-change: transform;
}
/* When mounted inside the header (standard pages), drop the fixed
   positioning so it sits next to the user pill. */
.gh-actions .audio-widget,
.audio-widget.audio-widget-inline {
  position: static;
  top: auto; right: auto;
  z-index: auto;
  background: rgba(19, 17, 13, 0.55);
  padding: 0.32rem 0.55rem;
  gap: 0.3rem;
}
.gh-actions .audio-widget input[type="range"] { width: 56px; }
@media (max-width: 720px) {
  .gh-actions .audio-widget { padding: 0.25rem 0.4rem; gap: 0.2rem; }
  .gh-actions .audio-widget input[type="range"] { display: none; }
  .gh-actions .audio-widget .label { display: none; }
}
.audio-widget:hover { border-color: var(--line-2); }
.audio-widget button {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--ink-2); background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  padding: 0;
}
.audio-widget button:hover { background: rgba(216, 195, 142, 0.1); color: var(--gold-2); }
.audio-widget button.on { color: var(--gold); }
.audio-widget input[type="range"] {
  width: 64px;
  accent-color: var(--gold);
}
.audio-widget .label {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--gold);
  margin: 0 0.2rem;
}

/* ═══ LAYOUT ═════════════════════════════════════════════════════════ */
.app-layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  max-width: 1480px; margin: 0 auto;
  position: relative; z-index: 1;
}
.app-layout > main {
  min-width: 0;
  padding: 0 0 5rem;
}

/* ═══ SIDEBAR ════════════════════════════════════════════════════════ */
.global-sidebar {
  position: sticky; top: 60px;
  align-self: start;
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 1.4rem 0.6rem 1.5rem 1.6rem;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.global-sidebar::-webkit-scrollbar { width: 4px; }
.global-sidebar::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 2px; }

.gs-inner { display: flex; flex-direction: column; }

/* Section-level grouping (one section per collection: replays / characters / scenarios) */
.gs-section {
  margin-bottom: 1.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--line);
}
.gs-section:last-child { border-bottom: 0; margin-bottom: 0; }
.gs-section-title {
  display: flex; align-items: center;
  padding: 0.55rem 0.7rem;
  font-family: var(--serif); font-weight: 500;
  font-size: 0.78rem;
  color: var(--ink-3); letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.gs-section.is-active > .gs-section-title {
  color: var(--gold);
  background: rgba(216, 195, 142, 0.06);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
}
.gs-section-title:hover { color: var(--gold-2); }
.gs-section-chev {
  margin-left: auto; font-size: 0.65rem;
  transition: transform 0.28s var(--ease);
}
.gs-section.section-collapsed .gs-section-chev { transform: rotate(-90deg); }
.gs-section-body {
  overflow: hidden;
  max-height: 1500px;
  transition: max-height 0.4s var(--ease), opacity 0.25s var(--ease);
  padding-top: 0.5rem;
}
.gs-section.section-collapsed .gs-section-body {
  max-height: 0; opacity: 0; padding-top: 0;
}

.gs-group { margin-bottom: 1.1rem; }
.gs-group-title {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  font-family: var(--serif);
  font-weight: 500; font-size: 0.95rem;
  color: var(--gold); letter-spacing: 0.02em;
  cursor: default;
  border-radius: var(--radius);
  transition: background 0.18s var(--ease), color 0.22s var(--ease);
  user-select: none;
  font-variation-settings: 'opsz' 144;
}
.gs-group.collapsible > .gs-group-title { cursor: pointer; }
.gs-group.collapsible > .gs-group-title:hover {
  background: rgba(216, 195, 142, 0.04);
  color: var(--gold-2);
}
.gs-group-ico { display: none; }
.gs-chev {
  margin-left: auto; font-size: 0.65rem; color: var(--ink-3);
  transition: transform 0.28s var(--ease);
}
.gs-group:not(.collapsible) .gs-chev { display: none; }
.gs-group.collapsed .gs-chev { transform: rotate(-90deg); }

.gs-list {
  list-style: none;
  padding: 0.2rem 0 0.4rem 0;
  margin: 0 0 0 1rem;
  border-left: 1px solid var(--line);
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.32s var(--ease), opacity 0.2s var(--ease);
}
.gs-group.collapsed .gs-list { max-height: 0; opacity: 0; }
.gs-list li { position: relative; }
.gs-link {
  display: block;
  padding: 0.32rem 0.7rem 0.32rem 0.9rem;
  font-size: 0.85rem; font-weight: 400;
  color: var(--ink-2); letter-spacing: 0.02em;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
  border-radius: 0 var(--radius) var(--radius) 0;
  text-decoration: none;
}
.gs-link::before {
  content: ''; position: absolute;
  left: -1px; top: 50%; height: 0; width: 1.5px;
  background: var(--gold); transform: translateY(-50%);
  transition: height 0.22s var(--ease);
}
.gs-link:hover { color: var(--ink); background: rgba(216, 195, 142, 0.04); }
.gs-link.active { color: var(--gold-2); background: rgba(216, 195, 142, 0.06); }
.gs-link.active::before { height: 22px; }
.gs-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  font-family: var(--sans);
}

/* ═══ COMMON ELEMENTS ═══════════════════════════════════════════════ */
button.btn, .btn {
  padding: 0.75rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.86rem; font-weight: 500; letter-spacing: 0.04em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.22s var(--ease);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.btn:hover {
  border-color: var(--gold);
  color: var(--gold-2);
  transform: translateY(-1px);
}
.btn.primary {
  background: var(--gold);
  color: var(--bg);
  border-color: var(--gold);
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--gold-2);
  border-color: var(--gold-2);
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(216, 195, 142, 0.25);
}
.btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn.danger:hover {
  background: rgba(207, 110, 110, 0.08);
}
.btn.icon {
  width: 38px; height: 38px;
  padding: 0;
  justify-content: center;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ═══ HERO ════════════════════════════════════════════════════════════ */
.hero {
  position: relative;
  padding: 4rem 2.5rem 3rem;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3.5rem;
  align-items: end;
  animation: rise 0.8s var(--ease) both;
}
/* Compact hero: single column, no image, tight to the header */
.hero.hero-compact {
  display: block;
  padding: 1.6rem 2.5rem 1.4rem;
}
.hero.hero-compact .hero-meta { margin-bottom: 0.6rem; }
.hero.hero-compact h1 {
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  line-height: 1;
  margin-bottom: 0.9rem;
}
.hero.hero-compact p {
  max-width: 60ch;
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: 1.1rem;
}
.hero.hero-compact .hero-actions { margin-top: 0.4rem; }
@media (max-width: 960px) {
  .hero.hero-compact { padding: 1.1rem 1.2rem 1rem; }
}
/* Compact text-only variant — top-aligned, no right image */
.hero-compact {
  display: block;
  padding: 2rem 2.5rem 2.5rem;
  border-bottom: 1px solid var(--line);
}
.hero-meta {
  font-size: 0.7rem; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 1rem;
}
.hero-meta .accent { color: var(--gold); }
.hero h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05; letter-spacing: -0.025em;
  margin-bottom: 1rem;
  font-variation-settings: 'opsz' 144;
}
.hero h1 .it,
.hero h1 em {
  font-style: italic; font-weight: 400;
  color: var(--gold);
}
.hero p {
  font-size: 1rem; line-height: 1.75;
  max-width: 56ch; color: var(--ink-2);
  margin-bottom: 1.4rem;
}
.hero-actions { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.hero-img {
  aspect-ratio: 4 / 5;
  background: var(--bg-2);
  position: relative; overflow: hidden;
  border-radius: var(--radius);
}
.hero-img::after {
  content: ''; position: absolute; inset: 0;
  background: url('../assets/images/hero-bg.jpg') center/cover;
  transform: scale(1.05);
  animation: kenburns 18s ease-in-out infinite alternate;
}
@keyframes kenburns {
  0%   { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1.5%, 1%); }
}
.hero-img .cap {
  position: absolute; bottom: 1.2rem; left: 1.2rem; z-index: 1;
  color: var(--ink); font-family: var(--serif);
  font-style: italic; font-size: 1rem;
  font-variation-settings: 'opsz' 144;
}
.hero-img .cap small {
  display: block; font-family: var(--sans); font-style: normal;
  font-size: 0.62rem; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.3rem;
}

/* ═══ SECTION TITLE ═══════════════════════════════════════════════════ */
.section {
  padding: 3rem 2.5rem 0;
  animation: rise 0.8s var(--ease) 0.1s both;
}
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 1.2rem; margin-bottom: 1.8rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif); font-weight: 400;
  font-size: 1.8rem; letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 144;
  color: var(--ink);
}
.section-title em, .section-title .it {
  color: var(--gold);
  font-style: italic;
}
.section-title .meta-right {
  font-family: var(--sans); font-size: 0.7rem;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 400;
}

/* ═══ CARD GRID ═══════════════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.4rem;
}

.card {
  position: relative;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.32s var(--ease),
              border-color 0.28s var(--ease),
              box-shadow 0.32s var(--ease);
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--line-2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
.card-thumb {
  aspect-ratio: 16 / 10;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-2), var(--bg));
}
.card-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.card:hover .card-thumb img { transform: scale(1.04); }
.card-thumb .glyph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); color: var(--ink-3);
  font-size: 2.5rem; opacity: 0.5;
  font-variation-settings: 'opsz' 144;
}
.card-thumb .badge {
  position: absolute; top: 0.7rem; left: 0.7rem;
  font-size: 0.62rem; letter-spacing: 0.3em; text-transform: uppercase;
  background: rgba(19, 17, 13, 0.85);
  color: var(--gold);
  padding: 0.3rem 0.55rem; border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.card-body {
  padding: 1.2rem 1.3rem 1.3rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  flex: 1;
}
.card-title {
  font-family: var(--serif); font-weight: 500;
  font-size: 1.15rem; line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variation-settings: 'opsz' 36;
}
.card-author {
  font-family: var(--serif);
  font-style: italic; font-size: 0.9rem;
  color: var(--ink-3);
  font-variation-settings: 'opsz' 144;
}
/* Prominent uploader byline directly under the title — the
   community-branding cue ("〇〇さんのログ") that testers asked for. */
.card-byline {
  font-family: var(--serif);
  font-size: 0.92rem;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin-top: 0.15rem;
  font-variation-settings: 'opsz' 36;
}
.card-byline .by-name {
  color: var(--gold);
  font-weight: 500;
  font-style: italic;
  font-variation-settings: 'opsz' 144;
}
/* Character-icon strip on cards — small overlapping circles showing who
   appears in this replay. Tooltip shows the name on hover. */
.card-char-icons {
  display: flex; align-items: center;
  gap: 0.15rem;
  margin-top: 0.4rem;
  padding-left: 0.2rem;
}
.card-char-icons .ci-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background-color: var(--bg-soft);
  background-size: cover;
  background-position: center;
  border: 2px solid var(--bg);
  margin-left: -0.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.card-char-icons .ci-dot:first-child { margin-left: 0; }
.card-char-icons .ci-more {
  font-size: 0.7rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  margin-left: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.card-excerpt {
  font-size: 0.88rem; line-height: 1.6; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex; gap: 0.9rem;
  font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--ink-3);
  align-items: center;
  flex-wrap: wrap;
}
.card-meta span::before { content: '·  '; color: var(--gold-dim); }
.card-meta span:first-child::before { content: ''; }
.card-actions {
  margin-top: auto;
  padding-top: 0.85rem; border-top: 1px solid var(--line);
  display: flex; gap: 0.5rem; align-items: center;
}
.card-actions .like {
  margin-left: auto;
  background: none; border: 0; padding: 0.2rem 0.4rem;
  color: var(--ink-3); font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.18s var(--ease);
}
.card-actions .like.liked { color: var(--gold-2); }
.card-actions .like:hover { color: var(--gold); }
.card-actions .play-btn {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gold);
  background: transparent; border: 0;
  padding: 0; cursor: pointer;
  transition: color 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.card-actions .play-btn:hover { color: var(--gold-2); }
.card-actions .more-btn {
  background: transparent; border: 0;
  color: var(--ink-3); cursor: pointer; padding: 0.2rem 0.5rem;
  font-size: 1rem;
}
.card-actions .more-btn:hover { color: var(--gold); }

/* ═══ UPLOAD ZONE ═════════════════════════════════════════════════════ */
.upload-zone {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: rgba(216, 195, 142, 0.02);
  transition: all 0.22s var(--ease);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--gold);
  background: rgba(216, 195, 142, 0.05);
}
.upload-zone .ico {
  font-size: 1.8rem; color: var(--gold); margin-bottom: 0.6rem;
}
.upload-zone h3 {
  font-family: var(--serif); font-weight: 400;
  color: var(--gold); letter-spacing: 0.02em;
  margin-bottom: 0.4rem; font-size: 1.2rem;
  font-variation-settings: 'opsz' 144;
}
.upload-zone p { color: var(--ink-2); font-size: 0.88rem; }
.upload-zone input[type="file"] { display: none; }

/* ═══ TEXT INPUT / SELECT ═════════════════════════════════════════════ */
input[type="text"], input[type="email"], textarea, select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem;
  transition: border-color 0.22s var(--ease);
}
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--gold);
}

/* ═══ TOAST ══════════════════════════════════════════════════════════ */
.toast-wrap {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 0.7rem 1.2rem;
  color: var(--ink); font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s var(--ease), toast-out 0.25s ease 2.7s forwards;
  pointer-events: auto;
}
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }

/* ═══ EMPTY STATE ════════════════════════════════════════════════════ */
.empty {
  text-align: center; padding: 3rem 1rem; color: var(--ink-3);
}
.empty h3 {
  font-family: var(--serif); font-weight: 400;
  color: var(--gold); margin-bottom: 0.4rem; font-size: 1.2rem;
  font-variation-settings: 'opsz' 144;
}

/* ═══ MOBILE FAB FOR SIDEBAR ═════════════════════════════════════════ */
.sb-fab {
  display: none;
  position: fixed; bottom: 1.2rem; left: 1.2rem; z-index: 30;
  background: var(--gold); color: var(--bg); border: 0;
  padding: 0.7rem 1.2rem; border-radius: 999px;
  font-family: var(--serif); font-style: italic;
  font-size: 0.95rem; font-variation-settings: 'opsz' 144;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.sb-fab:hover { background: var(--gold-2); }

/* ═══ ANIMATIONS ═════════════════════════════════════════════════════ */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-out {
  to { opacity: 0; transform: translateY(-4px); }
}

/* ═══ MOBILE ═════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .global-header { padding: 0.7rem 1rem; gap: 0.7rem; }
  /* Burger always at the right edge on mobile */
  .gh-burger { display: inline-flex; margin-left: auto; order: 99; }
  .gh-actions { order: 98; }
  .gh-brand { order: 1; }
  .gh-brand img { height: 30px; }
  .gh-nav {
    position: fixed; top: 60px; right: 0; bottom: 0; width: 260px;
    /* Solid (non-transparent) drawer so menu text is readable */
    background: #13110D;
    background-color: var(--bg-2);
    flex-direction: column;
    padding: 1.4rem 1rem;
    border-left: 1px solid var(--line);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 49;
    transform: translateX(100%);
    transition: transform 0.28s var(--ease);
  }
  /* Backdrop dim behind the drawer */
  body.drawer-open::before {
    content: '';
    position: fixed; inset: 60px 0 0 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 48;
  }
  body.drawer-open .gh-nav { transform: translateX(0); }
  .gh-nav-link { padding: 0.85rem 0.6rem; font-size: 0.95rem; border-bottom: 1px solid var(--line); }
  .gh-nav-link::after { display: none; }
  /* Compact auth widget on mobile so it sits next to the burger */
  .gh-user-name { display: none; }
  .gh-login { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
  .gh-user { padding: 0.2rem 0.4rem; }
  .audio-widget input[type="range"] { display: none; }
  .audio-widget .label { display: none; }

  .app-layout { grid-template-columns: 1fr; }
  .global-sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 280px;
    background: var(--bg-soft);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    border-right: 1px solid var(--line-2);
  }
  body.sidebar-open .global-sidebar { transform: translateX(0); }
  body.sidebar-open::after {
    content: '';
    position: fixed; inset: 60px 0 0 280px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 39;
  }
  .sb-fab { display: inline-block; }

  .hero { grid-template-columns: 1fr; padding: 2rem 1.2rem 2rem; gap: 1.8rem; }
  .section { padding: 2.5rem 1.2rem 0; }
}

/* ═══ PLAYER MODAL (panel above portal background) ══════════════════ */
.player-modal {
  position: fixed; inset: 0;
  z-index: 1300;
  display: block;
}
.player-modal[hidden] { display: none !important; }

.pm-backdrop {
  position: absolute; inset: 0;
  background: rgba(7, 6, 4, 0.55);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: fade-in 0.32s var(--ease);
  cursor: pointer;
}
.pm-panel {
  position: absolute;
  top: 72px;                       /* leave room for global header */
  left: 50%;
  transform: translateX(-50%);
  width: min(1200px, calc(100% - 48px));
  height: calc(100% - 96px);
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: pm-in 0.32s var(--ease);
}
@keyframes pm-in {
  from { opacity: 0; transform: translate(-50%, 8px) scale(0.98); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.player-modal.closing .pm-panel { animation: pm-out 0.22s var(--ease) forwards; }
.player-modal.closing .pm-backdrop { animation: fade-out 0.22s var(--ease) forwards; }
@keyframes pm-out {
  to { opacity: 0; transform: translate(-50%, 4px) scale(0.99); }
}
@keyframes fade-out { to { opacity: 0; } }

.pm-toolbar {
  position: absolute;
  top: 0.7rem; right: 0.85rem;
  z-index: 5;
  display: flex; gap: 0.5rem; align-items: center;
}
.pm-close {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(19, 17, 13, 0.85);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--ink);
  padding: 0.4rem 0.95rem;
  font-family: var(--serif); font-style: italic;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  backdrop-filter: blur(8px);
  font-variation-settings: 'opsz' 144;
}
.pm-close:hover { background: var(--gold); color: var(--bg); border-color: var(--gold); }
.pm-close::before { content: '×'; font-size: 1.3em; line-height: 0; font-style: normal; }
.pm-frame {
  flex: 1; width: 100%; height: 100%;
  border: 0; background: var(--bg);
}

/* Lock body scroll while modal is open. Header stays above & clickable. */
body.pm-open { overflow: hidden; }
body.pm-open .global-header { z-index: 1400; }

/* Mobile: closer to full-bleed but still leave the header visible */
@media (max-width: 720px) {
  .pm-panel {
    top: 60px;
    width: calc(100% - 16px);
    height: calc(100% - 72px);
    border-radius: 6px;
  }
}

/* ═══ DETAIL / EDIT MODAL ═══════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s var(--ease);
  overflow-y: auto;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  max-width: 520px; width: 100%;
  padding: 1.8rem;
  box-shadow: var(--shadow);
}
.modal-edit { max-width: 600px; max-height: calc(100vh - 3rem); overflow-y: auto; }
.modal h3 {
  font-family: var(--serif); font-weight: 400;
  color: var(--gold); margin-bottom: 0.6rem; font-size: 1.25rem;
  font-variation-settings: 'opsz' 144;
}
.modal .meta-line {
  font-size: 0.78rem; color: var(--ink-3);
  letter-spacing: 0.08em; margin-bottom: 1.2rem;
}
.modal label {
  display: block; font-size: 0.74rem;
  color: var(--ink-3); letter-spacing: 0.14em;
  margin-top: 1.1rem; margin-bottom: 0.4rem;
  text-transform: uppercase;
}
.modal input[type="text"], .modal textarea {
  width: 100%;
}
.modal textarea { resize: vertical; min-height: 4.5em; line-height: 1.6; }
.modal .hint-sm {
  font-size: 0.7rem; color: var(--ink-3);
  margin-top: 0.4rem; line-height: 1.5;
}
.modal .actions {
  display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.6rem;
  flex-wrap: wrap;
}

/* Share URL row: input + copy button */
.share-row { display: flex; gap: 0.4rem; align-items: stretch; }
.share-row .share-url { flex: 1; min-width: 0; }
.share-row .share-copy {
  font-family: var(--serif); font-style: italic;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-2);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.share-row .share-copy:hover { border-color: var(--gold); color: var(--gold); }
.share-row .share-copy.copied { color: var(--gold); border-color: var(--gold); background: rgba(216, 195, 142, 0.06); }

/* Character modal toolbar (lives inside .pm-panel) */
.char-modal .pm-panel { background: #1a1814; }
.cm-toolbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  background: rgba(19, 17, 13, 0.96);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.cm-toolbar .cm-spacer { flex: 1; }
.cm-toolbar > button,
.cm-toolbar > a {
  font-family: var(--serif); font-style: italic;
  font-size: 0.85rem; letter-spacing: 0.04em;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line-2);
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.cm-toolbar > button:hover,
.cm-toolbar > a:hover { color: var(--gold); border-color: var(--gold); }
.cm-toolbar .cm-close { color: var(--ink); }
.cm-frame { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.modal .actions .del { margin-right: auto; color: var(--danger); border-color: var(--danger); }
.modal .actions .save.hot {
  background: var(--gold); color: var(--bg); border-color: var(--gold);
}
.modal .actions button[disabled] {
  opacity: 0.4; cursor: not-allowed;
}

/* Thumbnail editor */
.thumb-editor {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: start;
}
.thumb-preview {
  aspect-ratio: 16 / 10;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm, 4px);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.thumb-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-preview .thumb-empty {
  color: var(--ink-3); font-size: 0.78rem; letter-spacing: 0.1em;
}
.thumb-actions { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.btn-thumb, .btn-thumb-revert {
  font-family: var(--serif); font-style: italic; font-size: 0.85rem;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-2);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.btn-thumb:hover { border-color: var(--gold); color: var(--gold); }
.btn-thumb-revert { font-size: 0.78rem; color: var(--ink-3); padding: 0.3rem 0.8rem; }
.btn-thumb-revert:hover:not([disabled]) { color: var(--ink); border-color: var(--ink-3); }
.btn-thumb-revert[disabled] { opacity: 0.4; cursor: not-allowed; }
.thumb-hint {
  font-size: 0.68rem; color: var(--ink-3);
  letter-spacing: 0.04em; margin-top: 0.2rem; line-height: 1.5;
}

/* Tag input + chips (in modal) */
.tag-input {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm, 4px);
  background: var(--bg);
  padding: 0.5rem 0.6rem 0.4rem;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  transition: border-color 0.18s var(--ease);
}
.tag-input:focus-within { border-color: var(--gold-dim); }
.tag-input .tag-chips { display: contents; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  background: rgba(216, 195, 142, 0.1);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.78rem;
  font-family: var(--sans);
  letter-spacing: 0.04em;
}
.tag-chip button {
  background: transparent; border: 0;
  color: var(--gold-dim);
  font-size: 1em; line-height: 1;
  cursor: pointer; padding: 0 0.1rem;
  transition: color 0.15s var(--ease);
}
.tag-chip button:hover { color: var(--danger); }
.tag-input .tag-add {
  flex: 1; min-width: 8em;
  border: 0; background: transparent;
  font-size: 0.85rem; color: var(--ink);
  padding: 0.25rem 0;
  outline: none;
}

/* Tags shown on cards */
.card-tags {
  display: flex; flex-wrap: wrap; gap: 0.32rem;
  margin-top: 0.1rem;
}
.card-tags .tag {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  padding: 0.12rem 0.5rem;
  background: rgba(216, 195, 142, 0.06);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
  font-family: inherit;
}
.card-tags .tag:hover {
  background: rgba(216, 195, 142, 0.18);
  border-color: var(--gold);
  color: var(--ink);
}
.card-tags .tag::before { content: '#'; opacity: 0.6; margin-right: 0.05em; }

@media (max-width: 540px) {
  .thumb-editor { grid-template-columns: 1fr; }
  .thumb-preview { max-width: 240px; }
}

/* ═══ WIKI / LORE PAGE ═══════════════════════════════════════════════ */
.wiki-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
  animation: rise 0.7s var(--ease) both;
}
.wiki-page-header {
  text-align: left;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}
.wiki-page-header small {
  display: block;
  font-size: 0.7rem; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 1rem;
}
.wiki-page-header h1 {
  font-family: var(--serif); font-weight: 300;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.025em; line-height: 1.05;
  margin-bottom: 0.8rem;
  font-variation-settings: 'opsz' 144;
}
.wiki-page-header h1 em { color: var(--gold); font-style: italic; font-weight: 400; }
.wiki-page-header p {
  color: var(--ink-2);
  font-size: 1.05rem; line-height: 1.7;
  max-width: 50ch;
}
.wiki-page section { margin-bottom: 2.5rem; scroll-margin-top: 80px; }
.wiki-page h2 {
  font-family: var(--serif); font-weight: 400;
  color: var(--ink);
  font-size: 1.5rem; letter-spacing: -0.015em;
  margin-bottom: 1rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-variation-settings: 'opsz' 144;
}
.wiki-page p {
  color: var(--ink-2); line-height: 1.85; margin-bottom: 0.8rem;
}
.wiki-page a { color: var(--gold); transition: color 0.18s var(--ease); }
.wiki-page a:hover { color: var(--gold-2); }

.wiki-list { list-style: none; padding: 0; margin: 0.6rem 0 0.8rem; }
.wiki-list li {
  position: relative; padding-left: 1.4rem;
  margin-bottom: 0.4rem; line-height: 1.85;
  color: var(--ink-2);
}
.wiki-list li::before {
  content: '›'; position: absolute; left: 0.4rem;
  color: var(--gold);
}
ol.wiki-list { counter-reset: w; }
ol.wiki-list li { counter-increment: w; }
ol.wiki-list li::before {
  content: counter(w);
  font-family: var(--serif); font-style: italic;
  color: var(--gold); font-size: 0.9em;
  font-variation-settings: 'opsz' 144;
}

.wiki-dl { margin-top: 0.8rem; }
.wiki-dl dt {
  font-family: var(--serif); font-weight: 500;
  color: var(--gold); font-size: 1rem;
  margin-top: 0.8rem;
  font-variation-settings: 'opsz' 36;
}
.wiki-dl dd {
  margin-left: 0; padding-left: 1rem;
  border-left: 1px solid var(--line-2);
  color: var(--ink-2); font-size: 0.92rem;
  line-height: 1.85; margin-top: 0.2rem;
}

.callout {
  background: rgba(216, 195, 142, 0.04);
  border-left: 2px solid var(--gold);
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92rem; line-height: 1.8;
  color: var(--ink-2);
}
.callout strong {
  color: var(--gold); font-family: var(--serif); font-style: italic;
  font-size: 0.9em;
  display: block; margin-bottom: 0.3rem;
  font-variation-settings: 'opsz' 144;
}

/* ═══ PLAYER (existing) ═══════════════════════════════════════════════ */
.title-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg-2) 0%, var(--bg) 100%);
  cursor: pointer;
  transition: opacity 0.6s var(--ease);
  overflow: hidden;
}
.title-screen.fade-out { opacity: 0; pointer-events: none; }
/* Particle canvas (sits behind everything inside the title screen) */
.title-screen .ts-particles {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
/* Top-left close button */
.title-screen .ts-close {
  position: absolute; top: 1rem; left: 1rem;
  z-index: 3;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(19, 17, 13, 0.7);
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.18s var(--ease);
}
.title-screen .ts-close:hover {
  color: var(--ink); border-color: var(--gold-dim);
  background: rgba(19, 17, 13, 0.92);
}
/* Stack the title content above the particles */
.title-screen .ts-stack {
  position: relative;
  z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 1rem;
  max-width: 92vw;
}
.title-screen .ts-thumb {
  width: min(420px, 70vw);
  aspect-ratio: 16 / 10;
  background-color: var(--bg-soft);
  background-size: cover; background-position: center;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  margin-bottom: 1.6rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.title-screen .ts-thumb[hidden] { display: none; }
.title-screen .title-name {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  color: var(--gold); letter-spacing: 0.05em;
  margin-bottom: 0.6rem; text-align: center; padding: 0 1rem;
  font-variation-settings: 'opsz' 144;
}
.title-screen .title-date {
  font-family: var(--serif);
  color: var(--ink-3); font-size: 0.95rem;
  letter-spacing: 0.3em; margin-bottom: 2.2rem;
}
.title-screen .press-start {
  font-family: var(--sans); font-size: 0.86rem;
  letter-spacing: 0.32em; color: var(--gold);
  border: 1px solid var(--line-2); background: transparent;
  padding: 0.9rem 2rem; border-radius: var(--radius);
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
  transition: all 0.2s var(--ease);
}
.title-screen .press-start:hover {
  border-color: var(--gold);
  background: rgba(216, 195, 142, 0.05);
}
/* Lift the audio widget above the title screen so users can adjust BGM/SFX
   from the title-screen state too. The widget mounts itself to body. */
body .audio-widget { z-index: 1100; }

/* Floating top-left close button on the player page. Always visible,
   even after PRESS TO START (the title-screen × is gone by then). */
.floating-close {
  position: fixed; top: 1rem; left: 1rem;
  z-index: 90;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(19, 17, 13, 0.78);
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.18s var(--ease);
  transform: translateZ(0);
}
.floating-close:hover {
  color: var(--ink); border-color: var(--gold-dim);
  background: rgba(19, 17, 13, 0.92);
}
.floating-close[hidden] { display: none !important; }

/* "物語を閉じる" button block shown after onFinish() */
.finish-block {
  margin: 3rem auto 4rem;
  text-align: center;
  animation: fade-in 0.6s var(--ease) both;
}
.finish-block .finish-btn {
  font-family: var(--serif); font-style: italic;
  font-size: 1.05rem; letter-spacing: 0.16em;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-dim);
  padding: 0.85rem 2.4rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.finish-block .finish-btn:hover {
  background: rgba(216, 195, 142, 0.08);
  border-color: var(--gold);
  color: var(--gold-2);
}
.finish-block .finish-note {
  font-size: 0.78rem;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  margin-top: 0.8rem;
}

/* Player page is its own app shell: header on top, scrolling stage in the
   middle, control bar pinned to the bottom — all in one column. The page
   itself NEVER scrolls; only `.log-stage` scrolls. This keeps the bottom
   bar perfectly stable on iOS (the URL bar can't show/hide because there's
   no page-level scroll), and the bar no longer jitters when text advances. */
body.player-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;          /* dynamic viewport so iOS chrome doesn't fight us */
  overflow: hidden;
}
body.player-page > header[data-saga-header] { flex: 0 0 auto; }
body.player-page .log-stage {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;            /* required so flex child can actually shrink */
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  /* Hide the visible scrollbar — it clashes with the immersive
     "press-to-continue" reading experience. Scrolling itself still
     works (wheel, trackpad, touch, keyboard, progress-bar jumps). */
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* legacy Edge / IE */
}
body.player-page .log-stage::-webkit-scrollbar {
  width: 0; height: 0;              /* WebKit (Safari, Chrome) */
}
body.player-page .player-bar {
  position: relative;       /* in flow at the bottom of the column */
  bottom: auto; left: auto; right: auto;
  flex: 0 0 auto;
}
body.player-page .title-screen { top: 0; }
body.player-page .floating-close { top: 4.5rem; }
body.player-page .audio-widget { top: 4.8rem; }
@media (max-width: 720px) {
  body.player-page .floating-close { top: 4rem; }
  body.player-page .audio-widget { top: 4.2rem; }
}

/* When player.html is loaded inside the portal modal iframe, the parent
   already shows the shared header — hide our copy and reclaim the space. */
html.in-modal body.player-page > header[data-saga-header] { display: none !important; }
html.in-modal body.player-page .log-stage { padding-top: 1rem; }
html.in-modal body.player-page .floating-close { top: 1rem; }
html.in-modal body.player-page .audio-widget { top: 1rem; }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(216, 195, 142, 0.4); }
  50%      { opacity: 0.7; box-shadow: 0 0 24px 4px rgba(216, 195, 142, 0.1); }
}

.log-stage {
  /* Narrower column on PC for shorter, eye-friendly lines (was 920px,
     felt like the eye had to track too far across before line-wrap).
     Also a bit more horizontal padding so the body never butts the
     edge on slightly narrow desktops. */
  max-width: 740px; margin: 0 auto;
  padding: 2rem 1.6rem 8rem;
  position: relative; z-index: 1;
}
.log-stage h1 {
  font-family: var(--serif); font-weight: 300;
  color: var(--gold); font-size: clamp(1.4rem, 3.5vw, 2rem);
  letter-spacing: -0.01em; text-align: center;
  margin-bottom: 0.4rem; padding-top: 1.5rem;
  font-variation-settings: 'opsz' 144;
}
.log-stage .stage-date {
  text-align: center; color: var(--ink-3);
  font-size: 0.85rem; letter-spacing: 0.3em; margin-bottom: 2rem;
}
.log-stage .chapter-mark {
  font-family: var(--serif); font-weight: 400;
  font-size: 1.1rem; color: var(--gold);
  letter-spacing: 0.2em; text-align: center;
  margin: 3rem 0 2rem;
  display: flex; align-items: center; gap: 1rem;
  opacity: 0; animation: fade-in 1s var(--ease) forwards;
  font-variation-settings: 'opsz' 144;
}
.log-stage .chapter-mark::before, .log-stage .chapter-mark::after {
  content: ''; flex: 1; height: 1px; background: var(--line-2);
}
.log-stage .scene {
  display: flex; gap: 1.5rem;
  margin-bottom: 2.4rem;
  opacity: 0; transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.log-stage .scene.visible { opacity: 1; transform: translateY(0); }
.log-stage .scene .ci {
  /* Bumped from 72px → 92px so the character icon reads as a "portrait",
     not just a tiny avatar. Pairs with the larger body type below. */
  flex-shrink: 0; width: 92px; height: 92px;
  background: transparent center/contain no-repeat;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background-color: var(--bg-soft);
}
.log-stage .scene .ci.n {
  background-image: none;
  background-color: transparent;
  border: 0; width: 0;
}
.log-stage .scene .body { flex: 1; min-width: 0; }
.log-stage .scene .cn {
  color: var(--gold);
  font-family: var(--serif); font-weight: 500;
  letter-spacing: 0.08em;
  margin-bottom: 0.55rem;
  font-size: 1.02rem;
  font-variation-settings: 'opsz' 144;
}
.log-stage .scene .ct {
  /* Bumped from 1rem/1.95 → 1.13rem/2.15 — body text reads about 18px
     with generous line spacing so the eye doesn't slip while scrolling. */
  font-size: 1.13rem; line-height: 2.15;
  color: var(--ink);
}
.log-stage .scene.narration .ct {
  color: var(--ink-2); font-family: var(--serif);
  border-left: 2px solid var(--gold-dim);
  padding-left: 1rem;
  font-variation-settings: 'opsz' 36;
}
.log-stage .scene .ct ruby rt {
  color: var(--ink-3); font-size: 0.55em;
}
.ss-inline-meta { display: none !important; }

/* Click-to-advance: the whole reading area acts as a "next" target. */
body.click-mode { cursor: pointer; }
/* …but don't override cursors on the chrome / interactive controls. */
body.click-mode .player-bar,
body.click-mode .player-bar *,
body.click-mode .chapter-nav,
body.click-mode .chapter-nav *,
body.click-mode .global-header,
body.click-mode .global-header *,
body.click-mode .global-sidebar,
body.click-mode .global-sidebar * { cursor: auto; }
body.click-mode button,
body.click-mode a,
body.click-mode select,
body.click-mode input { cursor: pointer; }
/* Click-to-advance hint: lives in the flex flow as a slim strip directly
   above the player-bar (NOT a floating pill over the text). This means
   it can never overlap reading content. The strip's space is reserved
   in layout while in click mode so scenes don't jolt up/down between
   transitions; only the text + arrow fade in/out. */
body.player-page .click-hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center; justify-content: center; gap: 0.55rem;
  padding: 0.55rem 1rem;
  color: var(--gold);
  font-family: var(--serif); font-style: italic;
  font-size: 0.86rem; letter-spacing: 0.12em;
  font-variation-settings: 'opsz' 144;
  cursor: pointer;
  user-select: none;
  opacity: 0;
  background-color: transparent;
  border-top: 1px solid transparent;
  transition: opacity 0.45s var(--ease), background-color 0.45s var(--ease), border-color 0.45s var(--ease), color 0.2s var(--ease);
}
body.player-page .click-hint[hidden] { display: none !important; }
body.player-page .click-hint.visible {
  opacity: 0.95;
  background-color: rgba(19, 17, 13, 0.85);
  border-top-color: var(--gold-dim);
  animation: ch-pulse 1.6s ease-in-out infinite;
}
body.player-page .click-hint:hover {
  background-color: rgba(216, 195, 142, 0.12);
  border-top-color: var(--gold);
  color: var(--ink);
}
body.player-page .click-hint .ch-arrow {
  font-size: 0.95em;
  line-height: 1;
  transform: translateY(1px);
}
@keyframes ch-pulse {
  0%, 100% { box-shadow: inset 0 8px 14px -10px rgba(216, 195, 142, 0.0); }
  50%      { box-shadow: inset 0 8px 14px -10px rgba(216, 195, 142, 0.5); }
}
@media (max-width: 720px) {
  body.player-page .click-hint { font-size: 0.78rem; padding: 0.45rem 0.9rem; }
}

.fx-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 90; opacity: 0; }
.fx-overlay.flash-yellow { background: rgba(255, 231, 131, 0.65); animation: flash 0.8s ease-out; }
.fx-overlay.flash-white  { background: rgba(255, 255, 255, 0.55); animation: flash 0.6s ease-out; }
@keyframes flash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }

.player-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(19, 17, 13, 0.92);
  border-top: 1px solid var(--line);
  padding: 0.7rem 1rem;
  display: flex; gap: 0.5rem; align-items: center;
  z-index: 70;                /* above click-hint so the bar always wins taps */
  backdrop-filter: blur(10px);
  /* Promote to its own compositor layer so iOS Safari doesn't repaint
     it while smooth-scrolling — same trick we use for the audio widget. */
  transform: translateZ(0);
  will-change: transform;
}
.player-bar .progress {
  flex: 1; height: 4px; background: var(--bg-3);
  border-radius: 2px; overflow: hidden;
  position: relative; cursor: pointer;
}
.player-bar .progress .bar {
  height: 100%; width: 0; background: var(--gold);
  transition: width 0.3s var(--ease);
}
.player-bar .speed-control {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem; color: var(--ink-3);
}
.player-bar .speed-control select {
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
}
.player-bar .share-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 0.32rem 0.85rem;
  font-family: var(--serif); font-style: italic;
  font-size: 0.8rem; letter-spacing: 0.06em;
  font-variation-settings: 'opsz' 144;
  cursor: pointer;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.player-bar .share-btn:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: rgba(216, 195, 142, 0.08);
}
.player-bar .share-btn .ico { font-size: 0.95em; line-height: 1; }
@media (max-width: 480px) {
  /* Tight phone screens — drop the label, keep only the icon */
  .player-bar .share-btn .lbl { display: none; }
  .player-bar .share-btn { padding: 0.32rem 0.6rem; }
}

.chapter-nav {
  position: fixed; left: 1rem; top: 50%;
  transform: translateY(-50%);
  z-index: 80;
  background: rgba(19, 17, 13, 0.85);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex; flex-direction: column; gap: 0.3rem;
  backdrop-filter: blur(8px);
  max-width: 200px;
}
.chapter-nav a {
  font-family: var(--serif); color: var(--ink-2);
  font-size: 0.85rem; padding: 0.4rem 0.7rem;
  border-radius: var(--radius); letter-spacing: 0.05em;
  text-decoration: none;
  transition: all 0.18s var(--ease);
  font-variation-settings: 'opsz' 144;
}
.chapter-nav a:hover, .chapter-nav a.active {
  color: var(--gold);
  background: rgba(216, 195, 142, 0.05);
}

@media (max-width: 768px) {
  .chapter-nav { display: none; }
  /* Mobile: bumped one more notch — body text reads ~18px so it stays
     comfortable on small screens too. (Width-narrowing is for PC only;
     phones already have a tight viewport.) */
  .log-stage { padding: 1rem 0.9rem 2rem; max-width: none; }
  .log-stage .scene { gap: 0.95rem; margin-bottom: 2rem; }
  .log-stage .scene .ci { width: 64px; height: 64px; }
  .log-stage .scene .cn { font-size: 1rem; }
  .log-stage .scene .ct { font-size: 1.13rem; line-height: 2.05; }
  .log-stage .scene.narration .ct { padding-left: 0.8rem; }
}
