/* ==========================================================================
   Narrative TRPG Engine — Mobile Web Playroom (Touch-First, 100dvh, Safe-Area)
   ========================================================================== */

:root {
  --bg-void: #070a12;
  --bg-deep: #0b101d;
  --bg-panel: rgba(16, 23, 38, 0.9);
  --bg-card: rgba(20, 29, 46, 0.92);
  --bg-elevated: rgba(26, 37, 59, 0.95);
  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(212, 163, 89, 0.45);

  --text-primary: #ece7dc;
  --text-secondary: #aab5ca;
  --text-muted: #76849c;

  --accent-amber: #d4a359;
  --accent-amber-soft: rgba(212, 163, 89, 0.16);
  --accent-teal: #57b5b0;
  --accent-teal-soft: rgba(87, 181, 176, 0.15);
  --accent-indigo: #7c8cf8;
  --accent-indigo-soft: rgba(124, 140, 248, 0.16);
  --accent-crimson: #e05a6d;
  --accent-crimson-soft: rgba(224, 90, 109, 0.16);
  --accent-green: #4ade80;

  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Backdrop & Atmosphere */
.scene-backdrop-layer {
  pointer-events: none;
  position: fixed;
  inset: -4%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.9;
  transition: background-image 0.8s ease, opacity 0.8s ease;
  filter: saturate(0.84) brightness(0.56);
}

.scene-backdrop-layer.has-image {
  opacity: 0.46;
}

.scene-backdrop-scrim {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, rgba(6, 9, 18, 0.78) 0%, rgba(7, 11, 21, 0.65) 45%, rgba(5, 8, 16, 0.92) 100%);
}

.atmosphere-canvas {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
}

.scene-transition-banner {
  pointer-events: none;
  position: fixed;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  width: min(86vw, 340px);
  padding: 16px 20px;
  border-radius: 14px;
  background: rgba(7, 11, 22, 0.92);
  border: 1px solid var(--border-strong);
  text-align: center;
  opacity: 0;
}

.scene-transition-banner.show {
  animation: mSceneFade 2.1s ease forwards;
}

@keyframes mSceneFade {
  0% { opacity: 0; transform: translate(-50%, -44%) scale(0.96); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(1.02); }
}

.scene-transition-eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--accent-amber);
}

.scene-transition-title {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

/* Main Mobile App Shell */
.mobile-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* Header */
.m-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: rgba(9, 13, 24, 0.88);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}

.m-header-left {
  min-width: 0;
  flex: 1;
}

.m-scene-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-scene-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-dot-sep {
  opacity: 0.45;
}

.m-status-text.status-running { color: var(--accent-teal); }
.m-status-text.status-ended { color: var(--accent-amber); }
.m-status-text.status-paused { color: var(--accent-crimson); }

.m-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.m-icon-pill,
.m-host-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(20, 29, 46, 0.85);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.m-host-pill {
  max-width: 136px;
}

#mHostPillText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-ok { background: var(--accent-green); box-shadow: 0 0 8px rgba(74, 222, 128, 0.7); }
.dot-pending { background: var(--accent-amber); }
.dot-error { background: var(--accent-crimson); }

/* Main Tabs Area */
.m-main {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.m-tab-panel {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.m-tab-panel.active {
  display: flex;
}

/* Stage Tab */
.m-ambient-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(11, 16, 29, 0.65);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  flex-shrink: 0;
}

.m-tag-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.m-tag-scroll::-webkit-scrollbar { display: none; }

.m-mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
  border: 1px solid rgba(212, 163, 89, 0.35);
  flex-shrink: 0;
}

.m-agent-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(212, 163, 89, 0.12);
  border-bottom: 1px solid rgba(212, 163, 89, 0.28);
  flex-shrink: 0;
}

.m-agent-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--accent-amber);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-amber);
}

.pulse-dot.running {
  animation: pulseAnim 1.2s infinite;
}

@keyframes pulseAnim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.m-agent-btns {
  display: flex;
  gap: 6px;
}

/* Story Feed */
.m-story-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.story-card {
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.card-scene-intro {
  border-color: rgba(212, 163, 89, 0.35);
  background: linear-gradient(180deg, rgba(28, 36, 56, 0.92), rgba(16, 22, 36, 0.92));
}

.card-protagonist {
  border-left: 3px solid var(--accent-amber);
}

.card-npc {
  border-left: 3px solid var(--accent-teal);
}

.card-interrupt {
  border-left: 3px solid var(--accent-indigo);
}

.card-rejection {
  border-color: rgba(224, 90, 109, 0.45);
  background: rgba(48, 18, 28, 0.85);
}

.card-system {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(15, 22, 36, 0.78);
}

.story-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.speaker-tag {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.speaker-dm { color: var(--accent-amber); }
.speaker-protag { color: var(--accent-amber); }
.speaker-npc { color: var(--accent-teal); }
.speaker-rejection { color: var(--accent-crimson); }
.speaker-system { color: var(--text-secondary); }

.turn-stamp {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.interrupt-pill {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  background: var(--accent-indigo-soft);
  color: var(--accent-indigo);
  border: 1px solid rgba(124, 140, 248, 0.35);
}

.narration-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.world-bg-note {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(148, 163, 184, 0.18);
  font-size: 13px;
  color: var(--text-secondary);
}

.dialogue-box {
  margin-top: 9px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(8, 12, 22, 0.56);
  border-left: 2px solid var(--accent-amber);
  font-size: 14.5px;
}

.dialogue-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.clue-callout {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(87, 181, 176, 0.12);
  border: 1px solid rgba(87, 181, 176, 0.28);
  font-size: 13px;
  color: #cbece9;
}

.clue-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-teal);
  margin-bottom: 3px;
}

.card-ending {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(212, 163, 89, 0.16);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
}

.card-ending-title {
  font-weight: 700;
  color: var(--accent-amber);
  margin-bottom: 4px;
}

/* Live Banner & Retry */
.m-live-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(124, 140, 248, 0.14);
  border-top: 1px solid rgba(124, 140, 248, 0.3);
  font-size: 12px;
  flex-shrink: 0;
}

.m-live-left, .m-live-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#mLiveStage {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-indigo);
  animation: pulseAnim 1s infinite;
  flex-shrink: 0;
}

.m-retry-bar {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 12px;
  background: rgba(224, 90, 109, 0.18);
  border-top: 1px solid rgba(224, 90, 109, 0.42);
  color: #ffd4da;
  font-size: 12.5px;
  flex-shrink: 0;
}

/* Composer */
.m-composer {
  padding: 8px 12px 10px;
  background: rgba(9, 13, 24, 0.92);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}

.m-quick-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 7px;
  scrollbar-width: none;
}

.m-quick-bar::-webkit-scrollbar { display: none; }

.m-chip-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(22, 31, 50, 0.88);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.m-chip-amber {
  border-color: rgba(212, 163, 89, 0.42);
  color: var(--accent-amber);
}

.m-chip-danger {
  border-color: rgba(224, 90, 109, 0.4);
  color: #f49ca8;
}

.m-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.m-textarea {
  flex: 1;
  min-height: 46px;
  max-height: 112px;
  resize: none;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 22, 37, 0.96);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  outline: none;
}

.m-textarea:focus {
  border-color: var(--accent-amber);
}

.m-send-btn {
  min-width: 68px;
  padding: 0 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #d4a359, #b5823b);
  color: #120d05;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.m-send-btn:disabled {
  opacity: 0.45;
}

/* Status & Settings Scroll Panels */
.m-scroll-pad {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.m-card {
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.m-card-highlight {
  border-color: var(--border-strong);
  box-shadow: 0 8px 26px rgba(212, 163, 89, 0.08);
}

.m-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.m-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent-amber);
}

.m-card-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.m-muted-text {
  margin: 4px 0 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.m-stat-group {
  margin-top: 10px;
}

.m-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.m-tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(25, 36, 58, 0.85);
  color: var(--text-secondary);
}

.tag-ambient { color: #bcd5f6; border-color: rgba(124, 162, 224, 0.3); }
.tag-physical { color: #f6c38d; border-color: rgba(212, 163, 89, 0.38); background: rgba(212, 163, 89, 0.12); }
.tag-mental { color: #c7ceff; border-color: rgba(124, 140, 248, 0.38); background: rgba(124, 140, 248, 0.12); }
.tag-item { color: #9ee8e3; border-color: rgba(87, 181, 176, 0.38); background: rgba(87, 181, 176, 0.12); }
.tag-danger { color: #ffb3be; border-color: rgba(224, 90, 109, 0.45); background: rgba(224, 90, 109, 0.15); }
.tag-clickable { cursor: pointer; }

.m-agent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.m-agent-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(11, 16, 29, 0.72);
  border: 1px solid var(--border-subtle);
}

.m-agent-name {
  font-weight: 600;
  font-size: 14px;
}

/* Memory Meter */
.m-meter-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.m-meter-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
  margin-bottom: 10px;
}

.m-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-amber));
  transition: width 0.3s ease;
}

.m-memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-memory-item {
  padding: 10px 11px;
  border-radius: 10px;
  background: rgba(10, 15, 27, 0.75);
  border: 1px solid var(--border-subtle);
}

.m-memory-top {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.m-memory-content {
  margin: 0;
  font-size: 13.5px;
}

/* Form Controls */
.m-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.m-field-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.m-text-input,
.m-select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 15, 27, 0.92);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
}

.m-text-input:focus,
.m-select:focus {
  border-color: var(--accent-amber);
}

.m-inline-row {
  display: flex;
  gap: 8px;
}

.m-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.m-btn-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-btn {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.m-btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12.5px;
}

.m-btn-xs {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.m-btn-amber {
  background: linear-gradient(135deg, #d4a359, #b5823b);
  color: #140d04;
}

.m-btn-ghost {
  background: rgba(24, 34, 54, 0.88);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.m-btn:disabled {
  opacity: 0.45;
}

.m-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(10, 15, 27, 0.85);
  border: 1px solid var(--border-subtle);
}

.m-mode-btn {
  min-height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.m-mode-btn.active {
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
}

.m-host-feedback {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  background: rgba(87, 181, 176, 0.12);
  border: 1px solid rgba(87, 181, 176, 0.35);
  color: #cef4f1;
}

.m-host-feedback.is-error {
  background: rgba(224, 90, 109, 0.14);
  border-color: rgba(224, 90, 109, 0.4);
  color: #ffd2d8;
}

.m-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 14px 0;
}

.m-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 14px;
}

.m-toggle-row:last-of-type {
  border-bottom: none;
}

.m-switch {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-amber);
}

.m-range {
  width: 140px;
  accent-color: var(--accent-amber);
}

/* Director Tabs */
.m-seg-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.m-seg-btn {
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(12, 18, 32, 0.8);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.m-seg-btn.active {
  border-color: var(--border-strong);
  color: var(--accent-amber);
  background: var(--accent-amber-soft);
}

.m-director-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-debug-item {
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(10, 14, 24, 0.84);
  border: 1px solid var(--border-subtle);
  font-size: 12.5px;
  word-break: break-word;
}

.m-debug-pre {
  margin: 6px 0 0;
  padding: 7px;
  border-radius: 6px;
  background: rgba(5, 8, 15, 0.9);
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Bottom Tab Bar */
.m-bottom-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 12, 22, 0.96);
  border-top: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  flex-shrink: 0;
}

.m-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.m-nav-btn.active {
  color: var(--accent-amber);
  background: rgba(212, 163, 89, 0.1);
}

.m-nav-icon {
  font-size: 17px;
  line-height: 1.1;
}

.m-nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* Bottom Sheet Modals */
.m-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.m-modal-sheet {
  width: 100%;
  max-width: 720px;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  border-radius: 18px 18px 0 0;
  background: #101726;
  border-top: 1px solid var(--border-strong);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.m-modal-tall {
  max-height: 90dvh;
}

.m-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.m-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
}

.m-modal-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.m-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  background: rgba(20, 29, 46, 0.9);
  border: 1px solid var(--border-subtle);
}

.m-save-title {
  font-weight: 600;
  font-size: 13.5px;
  word-break: break-all;
}

.m-save-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.m-novel-body {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.78;
}

.m-novel-body h1, .m-novel-body h2, .m-novel-body h3 {
  color: var(--accent-amber);
  margin: 12px 0 6px;
}

.m-novel-body p {
  margin: 6px 0;
}

.m-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Toast */
.m-toast-box {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.m-toast {
  padding: 10px 14px;
  border-radius: 11px;
  background: rgba(15, 23, 40, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.m-toast-error {
  border-color: rgba(224, 90, 109, 0.65);
  color: #ffd4da;
}
