:root {
  color-scheme: dark;
  --bg: #070914;
  --panel: rgba(12, 18, 36, 0.82);
  --panel-strong: rgba(15, 24, 50, 0.94);
  --line: rgba(142, 170, 230, 0.22);
  --text: #f8fbff;
  --muted: #aebad0;
  --blue: #2d7dff;
  --blue-soft: #79b7ff;
  --fire: #35d4ff;
  --ember: #bfeeff;
  --body-bg:
    radial-gradient(circle at 18% 16%, rgba(45, 125, 255, 0.42), transparent 28%),
    radial-gradient(circle at 86% 16%, rgba(255, 106, 31, 0.34), transparent 30%),
    linear-gradient(120deg, #0712aa 0%, #12172f 45%, #8c3305 100%);
  --hero-bg:
    linear-gradient(115deg, rgba(10, 22, 58, 0.96), rgba(16, 18, 37, 0.94) 54%, rgba(89, 32, 8, 0.9)),
    var(--panel);
  --accent-gradient: linear-gradient(100deg, #1c6cff, #ff6a1f);
  --brand-gradient: linear-gradient(135deg, #1265ff, #10183c 48%, #35d4ff);
  --cover-gradient:
    radial-gradient(circle at 24% 48%, rgba(45, 125, 255, 0.86) 0 18%, transparent 21%),
    radial-gradient(circle at 80% 26%, rgba(53, 212, 255, 0.64) 0 18%, transparent 21%),
    linear-gradient(120deg, #061eb4, #10162e 45%, #065f9d);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="mana"] {
  --panel: rgba(12, 18, 36, 0.82);
  --panel-strong: rgba(15, 24, 50, 0.94);
  --line: rgba(142, 190, 255, 0.24);
  --muted: #aebad0;
  --blue: #2d7dff;
  --blue-soft: #9fd1ff;
  --fire: #35d4ff;
  --ember: #bfeeff;
  --body-bg:
    radial-gradient(circle at 18% 16%, rgba(45, 125, 255, 0.45), transparent 28%),
    radial-gradient(circle at 86% 16%, rgba(53, 212, 255, 0.24), transparent 30%),
    linear-gradient(120deg, #0712aa 0%, #111832 48%, #065f9d 100%);
  --hero-bg:
    linear-gradient(115deg, rgba(10, 22, 58, 0.96), rgba(16, 18, 37, 0.94) 54%, rgba(6, 61, 105, 0.9)),
    var(--panel);
  --accent-gradient: linear-gradient(100deg, #1c6cff, #35d4ff);
  --brand-gradient: linear-gradient(135deg, #1265ff, #10183c 48%, #35d4ff);
  --cover-gradient:
    radial-gradient(circle at 24% 48%, rgba(45, 125, 255, 0.86) 0 18%, transparent 21%),
    radial-gradient(circle at 80% 26%, rgba(53, 212, 255, 0.64) 0 18%, transparent 21%),
    linear-gradient(120deg, #061eb4, #10162e 45%, #065f9d);
}

body[data-theme="rift"] {
  --panel: rgba(36, 12, 22, 0.84);
  --panel-strong: rgba(54, 15, 30, 0.95);
  --line: rgba(255, 124, 138, 0.25);
  --muted: #dcc0c6;
  --blue: #ff465d;
  --blue-soft: #ff9daa;
  --fire: #ff7a2b;
  --ember: #ffc29f;
  --body-bg:
    radial-gradient(circle at 18% 16%, rgba(255, 70, 93, 0.44), transparent 28%),
    radial-gradient(circle at 86% 16%, rgba(255, 122, 43, 0.3), transparent 30%),
    linear-gradient(120deg, #650818 0%, #1e111d 48%, #8f2805 100%);
  --hero-bg:
    linear-gradient(115deg, rgba(72, 12, 26, 0.96), rgba(30, 17, 29, 0.95) 54%, rgba(86, 28, 8, 0.9)),
    var(--panel);
  --accent-gradient: linear-gradient(100deg, #ff2e4d, #ff7a2b);
  --brand-gradient: linear-gradient(135deg, #ff2e4d, #21111c 48%, #ff7a2b);
  --cover-gradient:
    radial-gradient(circle at 24% 48%, rgba(255, 70, 93, 0.82) 0 18%, transparent 21%),
    radial-gradient(circle at 80% 26%, rgba(255, 122, 43, 0.7) 0 18%, transparent 21%),
    linear-gradient(120deg, #8c061a, #1e111d 45%, #9d2b06);
}

body[data-theme="guild"] {
  --panel: rgba(34, 26, 11, 0.84);
  --panel-strong: rgba(52, 39, 14, 0.95);
  --line: rgba(255, 211, 104, 0.26);
  --muted: #d1c3a0;
  --blue: #ffd15c;
  --blue-soft: #ffe6a6;
  --fire: #f09b24;
  --ember: #ffe0a3;
  --body-bg:
    radial-gradient(circle at 18% 16%, rgba(255, 209, 92, 0.34), transparent 28%),
    radial-gradient(circle at 86% 16%, rgba(240, 155, 36, 0.3), transparent 30%),
    linear-gradient(120deg, #4c3405 0%, #191711 48%, #7d4a05 100%);
  --hero-bg:
    linear-gradient(115deg, rgba(62, 43, 8, 0.96), rgba(25, 23, 17, 0.95) 54%, rgba(91, 55, 8, 0.9)),
    var(--panel);
  --accent-gradient: linear-gradient(100deg, #ffd15c, #f09b24);
  --brand-gradient: linear-gradient(135deg, #ffd15c, #1f1a10 48%, #f09b24);
  --cover-gradient:
    radial-gradient(circle at 24% 48%, rgba(255, 209, 92, 0.75) 0 18%, transparent 21%),
    radial-gradient(circle at 80% 26%, rgba(240, 155, 36, 0.68) 0 18%, transparent 21%),
    linear-gradient(120deg, #735206, #191711 45%, #9a5b06);
}

body[data-theme="spirit"] {
  --panel: rgba(10, 31, 23, 0.84);
  --panel-strong: rgba(12, 47, 34, 0.95);
  --line: rgba(116, 239, 163, 0.24);
  --muted: #b7d5c2;
  --blue: #35d889;
  --blue-soft: #a7f0cf;
  --fire: #b4f05b;
  --ember: #dcffad;
  --body-bg:
    radial-gradient(circle at 18% 16%, rgba(53, 216, 137, 0.4), transparent 28%),
    radial-gradient(circle at 86% 16%, rgba(180, 240, 91, 0.28), transparent 30%),
    linear-gradient(120deg, #064533 0%, #101d18 48%, #3d6b08 100%);
  --hero-bg:
    linear-gradient(115deg, rgba(6, 61, 45, 0.96), rgba(16, 29, 24, 0.95) 54%, rgba(48, 80, 9, 0.9)),
    var(--panel);
  --accent-gradient: linear-gradient(100deg, #35d889, #b4f05b);
  --brand-gradient: linear-gradient(135deg, #35d889, #101d18 48%, #b4f05b);
  --cover-gradient:
    radial-gradient(circle at 24% 48%, rgba(53, 216, 137, 0.78) 0 18%, transparent 21%),
    radial-gradient(circle at 80% 26%, rgba(180, 240, 91, 0.64) 0 18%, transparent 21%),
    linear-gradient(120deg, #08704f, #101d18 45%, #4f8509);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--body-bg);
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0.72rem 0.9rem;
}

button:hover {
  border-color: var(--blue-soft);
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

.danger {
  border-color: rgba(255, 95, 95, 0.44);
  background: rgba(255, 64, 64, 0.12);
  color: #ffd6d6;
}

.danger:hover {
  border-color: rgba(255, 120, 120, 0.8);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 10, 24, 0.7);
  color: var(--text);
  font: inherit;
  padding: 0.78rem 0.82rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 86px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 14, 34, 0.96), rgba(9, 10, 24, 0.96));
  box-shadow: 18px 0 60px rgba(0, 0, 0, 0.28);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  padding: 0.4rem;
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
}

.mobile-menu-toggle {
  display: none;
}

.mobile-reader-tab {
  display: none;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  flex: 0 0 auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--brand-gradient);
  box-shadow: 0 0 28px rgba(45, 125, 255, 0.42);
  cursor: pointer;
}

.brand h1,
.brand p,
.landing h2,
.landing p,
.home-cards h3,
.home-cards p,
.player-preview h3,
.player-preview p,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 1.2rem;
}

.brand p,
.sidebar-card span,
.landing p,
.home-cards p,
.player-preview p,
.preview-side span {
  color: var(--muted);
}

.side-nav {
  display: grid;
  gap: 0.55rem;
}

.side-nav button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.12rem 0.65rem;
  min-height: 58px;
  text-align: left;
  align-items: center;
}

.side-nav i {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  grid-row: span 2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
}

.side-nav i::before,
.side-nav i::after {
  content: "";
  position: absolute;
}

.side-nav [data-icon="home"] i::before {
  width: 16px;
  height: 13px;
  border: 2px solid currentColor;
  border-top: 0;
  transform: translateY(4px);
}

.side-nav [data-icon="home"] i::after {
  width: 14px;
  height: 14px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
}

.side-nav [data-icon="story"] i::before {
  width: 18px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.side-nav [data-icon="story"] i::after {
  width: 2px;
  height: 16px;
  background: currentColor;
}

.side-nav [data-icon="library"] i::before {
  width: 18px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.side-nav [data-icon="library"] i::after {
  width: 14px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 -5px 0 currentColor;
}

.side-nav [data-icon="import"] i::before {
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.side-nav [data-icon="import"] i::after {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -3px);
}

.side-nav [data-icon="music"] i::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.14);
}

.side-nav [data-icon="music"] i::after {
  width: 5px;
  height: 5px;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  box-shadow: 9px -10px 0 -1px currentColor;
}

.side-nav [data-icon="memory"] i::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.side-nav [data-icon="memory"] i::after {
  width: 2px;
  height: 22px;
  background: currentColor;
  box-shadow: 6px 0 0 currentColor, -6px 0 0 currentColor;
}

.side-nav [data-icon="settings"] i::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.side-nav [data-icon="settings"] i::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 -12px 0 -1px currentColor, 0 12px 0 -1px currentColor, 12px 0 0 -1px currentColor, -12px 0 0 -1px currentColor;
}

.side-nav [data-icon="admin"] i::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.side-nav [data-icon="admin"] i::after {
  width: 14px;
  height: 8px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  transform: translateY(9px);
}

.side-nav button span {
  font-weight: 800;
}

.side-nav button small {
  color: var(--muted);
}

.side-nav .active {
  background: var(--accent-gradient);
  border-color: rgba(255, 255, 255, 0.24);
}

.side-nav .active i {
  background: rgba(255, 255, 255, 0.18);
}

.side-nav .active small {
  color: rgba(255, 255, 255, 0.78);
}

.sidebar-card {
  display: grid;
  gap: 0.24rem;
  margin-top: auto;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.sidebar-collapsed .sidebar {
  padding: 1rem 0.72rem;
}

.sidebar-collapsed .brand {
  justify-content: center;
  padding: 0.25rem;
}

.sidebar-collapsed .brand div,
.sidebar-collapsed .side-nav small,
.sidebar-collapsed .side-nav span,
.sidebar-collapsed .sidebar-card {
  display: none;
}

.sidebar-collapsed .sidebar-toggle {
  position: fixed;
  left: 58px;
  top: 18px;
  z-index: 10;
  background: linear-gradient(100deg, #1c6cff, #ff6a1f);
}

.sidebar-collapsed .side-nav button {
  grid-template-columns: 1fr;
  min-height: 52px;
  padding: 0;
}

.sidebar-collapsed .side-nav i {
  place-self: center;
  grid-row: auto;
}

.sidebar-card strong {
  font-size: 0.95rem;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  padding: 1rem;
}

.page {
  display: none;
}

.page.active {
  display: grid;
}

.home {
  min-width: 0;
  min-height: 100vh;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 1rem;
}

.page-header,
.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 18, 36, 0.68);
}

.page-header h2 {
  margin: 0.18rem 0 0;
  font-size: clamp(1.3rem, 2vw, 2rem);
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-switcher {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.theme-switcher button {
  padding: 0.48rem 0.62rem;
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 800;
}

.theme-switcher button.active {
  background: var(--accent-gradient);
  border-color: rgba(255, 255, 255, 0.28);
}

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: clamp(1rem, 2.6vw, 2rem);
  min-height: 0;
  padding: clamp(1rem, 2.6vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    var(--hero-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035), 0 24px 80px rgba(0, 0, 0, 0.28);
}

.landing-copy {
  display: grid;
  align-content: center;
  gap: 1rem;
  min-width: 0;
}

.badge {
  width: fit-content;
  padding: 0.42rem 0.66rem;
  border: 1px solid rgba(121, 183, 255, 0.38);
  border-radius: 999px;
  background: rgba(45, 125, 255, 0.18);
  color: #d8e8ff;
  font-size: 0.82rem;
  font-weight: 900;
}

.landing h2 {
  max-width: 880px;
  font-size: clamp(2.25rem, 5.4vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-wrap: balance;
  text-shadow: 0 0 36px rgba(45, 125, 255, 0.22);
}

.landing p {
  max-width: 720px;
  font-size: clamp(0.98rem, 1.3vw, 1.14rem);
  line-height: 1.58;
}

.primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.primary {
  background: var(--accent-gradient);
  border-color: rgba(255, 255, 255, 0.26);
  color: white;
  font-weight: 900;
}

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.trust-row span {
  padding: 0.43rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #dce7ff;
  font-size: 0.85rem;
  font-weight: 800;
}

.cover-panel {
  display: grid;
  min-width: 0;
  place-items: center;
}

.cover-art {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    var(--cover-gradient);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.cover-art::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 8px;
  background:
    linear-gradient(100deg, rgba(5, 11, 30, 0.35), rgba(8, 8, 18, 0.1)),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 13px);
}

.moon {
  position: absolute;
  right: 16%;
  top: 13%;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd9a7, #ff8c36 58%, transparent 62%);
  filter: blur(0.3px);
}

.hero-silhouette {
  position: absolute;
  left: 34%;
  bottom: 21%;
  width: 72px;
  height: 150px;
  border-radius: 44% 44% 18% 18%;
  background: linear-gradient(180deg, #070914, #05060c);
  box-shadow: -54px 34px 0 -24px #05060c, 54px 44px 0 -27px #05060c;
}

.fireline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26%;
  background:
    radial-gradient(circle at 76% 20%, rgba(255, 176, 90, 0.82), transparent 18%),
    linear-gradient(180deg, transparent, rgba(255, 106, 31, 0.72));
}

.cover-title {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 7%;
  display: grid;
  gap: 0.28rem;
  padding: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 9, 20, 0.72);
  backdrop-filter: blur(12px);
}

.cover-title span,
.eyebrow {
  color: var(--blue-soft);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover-title strong {
  font-size: 1.12rem;
}

.cover-title small {
  color: var(--muted);
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.home-cards article,
.player-preview,
.resume-card,
.mood-card,
.placeholder-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.new-story-page {
  gap: 1rem;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.setup-steps article {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 0.12rem 0.65rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.setup-steps article span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  grid-row: span 2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  font-weight: 900;
}

.setup-steps article.active {
  border-color: rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel);
}

.setup-steps article.active span {
  background: var(--accent-gradient);
}

.setup-steps b {
  font-size: 0.95rem;
}

.setup-steps small {
  color: var(--muted);
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}

.setup-main,
.setup-side {
  display: grid;
  gap: 1rem;
}

.setup-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.setup-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.setup-card h3,
.setup-card p {
  margin: 0;
}

.setup-card h3 {
  margin-top: 0.24rem;
  font-size: 1.18rem;
}

.pill {
  width: fit-content;
  padding: 0.35rem 0.52rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #dce7ff;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.wide-field {
  grid-column: 1 / -1;
}

.rule-options,
.tracking-grid {
  display: grid;
  gap: 0.65rem;
}

.rule-options label,
.tracking-grid label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.rule-options input,
.tracking-grid input {
  width: auto;
  margin-top: 0.2rem;
}

.template-picker,
.mood-list,
.memory-mode-list {
  display: grid;
  gap: 0.65rem;
}

.template-choice,
.memory-choice {
  display: grid;
  gap: 0.18rem;
  text-align: left;
}

.template-choice span,
.memory-choice span,
.memory-mode span {
  color: var(--muted);
  font-size: 0.86rem;
}

.template-choice.active,
.memory-choice.active,
.mood-list .selected,
.companion-choice.active {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--accent-gradient);
}

.template-choice.active span,
.memory-choice.active span {
  color: rgba(255, 255, 255, 0.82);
}

.mood-list {
  margin-top: 0.85rem;
}

.mood-list button {
  position: relative;
  text-align: left;
  padding-right: 2.5rem;
}

.mood-list .selected::after {
  content: "on";
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 900;
}

.memory-mode,
.template-summary {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.template-summary {
  margin-top: 0;
}

.template-summary p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.summary-tags span {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #dce7ff;
  font-size: 0.8rem;
  font-weight: 800;
}

.companion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.companion-choice {
  display: grid;
  gap: 0.25rem;
  min-height: 100px;
  text-align: left;
  font-weight: 900;
}

.companion-choice span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.4;
}

.companion-choice.active span {
  color: rgba(255, 255, 255, 0.82);
}

.name-modal,
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 25% 20%, rgba(45, 125, 255, 0.35), transparent 30%),
    radial-gradient(circle at 80% 18%, rgba(255, 106, 31, 0.26), transparent 32%),
    rgba(3, 5, 12, 0.86);
  backdrop-filter: blur(12px);
}

.login-modal {
  z-index: 120;
}

.login-modal.visible {
  display: grid;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 5, 12, 0.72);
  backdrop-filter: blur(10px);
}

.confirm-modal.visible {
  display: grid;
}

.confirm-dialog {
  width: min(100%, 420px);
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent),
    var(--panel-strong);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  margin-top: 0.35rem;
}

.confirm-dialog p:not(.eyebrow) {
  margin-top: 0.6rem;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reader-page {
  height: calc(100vh - 2rem);
  min-height: 0;
  overflow: hidden;
}

.reader-shell {
  --reader-nav-width: 190px;
  --reader-right-width: 360px;
  display: grid;
  grid-template-columns: var(--reader-nav-width) 8px minmax(360px, 1fr) 8px var(--reader-right-width);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(248, 251, 255, 0.74);
  border-radius: 8px;
  background: var(--panel);
}

.reader-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(8, 13, 30, 0.88);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.reader-sidebar.collapsed {
  --reader-nav-width: 58px;
}

.reader-shell:has(.reader-sidebar.collapsed) {
  grid-template-columns: 58px 8px minmax(360px, 1fr) 8px var(--reader-right-width);
}

.reader-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
}

.reader-sidebar nav {
  display: grid;
  gap: 0.5rem;
  min-height: 0;
  overflow-y: auto;
}

.reader-sidebar nav button {
  min-height: 44px;
  text-align: left;
}

.reader-sidebar.collapsed nav button {
  padding: 0;
}

.reader-sidebar.collapsed nav button::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: auto;
  border-radius: 6px;
  background: var(--accent-gradient);
}

.reader-sidebar.collapsed nav span {
  display: none;
}

.reader-sidebar .active {
  background: var(--accent-gradient);
}

.reader-save-button {
  margin-top: auto;
  min-height: 46px;
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--accent-gradient);
  font-weight: 900;
  text-align: left;
}

.reader-sidebar.collapsed .reader-save-button {
  display: grid;
  place-items: center;
  padding: 0;
}

.reader-sidebar.collapsed .reader-save-button::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 4px;
  box-shadow: inset 0 -5px 0 rgba(255, 255, 255, 0.28);
}

.reader-sidebar.collapsed .reader-save-button span {
  display: none;
}

.resize-handle {
  position: relative;
  background:
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.22), transparent),
    rgba(255, 255, 255, 0.035);
  cursor: col-resize;
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 35% 2px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  opacity: 0.75;
}

.resize-handle:hover,
.resize-handle.dragging {
  background:
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.42), transparent),
    rgba(45, 125, 255, 0.18);
}

body.reader-resizing {
  cursor: col-resize;
  user-select: none;
}

.reader-chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.reader-header h2 {
  margin: 0.2rem 0 0;
}

.reader-feed {
  display: grid;
  align-content: start;
  gap: 0.85rem;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background:
    radial-gradient(circle at 6% 6%, rgba(45, 125, 255, 0.16), transparent 28%),
    rgba(6, 10, 24, 0.42);
}

.reader-content {
  min-height: 0;
  overflow: hidden;
}

.reader-tab-panel {
  display: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 1rem;
  background:
    radial-gradient(circle at 6% 6%, rgba(45, 125, 255, 0.12), transparent 28%),
    rgba(6, 10, 24, 0.3);
}

.reader-tab-panel.active {
  display: block;
}

.reader-tab-panel[data-reader-panel="story"] {
  padding: 0;
}

.reader-chat:not([data-active-panel="story"]) .reader-input {
  display: none;
}

.reader-panel-headline {
  display: grid;
  gap: 0.35rem;
  max-width: 780px;
  margin-bottom: 1rem;
}

.reader-panel-headline h3,
.reader-panel-headline p,
.reader-panel-grid h3,
.reader-panel-grid p,
.reader-panel-empty h3,
.reader-panel-empty p,
.quest-board h3,
.quest-item p,
.archive-timeline h3,
.archive-timeline p {
  margin: 0;
}

.reader-panel-headline h3 {
  font-size: clamp(1.4rem, 2vw, 2.2rem);
  letter-spacing: -0.025em;
}

.reader-panel-headline p:not(.eyebrow),
.reader-panel-grid p,
.reader-panel-empty p,
.quest-item p,
.archive-timeline p {
  color: var(--muted);
  line-height: 1.5;
}

.reader-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.reader-panel-grid article,
.reader-panel-empty,
.reader-table,
.inventory-grid article,
.quest-board article,
.archive-timeline article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.reader-panel-grid article {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem;
}

.reader-panel-empty {
  display: grid;
  place-items: center;
  gap: 0.45rem;
  min-height: 260px;
  padding: 1.2rem;
  text-align: center;
  border-style: dashed;
}

.reader-panel-empty.compact {
  min-height: 170px;
  margin-top: 0.75rem;
}

.reader-table {
  display: grid;
  overflow: hidden;
}

.reader-table > div {
  display: grid;
  grid-template-columns: 1fr 0.9fr 0.9fr 1fr;
  gap: 0.75rem;
  padding: 0.8rem;
}

.reader-table > div:first-child {
  background: rgba(255, 255, 255, 0.06);
  color: var(--blue-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reader-table span {
  color: var(--muted);
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.inventory-grid article {
  display: grid;
  gap: 0.35rem;
  min-height: 110px;
  padding: 0.9rem;
}

.inventory-grid span,
.quest-item span,
.archive-timeline span {
  color: var(--blue-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quest-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.quest-board article {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  min-height: 260px;
  padding: 0.85rem;
}

.quest-item,
.empty-line {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.empty-line {
  color: var(--muted);
}

.archive-timeline {
  display: grid;
  gap: 0.75rem;
}

.archive-timeline article {
  position: relative;
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 0.9rem 0.9rem 1.2rem;
}

.archive-timeline article::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.9rem;
  bottom: 0.9rem;
  width: 3px;
  border-radius: 999px;
  background: var(--accent-gradient);
}

.reader-message {
  max-width: 820px;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.reader-message span {
  color: var(--blue-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-message p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.reader-message.pending p {
  font-style: italic;
  animation: reader-pulse 1.4s ease-in-out infinite;
}

@keyframes reader-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.reader-message.system {
  background: rgba(255, 255, 255, 0.065);
}

.reader-message.player {
  justify-self: end;
  border-color: rgba(255, 255, 255, 0.28);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
}

.reader-message.player span {
  color: var(--ember);
}

.reader-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.reader-input textarea {
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 10, 24, 0.7);
  color: var(--text);
  font: inherit;
  padding: 0.8rem;
}

.reader-right {
  display: grid;
  grid-template-rows: 0.75fr 1.25fr;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.panel-box {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}

.reader-map {
  border-bottom: 2px solid rgba(248, 251, 255, 0.74);
}

.reader-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.reader-panel-head h3 {
  margin: 0.18rem 0 0;
}

.locked-pill {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.map-controls {
  display: flex;
  gap: 0.4rem;
  margin-top: 1rem;
}

.map-controls button {
  padding: 0.42rem 0.58rem;
  font-size: 0.82rem;
  font-weight: 900;
}

.map-viewport {
  position: relative;
  min-height: 230px;
  margin-top: 0.6rem;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 35% 35%, rgba(45, 125, 255, 0.18), transparent 28%),
    radial-gradient(circle at 72% 68%, rgba(255, 106, 31, 0.14), transparent 30%),
    rgba(255, 255, 255, 0.035);
  background-size: 28px 28px, 28px 28px, auto, auto, auto;
  text-align: center;
  overscroll-behavior: contain;
  cursor: grab;
  touch-action: none;
}

.map-viewport.dragging {
  cursor: grabbing;
}

.world-map {
  position: absolute;
  inset: 0;
  transform-origin: center;
  transition: transform 160ms ease;
}

.world-map::after {
  content: attr(data-zoom-scope);
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 10, 24, 0.74);
  color: var(--blue-soft);
  font-size: 0.72rem;
  font-weight: 900;
}

.map-region {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 42px;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.region-forest {
  left: 12%;
  top: 22%;
}

.region-city {
  right: 13%;
  top: 34%;
}

.region-mountains {
  left: 35%;
  bottom: 16%;
}

.map-marker {
  position: absolute;
  left: 49%;
  top: 47%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-gradient);
  box-shadow: 0 0 26px rgba(45, 125, 255, 0.42);
  font-size: 1.2rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.map-viewport p {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  margin: 0;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 10, 24, 0.72);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.status-profile {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.status-profile div,
.skill-list {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.status-profile span,
.skill-list span {
  color: var(--muted);
  font-size: 0.85rem;
}

.skill-list {
  margin-top: 0.75rem;
}

.name-modal.visible {
  display: grid;
}

.name-dialog,
.login-dialog {
  width: min(100%, 520px);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent),
    var(--panel-strong);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.45);
}

.name-dialog img,
.login-dialog img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 32px rgba(45, 125, 255, 0.35);
}

.name-dialog h2,
.name-dialog p,
.login-dialog h2,
.login-dialog p {
  margin: 0;
}

.name-dialog h2,
.login-dialog h2 {
  margin-top: 0.35rem;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
}

.name-dialog p:not(.eyebrow),
.login-dialog p:not(.eyebrow) {
  margin-top: 0.6rem;
  color: var(--muted);
  line-height: 1.5;
}

.name-dialog form,
.login-dialog form {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.name-dialog form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.settings-page,
.admin-page,
.import-page,
.memory-page {
  gap: 1rem;
}

.import-layout,
.memory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 1rem;
  align-items: start;
}

.import-panel,
.import-preview,
.memory-main,
.memory-side {
  display: grid;
  gap: 1rem;
}

.import-panel,
.import-preview .settings-card,
.memory-list,
.memory-overview article,
.memory-toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.import-panel {
  padding: 1rem;
}

.import-panel textarea,
.memory-note-form textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 10, 24, 0.7);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  padding: 0.85rem;
}

.memory-note-form textarea {
  min-height: 130px;
}

.import-actions,
.data-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.import-stat-grid,
.memory-overview,
.settings-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.import-stat-grid div,
.settings-plan-grid div {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.import-stat-grid span,
.memory-overview span,
.settings-plan-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.import-stat-grid b,
.memory-overview b {
  font-size: 1.65rem;
}

.import-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.import-chip-list span {
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #dce7ff;
  font-size: 0.84rem;
  font-weight: 800;
}

.memory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.memory-toolbar input {
  max-width: 420px;
}

.memory-overview {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.memory-overview article {
  display: grid;
  gap: 0.12rem;
  padding: 1rem;
}

.memory-overview small {
  color: var(--muted);
}

.memory-list {
  display: grid;
  gap: 0.75rem;
  max-height: calc(100vh - 310px);
  overflow-y: auto;
  padding: 1rem;
}

.memory-entry {
  display: grid;
  gap: 0.55rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.memory-entry div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.memory-entry h3,
.memory-entry p,
.settings-plan-grid p {
  margin: 0;
}

.memory-entry p,
.settings-plan-grid p {
  color: var(--muted);
  line-height: 1.45;
}

.memory-note-form,
.preferences-form {
  display: grid;
  gap: 0.75rem;
}

.preferences-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.preferences-form button,
.toggle-row {
  grid-column: 1 / -1;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.toggle-row input {
  width: auto;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  gap: 1rem;
  align-items: start;
}

.settings-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.settings-card h3,
.settings-card p,
.form-message {
  margin: 0;
}

.settings-card p:not(.eyebrow),
.form-message {
  color: var(--muted);
  line-height: 1.45;
}

.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
}

.password-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
}

.account-list {
  display: grid;
  gap: 0.65rem;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.account-row strong {
  display: block;
}

.account-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.remember-login {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.remember-login input {
  width: auto;
}

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-switch button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue-soft);
  font-weight: 900;
  text-decoration: underline;
}

.signup-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.signup-head {
  display: grid;
  gap: 0.3rem;
}

.signup-head h3,
.signup-head p {
  margin: 0;
}

.signup-head p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.4;
}

.plan-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.plan-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.15rem 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  cursor: pointer;
}

.plan-choice input {
  width: auto;
  grid-row: span 2;
  margin-top: 0.2rem;
}

.plan-choice strong {
  font-size: 0.95rem;
}

.plan-choice span,
.plan-feature-tags span {
  color: var(--muted);
  font-size: 0.84rem;
}

.plan-choice:has(input:checked) {
  border-color: rgba(255, 255, 255, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel);
}

.plan-feature-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.plan-feature-tags span {
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #dce7ff;
  font-weight: 800;
}

.home-cards article {
  min-height: 116px;
  padding: 1rem;
}

.home-cards h3 {
  margin-top: 0.35rem;
  font-size: 1.05rem;
}

.home-cards p {
  margin-top: 0.42rem;
  line-height: 1.42;
}

.home-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
}

.resume-card,
.mood-card {
  display: grid;
  align-content: space-between;
  gap: 1rem;
  min-height: 170px;
  padding: 1rem;
}

.resume-card {
  background:
    radial-gradient(circle at 14% 18%, rgba(45, 125, 255, 0.22), transparent 32%),
    radial-gradient(circle at 92% 20%, rgba(255, 106, 31, 0.18), transparent 32%),
    var(--panel);
}

.resume-card.empty {
  border-style: dashed;
}

.resume-card h3,
.mood-card h3,
.placeholder-page h2,
.placeholder-page p {
  margin: 0;
}

.resume-card h3,
.mood-card h3 {
  margin-top: 0.3rem;
  font-size: 1.28rem;
}

.resume-card p,
.mood-card p,
.placeholder-page p {
  margin-top: 0.45rem;
  color: var(--muted);
  line-height: 1.45;
}

.resume-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.resume-stats span {
  padding: 0.4rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #dce7ff;
  font-size: 0.84rem;
  font-weight: 800;
}

.placeholder-page {
  align-content: center;
  min-height: calc(100vh - 2rem);
  padding: clamp(1.2rem, 4vw, 4rem);
}

.placeholder-page h2 {
  font-size: clamp(2.2rem, 5vw, 5rem);
  letter-spacing: -0.04em;
}

.stories-page {
  gap: 1rem;
}

.story-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.story-library-toolbar input {
  max-width: 420px;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-tabs button {
  padding: 0.55rem 0.7rem;
  box-shadow: none;
}

.filter-tabs .active {
  background: var(--accent-gradient);
  border-color: rgba(255, 255, 255, 0.28);
}

.story-library-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 1rem;
  align-items: start;
}

.story-card-list {
  display: grid;
  gap: 0.85rem;
}

.story-card {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.story-card .small-delete,
.story-card .small-continue {
  justify-self: start;
  padding: 0.45rem 0.62rem;
  font-size: 0.82rem;
}

.story-card .small-continue {
  margin-right: 0.35rem;
}

.empty-library {
  min-height: 420px;
}

.empty-state-card {
  display: grid;
  align-content: center;
  gap: 0.8rem;
  min-height: 420px;
  padding: 1.2rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  text-align: center;
}

.empty-state-card h3,
.empty-state-card p {
  margin: 0;
}

.empty-state-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

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

.story-card.active {
  border-color: rgba(255, 255, 255, 0.36);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel);
}

.story-card-top,
.story-meta,
.story-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.story-card-top {
  justify-content: space-between;
}

.story-card h3,
.story-card p,
.story-summary h3,
.story-summary p {
  margin: 0;
}

.story-card p,
.story-summary p {
  color: var(--muted);
  line-height: 1.45;
}

.story-state,
.story-card-top span:last-child,
.story-meta span {
  width: fit-content;
  padding: 0.32rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #dce7ff;
  font-size: 0.78rem;
  font-weight: 800;
}

.story-state.active {
  background: rgba(53, 216, 137, 0.18);
}

.story-state.draft {
  background: rgba(255, 209, 92, 0.16);
}

.story-state.imported {
  background: rgba(45, 125, 255, 0.18);
}

.story-detail-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.story-detail-cover {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 220px;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cover-gradient);
}

.story-detail-cover::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 8px;
  background:
    linear-gradient(100deg, rgba(5, 11, 30, 0.35), rgba(8, 8, 18, 0.08)),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 13px);
}

.story-detail-cover span,
.story-detail-cover strong {
  position: relative;
  z-index: 1;
}

.story-detail-cover span {
  color: var(--blue-soft);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-detail-cover strong {
  margin-top: 0.2rem;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.story-summary {
  display: grid;
  gap: 0.45rem;
}

.story-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.story-status-grid div {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.story-status-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.story-status-grid b {
  line-height: 1.35;
}

.music-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 760px;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.music-strip div:first-child {
  display: grid;
  gap: 0.16rem;
}

.music-strip strong {
  font-size: 1rem;
}

.music-strip span {
  color: var(--muted);
  font-size: 0.88rem;
}

.music-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.music-actions .selected {
  border-color: rgba(255, 255, 255, 0.32);
  background: var(--accent-gradient);
}

.music-page {
  gap: 1rem;
}

.music-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  gap: 1rem;
  align-items: start;
}

.music-locked-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 209, 92, 0.18), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(45, 125, 255, 0.16), transparent 32%),
    var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.music-locked-card h3,
.music-locked-card p {
  margin: 0;
}

.music-locked-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.music-player-card,
.music-library-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.music-player-card {
  background:
    radial-gradient(circle at 18% 12%, rgba(45, 125, 255, 0.2), transparent 34%),
    radial-gradient(circle at 82% 20%, rgba(255, 106, 31, 0.16), transparent 32%),
    var(--panel);
}

.music-player-card h3,
.music-player-card p,
.music-library-head h3,
.music-empty-state h3,
.music-empty-state p,
.track-row h3,
.track-row p {
  margin: 0;
}

.music-player-card h3,
.music-library-head h3 {
  font-size: clamp(1.25rem, 2vw, 2rem);
}

.music-player-card p:not(.eyebrow),
.music-empty-state p,
.track-row p,
.music-hint span {
  color: var(--muted);
  line-height: 1.45;
}

.music-player-card audio {
  width: 100%;
}

.file-pick-button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0.72rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  font-weight: 900;
}

.file-pick-button input {
  display: none;
}

.music-hint {
  display: grid;
  gap: 0.45rem;
}

.music-hint span {
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.9rem;
}

.music-library-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.music-file-list {
  display: grid;
  gap: 0.65rem;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

.music-empty-state {
  display: grid;
  place-items: center;
  gap: 0.45rem;
  min-height: 260px;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  text-align: center;
}

.track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.track-row.playing {
  border-color: rgba(255, 255, 255, 0.32);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--panel);
}

.track-row h3 {
  font-size: 1rem;
}

.track-row p {
  margin-top: 0.22rem;
  font-size: 0.86rem;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .landing {
    grid-template-columns: 1fr;
  }

  .cover-art {
    max-height: 360px;
    width: min(100%, 360px);
  }
}

@media (max-width: 820px) {
  body {
    overflow-x: hidden;
    min-height: 100dvh;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    height: auto;
    max-height: none;
    display: grid;
    gap: 0.35rem;
    padding: 0.62rem 0.75rem 0.55rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    background: rgba(7, 10, 24, 0.96);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  }

  .brand {
    order: 1;
    padding: 0.25rem;
    min-height: 48px;
  }

  .mobile-menu-toggle {
    display: grid;
    place-items: center;
    gap: 0.2rem;
    width: 48px;
    height: 48px;
    margin-left: auto;
    padding: 0;
    border: 2px solid #b244ff;
    border-radius: 8px;
    background: rgba(178, 68, 255, 0.12);
    color: #c86cff;
    box-shadow: 0 0 22px rgba(178, 68, 255, 0.3);
  }

  .mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: currentColor;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .brand h1 {
    font-size: 1.45rem;
    line-height: 1;
    letter-spacing: -0.02em;
  }

  .brand p,
  .sidebar-card,
  .sidebar-toggle {
    display: none;
  }

  .side-nav {
    position: fixed !important;
    top: 5.35rem !important;
    right: 0.65rem !important;
    bottom: auto !important;
    left: auto !important;
    order: 2;
    z-index: 45;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    width: min(78vw, 320px);
    max-height: calc(100dvh - 6.3rem);
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 0.35rem;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(7, 10, 24, 0.98);
    backdrop-filter: blur(18px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
    opacity: 0;
    pointer-events: none;
    transform: translateX(110%);
    transition: opacity 180ms ease, transform 180ms ease;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-nav-open .side-nav {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .side-nav button {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    grid-template-columns: 32px minmax(0, 1fr);
    justify-items: start;
    gap: 0.14rem 0.65rem;
    padding: 0.55rem;
    text-align: left;
    font-size: 0.9rem;
  }

  .side-nav i {
    width: 28px;
    height: 28px;
    grid-row: auto;
  }

  .side-nav button small,
  .side-nav [data-admin-nav][hidden] {
    display: none;
  }

  .sidebar-collapsed .sidebar {
    padding: 0.65rem;
    display: grid;
  }

  .sidebar-collapsed .brand {
    order: 1;
    justify-content: flex-start;
  }

  .sidebar-collapsed .brand div,
  .sidebar-collapsed .side-nav span {
    display: block;
  }

  .sidebar-collapsed .side-nav button {
    grid-template-columns: 1fr;
    min-height: 58px;
    padding: 0.42rem 0.5rem;
  }

  .sidebar-collapsed .side-nav {
    position: fixed !important;
    top: 5.35rem !important;
    right: 0.65rem !important;
    bottom: auto !important;
    left: auto !important;
    order: 2;
  }

  .sidebar-collapsed .side-nav i {
    place-self: center;
  }

  .home-cards,
  .story-library-layout,
  .story-status-grid,
  .setup-steps,
  .setup-layout,
  .field-grid,
  .companion-grid,
  .tracking-grid {
    grid-template-columns: 1fr;
  }

  .story-library-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .story-library-toolbar input {
    max-width: none;
  }

  .workspace,
  .home {
    min-height: auto;
    grid-template-rows: auto;
  }

  .workspace {
    padding: 5.15rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
  }

  .page-header {
    display: grid;
    gap: 0.85rem;
    padding: 0.9rem;
  }

  .page-header h2 {
    font-size: clamp(1.25rem, 6vw, 1.75rem);
    line-height: 1.15;
  }

  .header-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .header-actions button,
  .header-actions .file-pick-button {
    width: 100%;
  }

  .home-dashboard {
    grid-template-columns: 1fr;
  }

  .settings-layout,
  .music-layout,
  .import-layout,
  .memory-layout,
  .memory-overview {
    grid-template-columns: 1fr;
  }

  .memory-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .memory-toolbar input {
    max-width: none;
  }

  .music-file-list {
    max-height: 420px;
  }

  .landing {
    padding: 1rem;
    min-height: auto;
  }

  .landing h2 {
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.02;
    letter-spacing: -0.025em;
  }

  .cover-panel {
    display: none;
  }

  .theme-switcher {
    overflow-x: auto;
    width: 100%;
  }

  .home-cards,
  .home-dashboard,
  .setup-main,
  .setup-side,
  .story-card-list,
  .import-panel,
  .import-preview,
  .memory-main,
  .memory-side,
  .settings-layout {
    gap: 0.75rem;
  }

  .import-panel textarea {
    min-height: 260px;
  }

  .memory-list {
    max-height: none;
  }

  .story-card,
  .settings-card,
  .setup-card,
  .music-player-card,
  .music-library-card,
  .music-locked-card,
  .import-panel,
  .memory-list,
  .memory-overview article {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
  }

  .reader-page {
    height: calc(100dvh - 10.15rem - env(safe-area-inset-bottom));
    min-height: 560px;
    overflow: hidden;
  }

  .reader-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
  }

  .reader-shell:has(.reader-sidebar.collapsed) {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .resize-handle {
    display: none;
  }

  .reader-sidebar,
  .reader-sidebar.collapsed {
    width: auto;
    min-height: 0;
    padding: 0.55rem;
    border-right: 0;
    border-bottom: 2px solid rgba(248, 251, 255, 0.74);
  }

  .reader-toggle {
    display: none;
  }

  .reader-sidebar nav {
    display: flex;
    overflow-x: auto;
    gap: 0.4rem;
  }

  .mobile-reader-tab {
    display: block;
  }

  .reader-sidebar nav button,
  .reader-sidebar.collapsed nav button {
    min-width: 98px;
    min-height: 40px;
    padding: 0.5rem 0.65rem;
    text-align: center;
  }

  .reader-sidebar.collapsed nav button::before {
    display: none;
  }

  .reader-sidebar.collapsed nav span {
    display: inline;
  }

  .reader-save-button,
  .reader-sidebar.collapsed .reader-save-button {
    min-width: 112px;
    min-height: 40px;
    padding: 0.5rem 0.7rem;
    text-align: center;
  }

  .reader-sidebar.collapsed .reader-save-button::before {
    display: none;
  }

  .reader-sidebar.collapsed .reader-save-button span {
    display: inline;
  }

  .reader-chat {
    border-right: 0;
  }

  .reader-right {
    display: none;
  }

  .reader-shell[data-mobile-reader-tab="map"] .reader-chat,
  .reader-shell[data-mobile-reader-tab="status"] .reader-chat {
    display: none;
  }

  .reader-shell[data-mobile-reader-tab="map"] .reader-right,
  .reader-shell[data-mobile-reader-tab="status"] .reader-right {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
  }

  .reader-shell[data-mobile-reader-tab="map"] .reader-status,
  .reader-shell[data-mobile-reader-tab="status"] .reader-map {
    display: none;
  }

  .reader-shell[data-mobile-reader-tab="map"] .reader-map,
  .reader-shell[data-mobile-reader-tab="status"] .reader-status {
    min-height: 0;
    overflow-y: auto;
  }

  .reader-header {
    padding: 0.75rem;
  }

  .reader-header h2 {
    font-size: 1.15rem;
  }

  .reader-feed,
  .reader-tab-panel {
    padding: 0.75rem;
  }

  .reader-tab-panel[data-reader-panel="story"] {
    padding: 0;
  }

  .reader-input {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .reader-input textarea {
    min-height: 76px;
  }

  .reader-message {
    max-width: 100%;
  }

  .panel-box {
    padding: 0.75rem;
  }

  .map-viewport {
    min-height: 180px;
  }

  .reader-panel-grid,
  .inventory-grid,
  .quest-board {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .sidebar {
    padding: 0.55rem 0.65rem;
  }

  .workspace,
  .home {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .primary-actions button {
    width: 100%;
  }

  .page-header,
  .header-actions,
  .theme-switcher {
    align-items: stretch;
    flex-direction: column;
  }

  .side-nav {
    top: 5rem !important;
    right: 0.45rem !important;
    width: min(84vw, 310px);
    padding: 0.55rem;
  }

  .side-nav button {
    min-width: 0;
    min-height: 54px;
    padding: 0.5rem;
    font-size: 0.86rem;
  }

  .side-nav i {
    width: 26px;
    height: 26px;
  }

  .brand {
    min-height: 44px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .brand h1 {
    font-size: 1.32rem;
  }

  .music-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .name-dialog form {
    grid-template-columns: 1fr;
  }

  .name-dialog,
  .login-dialog {
    width: min(100%, calc(100vw - 1.2rem));
    max-height: calc(100dvh - 1.2rem);
    padding: 1rem;
  }

  .workspace {
    padding-top: 4.85rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  .page-header {
    padding: 0.8rem;
  }

  .setup-card,
  .story-detail-panel,
  .story-library-toolbar {
    padding: 0.8rem;
  }

  .reader-page {
    height: calc(100dvh - 5.45rem - env(safe-area-inset-bottom));
    min-height: 620px;
  }

  .reader-shell {
    border-width: 1px;
  }

  .reader-right {
    grid-template-rows: 1fr;
  }

  .map-controls {
    flex-wrap: wrap;
  }

  .music-library-head,
  .account-form,
  .password-form,
  .account-row,
  .preferences-form,
  .import-stat-grid,
  .settings-plan-grid,
  .plan-choice-grid,
  .memory-overview,
  .track-row {
    grid-template-columns: 1fr;
  }

  .landing-copy {
    gap: 0.85rem;
  }

  .trust-row span,
  .resume-stats span,
  .import-chip-list span,
  .plan-feature-tags span {
    font-size: 0.78rem;
  }

  .story-card .small-delete,
  .story-card .small-continue {
    width: 100%;
    justify-self: stretch;
  }

  .music-library-head {
    display: grid;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  body {
    overflow: hidden;
  }

  body::before {
    content: "Bitte Handy hochkant drehen";
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
      radial-gradient(circle at 18% 20%, rgba(45, 125, 255, 0.34), transparent 32%),
      linear-gradient(135deg, #070914, #10182f);
    color: var(--text);
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    font-weight: 900;
    text-align: center;
  }

  body::after {
    content: "Die Isekai Engine ist auf dem Handy fuer Hochkant optimiert.";
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: calc(50% + 3.2rem);
    z-index: 10000;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.45;
    text-align: center;
  }

  .app-shell,
  .name-modal,
  .login-modal,
  .confirm-modal {
    pointer-events: none;
    filter: blur(8px);
  }
}

/* ==========================================================
   Feinschliff 2026-10 (Claude): flüssigere Bedienung,
   Lesemodus im Reader, Icons, Übergänge
   ========================================================== */

:root {
  --read-font: "Literata", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Bedien-Feedback */
button,
a,
input,
select,
textarea {
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease,
    transform 120ms ease,
    opacity 140ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--blue-soft);
  outline-offset: 2px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
  outline: none;
}

/* Seitenwechsel: kurze Einblendung als Antwort auf den Klick */
.page.active {
  animation: page-in 240ms var(--ease-out);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Reader-Seitenleiste mit Icons ---------- */
.tab-icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reader-sidebar nav button,
.reader-save-button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.reader-sidebar nav button:not(.active) {
  color: var(--muted);
}

.reader-sidebar nav button:not(.active):hover {
  color: var(--text);
}

.reader-sidebar.collapsed nav button,
.reader-sidebar.collapsed .reader-save-button {
  justify-content: center;
  padding: 0;
}

.reader-sidebar.collapsed nav button::before,
.reader-sidebar.collapsed .reader-save-button::before {
  content: none;
  display: none;
}

.reader-sidebar.collapsed .reader-save-button {
  display: flex;
}

.reader-shell {
  transition: grid-template-columns 220ms var(--ease-out);
}

/* ---------- Lesemodus ---------- */
.reader-feed {
  scroll-behavior: smooth;
  gap: 1.35rem;
  padding-bottom: 2rem;
}

.reader-feed > .reader-message {
  width: 100%;
  max-width: 68ch;
  margin-inline: auto;
}

.reader-message.narrator {
  padding: 0 0.25rem;
  border: 0;
  background: none;
}

.reader-message.narrator span {
  display: none;
}

.reader-message.narrator p + p {
  margin-top: 1.05em;
}

.reader-message.narrator p {
  margin: 0;
  color: color-mix(in srgb, var(--text) 90%, var(--muted));
  font-family: var(--read-font);
  font-size: 1.09rem;
  line-height: 1.78;
  letter-spacing: 0.002em;
}

/* Systemfenster wie im Manhwa: [Skill erhalten: ...] */
.reader-message.narrator p.system-window {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 0.6rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--blue-soft) 55%, transparent);
  border-radius: 6px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--blue) 22%, transparent), color-mix(in srgb, var(--blue) 8%, transparent));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--blue) 18%, transparent) inset,
    0 0 24px color-mix(in srgb, var(--blue) 28%, transparent);
  color: var(--ember);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.reader-message.player {
  justify-self: stretch;
  max-width: 68ch;
  padding: 0.7rem 0.95rem;
  border: 0;
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--blue) 10%, transparent);
}

.reader-message.player span {
  color: var(--blue-soft);
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: none;
}

.reader-message.player p {
  margin-top: 0.15rem;
  color: var(--text);
}

.reader-message.system {
  padding: 0.55rem 0.85rem;
  border: 1px dashed var(--line);
  background: none;
  text-align: center;
}

.reader-message.system span {
  display: none;
}

.reader-message.system p {
  margin: 0;
  font-size: 0.88rem;
}

.reader-message.fresh {
  animation: message-in 320ms var(--ease-out);
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* "Erzähler schreibt" – drei pulsierende Punkte statt Text */
.reader-message.pending p {
  display: flex;
  gap: 0.4rem;
  font-size: 0;
  animation: none;
  font-style: normal;
}

.reader-message.pending p::before,
.reader-message.pending p::after,
.reader-message.pending .dot {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-soft);
  animation: typing 1.1s ease-in-out infinite;
}

.reader-message.pending .dot {
  animation-delay: 0.18s;
}

.reader-message.pending p::after {
  animation-delay: 0.36s;
}

@keyframes typing {
  0%, 80%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* Eingabe */
.reader-input {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) auto;
}

.reader-input textarea {
  min-height: 52px;
  max-height: 220px;
  resize: none;
  line-height: 1.5;
  overflow-y: auto;
}

.reader-input [data-reader-send] {
  min-height: 52px;
  min-width: 96px;
}

.reader-input-hint {
  grid-column: 1 / -1;
  margin: -0.3rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  opacity: 0.8;
}

/* ---------- Rechte Spalte: Karte + Status ---------- */
.reader-right {
  grid-template-rows: auto minmax(0, 1fr);
}

.reader-map {
  overflow: visible;
}

.map-viewport {
  min-height: 200px;
}

.map-caption {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ---------- Bewegung reduzieren, wenn gewünscht ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 760px) {
  .reader-message.narrator p {
    font-size: 1.02rem;
    line-height: 1.72;
  }

  .reader-input-hint {
    display: none;
  }

  .reader-input [data-reader-send] {
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .theme-switcher {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .theme-switcher button {
    min-height: 38px;
    padding: 0.45rem 0.5rem;
  }
}

@media (max-width: 820px) {
  .reader-sidebar nav {
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .reader-sidebar nav button,
  .reader-sidebar.collapsed nav button {
    display: flex;
    flex: none;
    min-width: 0;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .reader-sidebar.collapsed nav span {
    display: inline;
  }

  .mobile-reader-tab {
    display: flex;
  }
}

/* ===== Spielstand-Dateien (NPCs, Inventar, Quests, Archiv, Status) ===== */
.npc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.npc-card {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.npc-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.npc-card h3,
.npc-card p {
  margin: 0;
}

.npc-card header span,
.npc-card footer {
  color: var(--blue-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.npc-card p {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.npc-card p b {
  color: inherit;
  font-weight: 700;
  opacity: 0.9;
}

.inventory-grid article b {
  display: block;
}

.inventory-grid article small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.inventory-grid .money-card b {
  font-size: 1.15rem;
}

.archive-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.archive-hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.reader-message.savegame-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.reader-message.savegame-note p {
  color: var(--blue-soft);
}

.savegame-undo {
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

.skill-list[data-status-skills] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.skill-list[data-status-skills] .eyebrow {
  flex-basis: 100%;
  margin: 0;
}

@media (max-width: 760px) {
  .inventory-grid,
  .quest-board {
    grid-template-columns: 1fr;
  }
}
