 :root {
    --ink: #1a1208;
    --parchment: #faf6ee;
    --parchment-dark: #f0e9d8;
    --gold: #b8892a;
    --gold-light: #e8c96a;
    --gold-pale: #f7edd0;
    --fog: #6b6358;
    --fog-light: #a09888;
    --sidebar-bg: #1c1510;
    --sidebar-text: #d4c9b0;
    --sidebar-muted: #9f9f9f;
    --sidebar-hover: #2e261e;
    --sidebar-active: #3d3025;
    --accent-red: #8b2020;
    --border: rgba(184,137,42,0.25);
    --reader-max: 720px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--sidebar-bg);
    color: var(--ink);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* ── TOPBAR ── */
  #topbar {
    display: flex;
    align-items: center;
    background: #110e09;
    border-bottom: 1px solid rgba(184,137,42,0.3);
    padding: 0 1.5rem;
    height: 56px;
    flex-shrink: 0;
    gap: 1rem;
    z-index: 100;
  }

  #topbar .logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--gold-light);
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #topbar .logo span {
    color: var(--sidebar-muted);
    font-style: italic;
    font-size: 0.85rem;
    margin-left: 0.5rem;
  }

  #category-nav {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .cat-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--sidebar-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.35rem 0.9rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }

  .cat-btn:hover { color: var(--gold-light); border-color: rgba(184,137,42,0.3); }
  .cat-btn.active {
    color: var(--gold-light);
    background: rgba(184,137,42,0.15);
    border-color: rgba(184,137,42,0.4);
  }

  /* Google Translate wrapper */
  #translate-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
  }

  #translate-area label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sidebar-muted);
    white-space: nowrap;
  }

  #lang-select {
    background: #1c1510;
    border: 1px solid rgba(184,137,42,0.3);
    color: var(--sidebar-text);
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    font-family: 'Inter', sans-serif;
  }

  #lang-select:hover { border-color: var(--gold); }

  /* ── LAYOUT ── */
  #main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  /* ── SIDEBAR ── */
  #sidebar {
    width: 270px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(184,137,42,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #sidebar-header {
    padding: 1rem 1.2rem 0.75rem;
    border-bottom: 1px solid rgba(184,137,42,0.15);
    flex-shrink: 0;
  }

  #sidebar-category-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    margin-bottom: 0.3rem;
  }

  #sidebar-count {
    font-size: 0.75rem;
    color: var(--sidebar-muted);
  }

  #sidebar-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(184,137,42,0.1);
    flex-shrink: 0;
  }

  #search-input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(184,137,42,0.2);
    border-radius: 3px;
    padding: 0.4rem 0.7rem;
    color: var(--sidebar-text);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    outline: none;
  }

  #search-input:focus { border-color: var(--gold); }
  #search-input::placeholder { color: var(--sidebar-muted); }

  #story-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
  }

  #story-list::-webkit-scrollbar { width: 3px; }
  #story-list::-webkit-scrollbar-track { background: transparent; }
  #story-list::-webkit-scrollbar-thumb { background: rgba(184,137,42,0.3); border-radius: 2px; }

  .story-item {
    display: flex;
    gap: 10px;
    padding: 0.3rem 1.2rem;
    color: #9f9f9f;
    font-size: 0.8rem;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.15s;
    line-height: 1.4;
    text-decoration: none;
    font-weight: 600;
  }

  .story-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
  }

  .story-item.active {
    background: var(--sidebar-active);
    color: var(--gold-light);
    border-left-color: var(--gold);
    font-weight: 500;
  }

  .story-item .story-number {
    font-size: 0.65rem;
    color: var(--sidebar-muted);
    display: block;
    margin-top: 3px;
    opacity: 0.6;
  }

  .story-item.active .story-number { opacity: 0.8; }

  /* ── READER ── */
  #reader-area {
    flex: 1;
    background: var(--parchment);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  #reader-area::-webkit-scrollbar { width: 6px; }
  #reader-area::-webkit-scrollbar-track { background: var(--parchment-dark); }
  #reader-area::-webkit-scrollbar-thumb { background: rgba(184,137,42,0.4); border-radius: 3px; }

  #reader-toolbar {
    background: var(--parchment-dark);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .toolbar-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fog);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.8rem;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
  }

  .toolbar-btn:hover { background: var(--gold-pale); color: var(--gold); border-color: var(--gold); }

  #font-size-label {
    font-size: 0.7rem;
    color: var(--fog-light);
    margin-left: auto;
  }

  #font-size-range {
    width: 80px;
    accent-color: var(--gold);
  }

  #breadcrumb {
    font-size: 0.7rem;
    color: var(--fog-light);
  }

  #breadcrumb span { color: var(--fog); }

  #content-wrap {
    max-width: var(--reader-max);
    margin: 0 auto;
    padding: 3rem 2.5rem 5rem;
    flex: 1;
    width: 100%;
  }

  /* Story header */
  #story-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  #story-header::after {
    content: '❧';
    position: absolute;
    bottom: -0.6rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--parchment);
    padding: 0 0.5rem;
    color: var(--gold);
    font-size: 1rem;
  }

  #story-eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.8rem;
    font-family: 'Inter', sans-serif;
  }

  #story-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
    margin-bottom: 0.5rem;
  }

  #story-meta {
    font-size: 0.75rem;
    color: var(--fog-light);
    font-style: italic;
    font-family: 'EB Garamond', serif;
  }

  /* Body text */
  #story-body {
    font-family: 'EB Garamond', serif;
    font-size: 1.15rem;
    line-height: 1.9;
    color: #2a2218;
  }

  #story-body p {
    margin-bottom: 1.2em;
    text-indent: 1.8em;
    
    /* Core Alignment */
    text-align: justify;
    text-justify: inter-word; /* Optimizes spacing between words rather than characters */
    text-align-last: left;    /* Ensures the very last line of the paragraph doesn't stretch awkwardly */

    /* Typography Clean-up (Prevents awkward gaps/rivers) */
    -webkit-hyphens: auto;    /* Safari */
    -ms-hyphens: auto;       /* IE/Edge */
    hyphens: auto;           /* Standard - breaks long words naturally at line ends */
}

  #story-body p:first-of-type { text-indent: 0; }

  #story-body p:first-of-type::first-letter {
    float: left;
    font-family: 'Playfair Display', serif;
    font-size: 4rem;
    line-height: 0.75;
    margin: 0.1em 0.1em 0 0;
    color: var(--gold);
    font-weight: 600;
  }

  /* Loading & welcome */
  #loading-state {
    display: none;
    text-align: center;
    padding: 4rem;
    color: var(--fog-light);
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1.1rem;
  }

  #welcome-state {
    text-align: center;
    padding: 4rem 2rem;
  }

  #welcome-state .welcome-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
  }

  #welcome-state h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--ink);
    margin-bottom: 0.75rem;
  }

  #welcome-state p {
    color: var(--fog);
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.7;
  }

  /* Progress bar */
  #progress-bar {
    position: fixed;
    top: 56px;
    left: 270px;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, var(--gold) var(--progress, 0%), transparent 0);
    z-index: 50;
    pointer-events: none;
  }

  /* Ornament dividers in text */
  #story-body hr {
    border: none;
    text-align: center;
    color: var(--gold);
    margin: 2rem 0;
    letter-spacing: 0.3em;
  }

  #story-body hr::after { content: '— ✦ —'; }

  /* Nav buttons at bottom */
  #story-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
  }

  .nav-story-btn {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.75rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    max-width: 45%;
    text-align: left;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
    text-decoration: none;
  }

  .nav-story-btn:hover { background: var(--gold-pale); border-color: var(--gold); }
  .nav-story-btn.right { text-align: right; margin-left: auto; }

  .nav-story-btn .nav-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold);
  }

  .nav-story-btn .nav-title {
    font-size: 0.82rem;
    color: var(--fog);
    line-height: 1.3;
  }

  /* Google Translate widget override */
  .goog-te-banner-frame, .skiptranslate { display: none !important; }
  body { top: 0 !important; }

  /* Sidebar toggle for narrow */
  #sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
  }

  @media (max-width: 768px) {
    #sidebar {
      position: fixed;
      left: -270px;
      top: 56px;
      bottom: 0;
      z-index: 200;
      transition: left 0.25s;
    }
    #sidebar.open { left: 0; }
    #sidebar-toggle { display: block; }
    #progress-bar { left: 0; }
    #content-wrap { padding: 2rem 1.25rem 4rem; }
  }