/* ══════════════════════════════════════════════════════════════════
   DIM LANTERN — desktop layer (≥ 769px)
   Additive. Loads AFTER style.css (same pattern as mobile.css).
   All rules gated on @media (min-width: 769px) so the mobile layer
   stays untouched.

   Goals
     · Editorial reader: Georgia, capped measure, breathing room
     · 3-pane workspace: Lore · Reader · Interrogation (each dockable)
     · Persisted, draggable dividers on both sides of the Reader
     · Ultrawide (≥ 1600px): panels fill, reader stays readable
   ══════════════════════════════════════════════════════════════════ */

@media (min-width: 769px) {

:root {
    /* Dim Lantern tokens (scoped under @media so mobile can define its own) */
    --dl-bg:        #050505;
    --dl-bg-raised: #0c0c0c;
    --dl-border:    #1a1a1a;
    --dl-border-2:  #242424;
    --dl-fg:        #e8e4d9;
    --dl-fg-dim:    #8a8374;
    --dl-muted:     #555044;
    --dl-gold:      #d4af37;
    --dl-gold-soft: rgba(212, 175, 55, 0.18);
    --dl-serif:     'Georgia', 'Iowan Old Style', 'Charter', serif;

    /* Panel widths — mirrored to CSS by desktop.js from localStorage */
    --dl-left-w:  320px;   /* Lore */
    --dl-right-w: 380px;   /* Interrogation */

    /* Reader measure cap (comfortable) */
    --dl-reader-measure: 68ch;

    /* Divider grab width (visual is 1px, hit area is 10px) */
    --dl-divider-w: 10px;
}

/* ══════════════════════════════════════════════════════════════════
   HEADER refinements — quieter, more editorial
   ══════════════════════════════════════════════════════════════════ */
header {
    background: rgba(5,5,5,0.94);
    border-bottom: 1px solid var(--dl-border);
}
.brand-logo-img { height: 28px; }
/* Progress chip in header — tone down, Georgia italic for chapter */
.progress-chapter { font-family: var(--dl-serif); font-style: italic; font-weight: 400; letter-spacing: 0.5px; text-transform: none; }
.progress-chunk   { font-family: var(--dl-serif); font-style: italic; }
.progress-bar-track { background: #111; }

/* ══════════════════════════════════════════════════════════════════
   LIBRARY — editorial hero, thumbnail-forward grid
   ══════════════════════════════════════════════════════════════════ */
#view-library { background: var(--dl-bg); }

.hero {
    padding: 7rem 2rem 4rem;
    max-width: 900px;
}
.hero h2 {
    font-family: var(--dl-serif);
    font-weight: 400;
    font-style: italic;
    font-size: 5rem;
    line-height: 1;
    letter-spacing: -2px;
    background: linear-gradient(180deg, #fff 55%, var(--dl-gold) 120%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.25rem;
}
.hero p {
    font-family: var(--dl-serif);
    font-size: 1.2rem;
    font-style: italic;
    color: var(--dl-fg-dim);
    line-height: 1.55;
    max-width: 640px;
}

.view-title-row {
    max-width: 1400px;
    margin: 2rem auto 1.25rem;
    padding: 0 2rem;
    border-top: 1px solid var(--dl-border);
    padding-top: 2rem;
}
.view-title {
    font-family: var(--dl-serif);
    font-weight: 400;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--dl-fg-dim);
    text-transform: none;
    letter-spacing: 0;
}

#book-grid.book-grid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem 1.75rem;
}
.book-card {
    background: transparent;
    border: 0;
    padding: 0;
    border-radius: 0;
    transition: transform 0.25s ease;
}
.book-card:hover { transform: translateY(-4px); }
.book-card .book-cover,
.book-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 3px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        0 18px 40px rgba(0,0,0,0.6),
        0 0 0 1px var(--dl-border-2);
}
.book-card h3, .book-card .book-title {
    font-family: var(--dl-serif);
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.75rem;
    line-height: 1.3;
    color: var(--dl-fg);
}
.book-card .book-author, .book-card .author {
    font-family: var(--dl-serif);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--dl-fg-dim);
    margin-top: 0.15rem;
}

/* Ultrawide: cap library at 1600px so it doesn't become a wall */
@media (min-width: 1700px) {
    .hero { padding: 9rem 2rem 5rem; }
    .hero h2 { font-size: 6rem; }
    #book-grid.book-grid, .view-title-row { max-width: 1600px; }
}

/* ══════════════════════════════════════════════════════════════════
   3-PANE WORKSPACE
   #split-layout is flex-row. desktop.js injects #dl-right-panel after
   #panel-right (as a sibling). Both dividers are injected too.
   Active pane widths flow via --dl-left-w / --dl-right-w vars.
   ══════════════════════════════════════════════════════════════════ */

#split-layout {
    background: var(--dl-bg);
    /* Allow dl.js to set --left-w + --dl-right-w dynamically */
}

/* Override base rule: honor our variable */
#panel-left {
    width: var(--dl-left-w);
    background: #070707;
    border-right: 1px solid var(--dl-border-2);
    transition: width 0.25s cubic-bezier(0.4,0,0.2,1), border-right-width 0.2s;
}
#panel-left.collapsed { width: 0 !important; border-right-width: 0; }

/* Left drag handle — 10px hit area, 1px visible edge */
#dl-divider-left {
    width: var(--dl-divider-w);
    flex-shrink: 0;
    background: transparent;
    cursor: col-resize;
    position: relative;
    z-index: 15;
    display: flex;
    align-items: stretch;
    justify-content: center;
    margin-left: -5px; /* center hit zone over panel-left's edge */
}
#dl-divider-left::before {
    content: '';
    width: 1px;
    background: var(--dl-border);
    transition: background 0.2s, width 0.2s;
}
#dl-divider-left:hover::before,
#dl-divider-left.dl-dragging::before {
    background: var(--dl-gold);
    width: 2px;
    box-shadow: 0 0 8px var(--dl-gold-soft);
}
#panel-left.collapsed + #dl-divider-left,
#panel-left.collapsed + #panel-divider + #dl-divider-left { display: none; }

/* Right pane — Interrogation */
#dl-right-panel {
    width: var(--dl-right-w);
    flex-shrink: 0;
    background: #070707;
    border-left: 1px solid var(--dl-border-2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.4,0,0.2,1), border-left-width 0.2s, opacity 0.2s;
    position: relative;
    z-index: 10;
}
#dl-right-panel.dl-hidden {
    width: 0 !important;
    border-left-width: 0;
    opacity: 0;
    pointer-events: none;
}

#dl-divider-right {
    width: var(--dl-divider-w);
    flex-shrink: 0;
    background: transparent;
    cursor: col-resize;
    position: relative;
    z-index: 15;
    display: flex;
    align-items: stretch;
    justify-content: center;
    margin-right: -5px;
}
#dl-divider-right::before {
    content: '';
    width: 1px;
    background: var(--dl-border);
    transition: background 0.2s, width 0.2s;
}
#dl-divider-right:hover::before,
#dl-divider-right.dl-dragging::before {
    background: var(--dl-gold);
    width: 2px;
    box-shadow: 0 0 8px var(--dl-gold-soft);
}
#dl-right-panel.dl-hidden ~ #dl-divider-right,
#dl-right-panel.dl-hidden + #dl-divider-right { display: none; }

/* Body locks pointer events during drag */
body.dl-resizing { cursor: col-resize !important; user-select: none; }
body.dl-resizing * { pointer-events: none !important; }

/* Right-panel header (inserted by desktop.js) */
#dl-right-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.75rem;
    border-bottom: 1px solid var(--dl-border);
    font-family: var(--dl-serif);
    font-style: italic;
    color: var(--dl-fg-dim);
    font-size: 0.95rem;
    flex-shrink: 0;
    gap: 0.5rem;
}
#dl-right-header .dl-rh-title {
    display: flex; align-items: baseline; gap: 0.5rem;
    min-width: 0;
}
#dl-right-header .dl-rh-title i { color: var(--dl-gold); font-size: 0.8rem; }
#dl-right-header .dl-rh-title strong {
    font-family: var(--dl-serif);
    font-style: normal;
    font-weight: 500;
    color: var(--dl-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#dl-right-close {
    background: transparent;
    border: 0;
    color: var(--dl-fg-dim);
    width: 28px; height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
#dl-right-close:hover { background: var(--dl-border); color: var(--dl-fg); }

/* Container that holds the RELOCATED #section-interrogation */
#dl-right-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* When relocated, strip the lore-section chrome and fill */
#dl-right-body #section-interrogation {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    border: 0;
    padding: 0;
    background: transparent;
}
#dl-right-body #section-interrogation .section-trigger {
    display: none !important;  /* right-header replaces it */
}
#dl-right-body #section-interrogation .section-content {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    padding: 0;
    min-height: 0;
}
#dl-right-body .interrogation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#dl-right-body .interrogation-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--dl-border);
}
#dl-right-body .interrogation-header h4 {
    font-family: var(--dl-serif);
    font-weight: 500;
    font-style: italic;
    color: var(--dl-fg);
    margin: 0;
    font-size: 1.1rem;
}
#dl-right-body .persona-state-tag {
    font-size: 0.72rem;
    color: var(--dl-fg-dim);
    margin-top: 0.3rem;
}
#dl-right-body .persona-state-tag strong {
    color: var(--dl-gold);
    font-weight: 500;
    letter-spacing: 0.5px;
}
#dl-right-body #chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
    background: var(--dl-bg);
}
#dl-right-body .chat-input-wrap {
    padding: 0.65rem 0.85rem;
    border-top: 1px solid var(--dl-border);
    background: #050505;
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
#dl-right-body #chat-input {
    flex: 1;
    background: #0d0d0d;
    border: 1px solid var(--dl-border-2);
    border-radius: 8px;
    color: var(--dl-fg);
    padding: 0.55rem 0.75rem;
    font-family: var(--dl-serif);
    font-style: italic;
    font-size: 0.95rem;
}
#dl-right-body #chat-input:focus {
    outline: none;
    border-color: var(--dl-gold);
    box-shadow: 0 0 0 1px var(--dl-gold-soft);
}
#dl-right-body #chat-send {
    background: var(--dl-gold);
    color: #1a1408;
    border: 0;
    border-radius: 8px;
    width: 40px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════════════════════════════
   READER — editorial single-column measure
   ══════════════════════════════════════════════════════════════════ */
#panel-right {
    background: var(--dl-bg);
}
#text-container {
    max-width: var(--dl-reader-measure);
    margin: 0 auto;
    padding: 4rem 2.5rem 6rem;
}
#text-content {
    font-family: var(--dl-serif);
    font-size: 1.22rem;
    line-height: 1.8;
    color: var(--dl-fg);
    letter-spacing: 0.005em;
}
#text-content p {
    margin: 0 0 1.35em;
    text-wrap: pretty;
    text-indent: 1.75em;
}
#text-content p:first-child,
#text-content p.no-indent,
#text-content h1 + p,
#text-content h2 + p,
#text-content h3 + p,
#text-content .chapter-heading + p {
    text-indent: 0;
}
#text-content h1, #text-content h2, #text-content h3,
#text-content .chapter-heading {
    font-family: var(--dl-serif);
    font-weight: 400;
    font-style: italic;
    color: var(--dl-fg-dim);
    margin: 3.5rem 0 2rem;
    text-align: center;
    letter-spacing: 0.04em;
}
#text-content h2 { font-size: 1.9rem; }
#text-content h3 { font-size: 1.4rem; }
#text-content .chapter-heading::after {
    content: '⁕';
    display: block;
    color: var(--dl-gold);
    font-size: 0.8em;
    margin-top: 1rem;
    opacity: 0.6;
}

/* active passage highlight — quieter */
#text-content .passage.active,
#text-content .chunk.active,
#text-content [data-tid].active {
    background: linear-gradient(90deg, transparent, rgba(212,175,55,0.04) 10%, rgba(212,175,55,0.04) 90%, transparent);
    border-left: 2px solid var(--dl-gold-soft);
    margin-left: -1.25rem;
    padding-left: 1.25rem;
}

/* Ultrawide: wider measure, bigger margins */
@media (min-width: 1700px) {
    :root { --dl-reader-measure: 72ch; }
    #text-container { padding: 5rem 3rem 7rem; }
    #text-content { font-size: 1.28rem; }
}

/* ══════════════════════════════════════════════════════════════════
   LORE PANEL — tighten to match Dim Lantern
   ══════════════════════════════════════════════════════════════════ */
#panel-left .panel-left-header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--dl-border);
}
#panel-left .panel-left-title {
    font-family: var(--dl-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--dl-fg-dim);
    letter-spacing: 0.5px;
    text-transform: none;
}
#panel-left .panel-left-title i { color: var(--dl-gold); margin-right: 0.4rem; }

#panel-left .lore-section {
    border-bottom: 1px solid var(--dl-border);
}
#panel-left .section-trigger {
    padding: 0.75rem 1rem;
}
#panel-left .section-trigger h4 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--dl-fg-dim);
    font-weight: 600;
}
#panel-left .section-content { padding: 0.25rem 1rem 1rem; }
#panel-left .count-badge {
    background: var(--dl-gold-soft);
    color: var(--dl-gold);
    font-family: var(--dl-serif);
}

/* Hide the "Interrogation" section from the lore panel ONLY when it's been
   relocated into the right panel (body gets a marker class). */
body.dl-interrogation-docked #panel-left #section-interrogation {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   NARRATOR BAR — quieter, taller measure
   ══════════════════════════════════════════════════════════════════ */
#narrator-bar {
    background: rgba(5,5,5,0.96);
    border-top: 1px solid var(--dl-border-2);
}
#narrator-bar-inner { max-width: 100%; padding: 0 1.5rem; }
.narrator-chapter {
    font-family: var(--dl-serif);
    font-style: italic;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--dl-fg);
}
.narrator-passage {
    font-family: var(--dl-serif);
    font-style: italic;
    font-size: 0.75rem;
    color: var(--dl-fg-dim);
}

/* ══════════════════════════════════════════════════════════════════
   GALLERY, PROFILE, AUTH — a touch of Dim Lantern polish
   ══════════════════════════════════════════════════════════════════ */
.gallery-page { max-width: 1600px; margin: 0 auto; }
.gallery-page-title h2 {
    font-family: var(--dl-serif);
    font-style: italic;
    font-weight: 400;
}
.gallery-page-title p {
    font-family: var(--dl-serif);
    font-style: italic;
    color: var(--dl-fg-dim);
}

.auth-container h2,
.profile-container h2 {
    font-family: var(--dl-serif);
    font-style: italic;
    font-weight: 400;
    color: var(--dl-fg);
}

} /* end @media (min-width: 769px) */
