﻿    :root {
      --content-width: 760px;
      --font-scale: 1;
      --line-height: 1.72;
      --shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
      --ease: 150ms ease;
      --header-height: 64px;
    }

    body[data-width-mode="wide"] {
      --content-width: 980px;
    }

    body[data-theme="dark"] {
      --bg-grad-1: #0f1624;
      --bg-grad-2: #0b0f17;
      --text: #e5ecf5;
      --muted: #9db0c8;
      --surface: #111826;
      --surface-2: #151f31;
      --border: #253750;
      --accent: #7db4ff;
      --warn-bg: #453913;
      --warn-border: #b89437;
      --warn-text: #ffe8a6;
      --author-bg: #1f203f;
      --author-border: #7874ff;
      --author-text: #d8d6ff;
      --log-bg: #2a1114;
      --log-border: #8f2f3a;
      --log-text: #ffb5bf;
      --night-bg: #090c12;
      --night-border: #3d4a64;
      --name-bg: rgba(125, 180, 255, 0.2);
      --name-border: rgba(125, 180, 255, 0.48);
      --dramatic: #ffd7d7;
    }

    body[data-theme="light"] {
      --bg-grad-1: #f9fbff;
      --bg-grad-2: #eef2fa;
      --text: #1e2a3a;
      --muted: #5d6d82;
      --surface: #ffffff;
      --surface-2: #f3f6fc;
      --border: #d5dfef;
      --accent: #1d63cc;
      --warn-bg: #fff4cc;
      --warn-border: #d3ad45;
      --warn-text: #5e4706;
      --author-bg: #eef0ff;
      --author-border: #8e94ff;
      --author-text: #31308f;
      --log-bg: #ffe9ec;
      --log-border: #d97885;
      --log-text: #6e1320;
      --night-bg: #e4ecf9;
      --night-border: #a6b7d6;
      --name-bg: rgba(29, 99, 204, 0.14);
      --name-border: rgba(29, 99, 204, 0.35);
      --dramatic: #5b0915;
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      padding: 0;
      min-height: 100%;
      overflow-x: hidden;
      scroll-behavior: smooth;
      font-family: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
      background: linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
      color: var(--text);
      -webkit-text-size-adjust: 100%;
    }

    body {
      font-size: calc(16px * var(--font-scale));
    }

    .app-header {
      position: sticky;
      top: 0;
      z-index: 40;
      border-bottom: 1px solid var(--border);
      background: rgba(17, 24, 38, 0.92);
      backdrop-filter: blur(8px);
      transition: background var(--ease), border-color var(--ease), box-shadow var(--ease);
    }

    body[data-theme="light"] .app-header {
      background: rgba(255, 255, 255, 0.95);
    }

    .header-inner,
    .toolbar-inner,
    .reader-wrap {
      width: min(var(--content-width), calc(100% - 24px));
      margin: 0 auto;
    }

    .header-inner {
      min-height: var(--header-height);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 8px 0;
      transition: min-height var(--ease), padding var(--ease);
    }

    .brand-title {
      margin: 0;
      font-size: clamp(1.1rem, 2.5vw, 1.4rem);
      line-height: 1.2;
      letter-spacing: 0.01em;
      transition: font-size var(--ease), letter-spacing var(--ease);
    }

    .brand-subtitle {
      margin: 3px 0 0;
      color: var(--muted);
      font-size: 0.9rem;
      transition: opacity var(--ease), max-height var(--ease), margin var(--ease);
      max-height: 1.8em;
      overflow: hidden;
    }

    .icon-btn,
    .text-btn,
    .mode-btn {
      border: 1px solid var(--border);
      color: var(--text);
      background: var(--surface);
      border-radius: 10px;
      padding: 8px 12px;
      cursor: pointer;
      font-weight: 600;
      transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease), background var(--ease);
    }

    .icon-btn:hover,
    .text-btn:hover,
    .mode-btn:hover {
      border-color: var(--accent);
    }

    .icon-btn:active,
    .text-btn:active,
    .mode-btn:active {
      transform: translateY(1px);
    }

    .toolbar {
      position: sticky;
      top: var(--header-height);
      z-index: 35;
      border-bottom: 1px solid var(--border);
      background: rgba(21, 31, 49, 0.9);
      backdrop-filter: blur(8px);
      transition: top var(--ease), background var(--ease), border-color var(--ease);
    }

    body[data-theme="light"] .toolbar {
      background: rgba(243, 246, 252, 0.95);
    }

    .toolbar-inner {
      min-height: 64px;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px 14px;
      align-items: center;
      padding: 10px 0;
      transition: min-height var(--ease), padding var(--ease);
    }

    body.is-scrolled {
      --header-height: 50px;
    }

    body.is-scrolled .app-header {
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }

    body.is-scrolled .header-inner {
      padding: 4px 0;
    }

    body.is-scrolled .brand-title {
      font-size: clamp(1rem, 2.2vw, 1.2rem);
      letter-spacing: 0;
    }

    body.is-scrolled .brand-subtitle {
      opacity: 0;
      max-height: 0;
      margin-top: 0;
    }

    body.is-scrolled .toolbar-inner {
      min-height: 56px;
      padding: 8px 0;
    }

    .toolbar-left,
    .toolbar-right {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .search {
      width: min(360px, 100%);
      min-height: 40px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      padding: 0 12px;
      outline: none;
    }

    .search:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(125, 180, 255, 0.3);
    }

    body[data-theme="light"] .search:focus {
      box-shadow: 0 0 0 3px rgba(29, 99, 204, 0.2);
    }

    .toolbar-chip {
      min-height: 40px;
      display: inline-flex;
      align-items: center;
      padding: 0 10px;
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--muted);
      background: var(--surface);
      font-weight: 600;
      white-space: nowrap;
    }

    .settings {
      position: relative;
    }

    .settings summary {
      list-style: none;
      cursor: pointer;
      user-select: none;
      border: 1px solid var(--border);
      border-radius: 10px;
      min-height: 40px;
      display: inline-flex;
      align-items: center;
      padding: 0 12px;
      background: var(--surface);
      font-weight: 600;
    }

    .settings summary::-webkit-details-marker {
      display: none;
    }

    .settings-panel {
      position: absolute;
      right: 0;
      top: calc(100% + 8px);
      width: min(300px, 88vw);
      border: 1px solid var(--border);
      background: var(--surface);
      border-radius: 12px;
      box-shadow: var(--shadow);
      padding: 12px;
      display: grid;
      gap: 8px;
    }

    .settings-row {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 0.92rem;
      color: var(--text);
    }

    .settings-row input {
      margin: 0;
    }

    main {
      padding: 12px 0 28px;
    }

    .reader-wrap {
      border: 1px solid var(--border);
      border-radius: 14px;
      background: var(--surface);
      box-shadow: var(--shadow);
      padding: clamp(10px, 2vw, 18px);
    }

    .status {
      margin: 0 0 10px;
      color: var(--muted);
      font-size: 0.92rem;
    }

    .help-modal {
      position: fixed;
      inset: 0;
      z-index: 90;
      display: grid;
      place-items: center;
      padding: 16px;
      background: rgba(5, 10, 20, 0.66);
      backdrop-filter: blur(2px);
    }

    .help-modal.hidden {
      display: none;
    }

    .help-dialog {
      width: min(680px, 100%);
      border: 1px solid var(--border);
      border-radius: 12px;
      background: var(--surface);
      box-shadow: var(--shadow);
      overflow: hidden;
    }

    .help-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 12px;
      border-bottom: 1px solid var(--border);
      background: var(--surface-2);
    }

    .help-header h2 {
      margin: 0;
      font-size: 1rem;
      line-height: 1.2;
    }

    .help-close {
      min-height: 34px;
      padding: 6px 10px;
    }

    .help-body {
      padding: 12px;
      color: var(--text);
      font-size: 0.92rem;
      line-height: 1.55;
    }

    .help-body p {
      margin: 0;
    }

    .help-body p + p {
      margin-top: 8px;
    }

    .reader {
      display: grid;
      gap: 18px;
    }

    .day-separator {
      margin: 22px 0 4px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface-2);
      text-align: center;
      padding: 12px 10px;
      color: var(--muted);
      line-height: 1.5;
      font-weight: 700;
      letter-spacing: 0.07em;
      white-space: pre-line;
    }

    .day-section {
      display: grid;
      gap: 10px;
      padding-top: 4px;
    }

    .day-heading {
      margin: 0;
      padding: 8px 10px;
      border-bottom: 1px solid var(--border);
      font-size: clamp(1.18rem, 2.3vw, 1.46rem);
      line-height: 1.3;
      font-weight: 800;
      letter-spacing: 0.03em;
    }

    .story-block {
      display: grid;
      gap: 2px;
      border-radius: 10px;
      padding: 4px 6px;
    }

    .story-block.rules {
      background: transparent;
      border: 0;
      color: var(--warn-text);
    }

    .story-block.log {
      background: transparent;
      border: 0;
      color: var(--log-text);
      font-family: Consolas, "Courier New", monospace;
      font-size: 0.96em;
    }

    .story-block.night {
      background: var(--night-bg);
      border: 1px solid var(--night-border);
    }

    .story-block.author-note {
      background: transparent;
      border: 0;
    }

    .story-line {
      margin: 0;
      border-radius: 8px;
      padding: 6px 8px;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      line-height: var(--line-height);
      transition: opacity var(--ease), background-color var(--ease), filter var(--ease);
    }

    .story-block.rules .story-line,
    .story-block.log .story-line {
      display: inline-block;
      width: fit-content;
      max-width: 100%;
    }

    .story-block.rules .story-line {
      background: var(--warn-bg);
      border: 1px solid var(--warn-border);
      color: var(--warn-text);
    }

    .story-block.log .story-line {
      background: var(--log-bg);
      border: 1px solid var(--log-border);
      color: var(--log-text);
    }

    .story-block.author-note .story-line {
      display: inline-block;
      width: fit-content;
      max-width: 100%;
      background: var(--author-bg);
      border: 1px solid var(--author-border);
      color: var(--author-text);
      font-style: italic;
    }

    .story-block.rules .story-line.blank,
    .story-block.log .story-line.blank,
    .story-block.author-note .story-line.blank {
      display: none;
    }

    .story-line.blank {
      min-height: 10px;
      padding: 0;
    }

    .story-line.dramatic {
      text-align: center;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      font-weight: 800;
      color: var(--dramatic);
      text-shadow: 0 0 10px rgba(255, 215, 215, 0.25);
    }

    body[data-theme="light"] .story-line.dramatic {
      text-shadow: 0 0 8px rgba(91, 9, 21, 0.18);
    }

    .story-line.is-hidden {
      display: none;
    }

    .story-line.dimmed {
      opacity: 0.35;
      filter: saturate(0.75);
    }

    .story-line.name-hit {
      background: rgba(125, 180, 255, 0.22);
    }

    body[data-theme="light"] .story-line.name-hit {
      background: rgba(29, 99, 204, 0.12);
    }

    .name {
      display: inline-block;
      padding: 0.03em 0.46em;
      border-radius: 999px;
      background: var(--name-bg);
      border: 1px solid var(--name-border);
      font-weight: 650;
      cursor: pointer;
      transition: box-shadow var(--ease), transform var(--ease);
    }

    .name:hover,
    .name:focus-visible {
      box-shadow: 0 0 0 2px rgba(125, 180, 255, 0.45);
      transform: translateY(-1px);
      outline: none;
    }

    body[data-theme="light"] .name:hover,
    body[data-theme="light"] .name:focus-visible {
      box-shadow: 0 0 0 2px rgba(29, 99, 204, 0.4);
    }

    .name.selected {
      box-shadow: 0 0 0 2px rgba(125, 180, 255, 0.62);
    }

    body[data-theme="light"] .name.selected {
      box-shadow: 0 0 0 2px rgba(29, 99, 204, 0.52);
    }

    .nav-wrap {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .nav-wrap.hidden {
      display: none;
    }

    .bottom-next-wrap {
      margin-top: 16px;
      display: flex;
      justify-content: flex-end;
    }

    .bottom-next-wrap.hidden {
      display: none;
    }

    @media (max-width: 860px) {
      :root {
        --header-height: 62px;
      }

      .header-inner,
      .toolbar-inner,
      .reader-wrap {
        width: min(var(--content-width), calc(100% - 14px));
      }

      body.is-scrolled {
        --header-height: 46px;
      }

      .toolbar-inner {
        grid-template-columns: 1fr;
      }
    }
  

