/* ============================================================
   32-Library-Stacks — Vibe Code News · הספרייה
   Book spines on wooden shelves, organized by category.
   Drag a spine out (pointer events) → book opens to article.
   Drag back → shelve. Warm wood tones, leather spine colors.
   Chat top styled as a "library desk reference". RTL.
   - No neon, no cyberpunk, no neomorphism.
   ============================================================ */

/* ─── Palette: Warm Wood + Library ─── */
:root {
  /* Wood tones */
  --wood-darkest:   #1a0e08;
  --wood-dark:      #2d1a0e;
  --wood-mid:       #4a2e1c;
  --wood-warm:      #6b3f24;
  --wood-light:     #8a5436;
  --wood-grain:     #5a3a25;

  /* Paper / parchment */
  --paper:          #f4ead5;
  --paper-warm:     #ebdfc2;
  --paper-edge:     #c9b48b;
  --ink:            #2a1a0c;
  --ink-soft:       #5a3f28;
  --ink-faint:      #8a6e4a;

  /* Brass / gold */
  --brass:          #b8893a;
  --brass-deep:     #8a6420;
  --brass-shine:    #e2c068;

  /* Leather spine colors (per category) */
  --leather-opinion:    #7c2828;   /* burgundy */
  --leather-deep:       #2c4a2c;   /* forest green */
  --leather-guide:      #2c3e5c;   /* navy */
  --leather-tools:      #a87148;   /* tan */
  --leather-bench:      #3a2418;   /* espresso */
  --leather-breaking:   #5a1e1e;   /* dark red */
  --leather-periodic:   #d4c08a;   /* newsprint cream */

  /* Shelf wood */
  --shelf-top:      #8a5436;
  --shelf-front:    #5a3a25;
  --shelf-shadow:   rgba(10, 5, 2, 0.5);

  /* Chat skin — WhatsApp (default) */
  --skin-wa-bg:     #ece5dd;
  --skin-wa-out:    #dcf8c6;
  --skin-wa-in:     #ffffff;
  --skin-wa-accent: #075e54;
  --skin-wa-dot:    #25d366;

  /* Chat skin — Telegram */
  --skin-tg-bg:     #e7eef5;
  --skin-tg-out:    #c8e1f0;
  --skin-tg-in:     #ffffff;
  --skin-tg-accent: #2aabee;
  --skin-tg-dot:    #2aabee;

  /* Chat skin — Messenger */
  --skin-ms-bg:     #eef0f3;
  --skin-ms-out:    #b7d6ff;
  --skin-ms-in:     #ffffff;
  --skin-ms-accent: #7b68ee;
  --skin-ms-dot:    #ff5e7e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Heebo', 'Arial Hebrew', 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
}

body {
  min-height: 100vh;
  /* Warm walnut wood background with grain */
  background:
    /* Wood grain vertical streaks */
    repeating-linear-gradient(
      90deg,
      transparent 0 24px,
      rgba(0, 0, 0, 0.05) 24px 25px,
      transparent 25px 48px,
      rgba(255, 220, 180, 0.04) 48px 49px
    ),
    /* Wood plank horizontal seams */
    repeating-linear-gradient(
      0deg,
      transparent 0 220px,
      rgba(0, 0, 0, 0.18) 220px 222px,
      transparent 222px 442px,
      rgba(0, 0, 0, 0.14) 442px 444px
    ),
    /* Vignette / center lighting */
    radial-gradient(
      ellipse at 50% 20%,
      var(--wood-warm) 0%,
      var(--wood-mid) 35%,
      var(--wood-dark) 75%,
      var(--wood-darkest) 100%
    );
  background-attachment: fixed;
  padding-top: 116px; /* POLISHED: tighter room for fixed chat + header */
  padding-bottom: 60px;
}

/* Reserve room for "reading desk" when a book is open */
body.book-open {
  padding-bottom: 480px;
}

/* ═════════════════════════════════════════════════════════════
   CHAT — TOP, fixed
   Styled as "library desk reference" — a wooden catalog card
   with brass corners and a chat embedded inside.
   ═════════════════════════════════════════════════════════════ */
#chat-host {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  direction: rtl;
  width: min(1280px, calc(100% - 32px));
}

.chat-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: stretch;
  gap: 0;
  background: linear-gradient(180deg, #c9a368 0%, #a07a3a 100%);
  border: 1px solid #5a3f18;
  border-radius: 6px;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 220, 160, 0.5),
    inset 0 -1px 0 rgba(60, 30, 8, 0.4);
  direction: ltr;
  padding: 0;
  position: relative;
  overflow: hidden;
}

/* Brass corner tacks */
.chat-bar::before,
.chat-bar::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--brass-shine) 0%, var(--brass) 40%, var(--brass-deep) 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.chat-bar::before { top: 6px; left: 6px; }
.chat-bar::after  { top: 6px; right: 6px; }

.chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #8a5a28 0%, #6b3f18 100%);
  border-right: 1px solid #3a2010;
  min-width: 240px;
  position: relative;
}

.chat-brand::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--brass-shine) 0%, var(--brass) 50%, var(--brass-deep) 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: var(--skin-wa-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
  border: 1.5px solid var(--brass-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chat-head-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.chat-head-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff5d8;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head-status {
  font-size: 11px;
  color: #f4e4b8;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
}

.chat-subs {
  color: #f4e4b8;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--skin-wa-dot);
  display: inline-block;
  animation: pulse 1.6s ease-in-out infinite;
  box-shadow: 0 0 4px var(--skin-wa-dot);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}

.chat-messages-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scroll-behavior: smooth;
  background:
    linear-gradient(180deg, var(--skin-wa-bg) 0%, #ddd3c5 100%);
  min-height: 60px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.chat-messages-strip::-webkit-scrollbar { height: 4px; }
.chat-messages-strip::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.18); border-radius: 2px; }

.bubble-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--skin-wa-in);
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.bubble-strip.urgent {
  border-color: #b13a2a;
  box-shadow: 0 0 0 1px #b13a2a inset, 0 1px 4px rgba(177, 58, 42, 0.25);
  font-weight: 600;
}

.bubble-strip-tag {
  background: var(--skin-wa-accent);
  color: #fff;
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.bubble-strip-text {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bubble-strip-time {
  color: var(--ink-faint);
  font-size: 10.5px;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

.urgent-badge {
  background: #b13a2a;
  color: #fff;
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.typing-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  flex-shrink: 0;
}

.typing-strip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--skin-wa-accent);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-strip-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-strip-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.chat-input-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #8a5a28 0%, #6b3f18 100%);
  border-left: 1px solid #3a2010;
}

.chat-input-field {
  background: var(--paper);
  border: 1px solid var(--brass-deep);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  min-width: 140px;
  font-family: 'Heebo', sans-serif;
}

.chat-send-btn {
  background: var(--brass);
  color: var(--ink);
  border: 1px solid var(--brass-deep);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.chat-skin-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #8a5a28 0%, #6b3f18 100%);
  border-left: 1px solid #3a2010;
}

.chat-skin-label {
  font-size: 10px;
  color: #f4e4b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  margin-left: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.skin-btn {
  background: transparent;
  border: 1px solid var(--brass);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: #f4e4b8;
  transition: all 0.15s ease;
  font-family: 'Heebo', sans-serif;
}

.skin-btn:hover { background: rgba(255, 220, 160, 0.15); }

.skin-btn.active {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass-shine);
}

/* Skin: Telegram */
.chat-bar.skin-tg .bubble-strip { background: var(--skin-tg-in); }
.chat-bar.skin-tg .chat-avatar,
.chat-bar.skin-tg .skin-btn.active { background: var(--skin-tg-accent); border-color: var(--skin-tg-accent); }
.chat-bar.skin-tg .bubble-strip-tag { background: var(--skin-tg-accent); }
.chat-bar.skin-tg .live-dot { background: var(--skin-tg-dot); }
.chat-bar.skin-tg .typing-strip-dot { background: var(--skin-tg-accent); }
.chat-bar.skin-tg .chat-messages-strip { background: var(--skin-tg-out); }

/* Skin: Messenger */
.chat-bar.skin-ms .bubble-strip { background: var(--skin-ms-in); }
.chat-bar.skin-ms .chat-avatar {
  background: linear-gradient(135deg, #00b2ff 0%, #7b68ee 50%, #ff5e7e 100%);
}
.chat-bar.skin-ms .skin-btn.active {
  background: linear-gradient(135deg, #00b2ff 0%, #7b68ee 100%);
  border-color: #7b68ee;
}
.chat-bar.skin-ms .bubble-strip-tag { background: linear-gradient(135deg, #00b2ff 0%, #7b68ee 100%); }
.chat-bar.skin-ms .live-dot { background: var(--skin-ms-dot); }
.chat-bar.skin-ms .typing-strip-dot { background: var(--skin-ms-accent); }
.chat-bar.skin-ms .chat-messages-strip { background: var(--skin-ms-out); }

/* ═════════════════════════════════════════════════════════════
   LIBRARY HEADER — Brass plate with carved text
   ═════════════════════════════════════════════════════════════ */
.library-header {
  max-width: 1380px;
  margin: 0 auto 24px;
  padding: 18px 26px;
  background: linear-gradient(180deg, #8a5a28 0%, #5a3a18 100%);
  border: 2px solid var(--brass-deep);
  border-radius: 6px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 220, 160, 0.3);
  position: relative;
  color: #f4e4b8;
}

/* Brass corner tacks */
.library-header::before,
.library-header::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--brass-shine) 0%, var(--brass) 40%, var(--brass-deep) 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.library-header::before { top: 8px; left: 8px; }
.library-header::after  { top: 8px; right: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brass-shine) 0%, var(--brass) 50%, var(--brass-deep) 100%);
  color: #2a1a0c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 900;
  font-size: 28px;
  border: 1.5px solid var(--brass-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 18px;
  color: #fff5d8;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.brand-sub {
  font-size: 11px;
  color: #d4b878;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

.library-title {
  text-align: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 24px;
  color: #fff5d8;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.library-title-meta {
  display: block;
  font-size: 10px;
  color: #d4b878;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
  font-weight: 400;
}

.library-nav {
  display: flex;
  gap: 4px;
}

.library-nav a {
  padding: 8px 14px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: #f4e4b8;
  background: transparent;
  border: 1px solid var(--brass);
  transition: all 0.15s ease;
}

.library-nav a:hover {
  background: rgba(255, 220, 160, 0.15);
  color: #fff5d8;
}

.library-nav a.active {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass-shine);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ═════════════════════════════════════════════════════════════
   LIBRARY ROOM — the shelves container
   ═════════════════════════════════════════════════════════════ */
.library-room {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 16px;
}

.library-intro {
  margin-bottom: 24px;
  padding: 18px 22px;
  background: var(--paper);
  border: 1px dashed var(--ink-soft);
  border-radius: 4px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  position: relative;
}

.library-intro strong {
  color: var(--ink);
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
}

.library-intro::before {
  content: 'ℹ';
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  font-size: 18px;
  color: var(--brass);
}

/* ═════════════════════════════════════════════════════════════
   SHELVES — Each is a wooden plank with books standing on it
   ═════════════════════════════════════════════════════════════ */
.shelf {
  position: relative;
  margin-bottom: 50px;
  padding-top: 6px; /* gap from previous shelf */
}

.shelf-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.shelf-label-text {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 16px;
  color: #f4e4b8;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  background: linear-gradient(180deg, #5a3a18 0%, #3a2010 100%);
  border: 1px solid var(--brass);
  border-radius: 4px;
  padding: 6px 14px;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.shelf-label-meta {
  font-size: 11px;
  color: #d4b878;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.shelf-divider {
  flex-grow: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(184, 137, 58, 0.4) 50%, transparent 100%);
}

.shelf-body {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 0 4px;
  /* The shelf "floor" */
  background:
    /* Book row (top portion) */
    linear-gradient(180deg, transparent 0%, transparent calc(100% - 18px), var(--shelf-top) calc(100% - 18px), var(--shelf-top) calc(100% - 12px), var(--shelf-front) calc(100% - 12px), var(--shelf-front) 100%);
  min-height: 188px; /* POLISHED: shorter, more compact */
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 0 0 4px 4px;
  box-shadow:
    inset 0 4px 6px rgba(0, 0, 0, 0.25),
    0 6px 16px rgba(0, 0, 0, 0.4);
  overflow: visible;
}

/* Shelf front edge — gives the 3D plank look */
.shelf-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 28px,
      rgba(0, 0, 0, 0.18) 28px 29px
    ),
    linear-gradient(180deg, var(--shelf-front) 0%, #2a1a0c 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 0 0 3px 3px;
  pointer-events: none;
}

/* Back wall of shelf (slight darker) */
.shelf-body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 18px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 12px,
      rgba(0, 0, 0, 0.06) 12px 13px
    ),
    linear-gradient(180deg, #3a2010 0%, #2a1a0c 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 4px 4px 0 0;
  pointer-events: none;
  z-index: 0;
}

/* Side walls of shelf */
.shelf-body {
  border-inline-start: 6px solid var(--shelf-front);
  border-inline-end: 6px solid var(--shelf-front);
}

/* ═════════════════════════════════════════════════════════════
   BOOKS — book spines standing on the shelf
   ═════════════════════════════════════════════════════════════ */
.book {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  z-index: 2;
  user-select: none;
  touch-action: none;
  margin-inline-start: -2px; /* tight packing */
}

.book.is-dragging {
  cursor: grabbing;
  z-index: 9500;  /* above chat (9000) and reading desk (8500) */
  transition: none;
}

.book.is-open {
  z-index: 5000;
}

.book-spine {
  position: relative;
  width: var(--spine-w, 36px);
  height: var(--spine-h, 200px);
  background: var(--leather, var(--leather-tools));
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 3px 3px 2px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.15),
    inset -1px 0 0 rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 2px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

/* Book gold band (horizontal line near top and bottom) */
.book-spine::before,
.book-spine::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--brass) 20%, var(--brass-shine) 50%, var(--brass) 80%, transparent 100%);
  opacity: 0.7;
}
.book-spine::before { top: 22px; }
.book-spine::after  { bottom: 22px; }

.book.is-dragging .book-spine {
  transform: rotate(-3deg);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.55),
    inset 1px 0 0 rgba(255, 255, 255, 0.18);
}

.book-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 11px;
  color: #f4e4b8;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.3px;
  max-height: calc(100% - 30px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.1;
}

.book-title-en {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  color: var(--brass-shine);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  max-height: calc(100% - 30px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

.book-knob {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--brass-shine) 0%, var(--brass) 50%, var(--brass-deep) 100%);
  border: 1px solid #5a3f18;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: grab;
  z-index: 3;
}

.book.is-dragging .book-knob { cursor: grabbing; }

/* Hover effect on book */
.book:hover .book-spine {
  transform: translateY(-3px);
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.2),
    inset -1px 0 0 rgba(0, 0, 0, 0.3),
    0 6px 14px rgba(0, 0, 0, 0.45);
}

.book.is-periodic .book-spine {
  background: var(--leather-periodic);
  border-color: #8a6e3a;
}

.book.is-periodic .book-title {
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.book.is-periodic .book-title-en {
  color: #5a3f18;
}

/* Breaking news = darker red */
.book.is-breaking .book-spine {
  background: var(--leather-breaking);
  box-shadow:
    inset 0 0 0 1px rgba(255, 200, 100, 0.3),
    inset 1px 0 0 rgba(255, 255, 255, 0.18),
    inset -1px 0 0 rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

/* ═════════════════════════════════════════════════════════════
   READING DESK — appears at bottom when a book is opened
   ═════════════════════════════════════════════════════════════ */
.reading-desk {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8500;
  background: linear-gradient(180deg, var(--wood-warm) 0%, var(--wood-mid) 50%, var(--wood-dark) 100%);
  border-top: 4px solid var(--brass-deep);
  box-shadow:
    0 -8px 32px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 220, 160, 0.2);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  direction: rtl;
}

.reading-desk.is-open {
  transform: translateY(0);
}

.reading-desk-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(180deg, #6b3f18 0%, #3a2010 100%);
  border-bottom: 1px solid var(--brass-deep);
  color: #f4e4b8;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
}

.reading-desk-top .reading-desk-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  color: #d4b878;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.reading-desk-close {
  background: var(--brass);
  color: var(--ink);
  border: 1px solid var(--brass-deep);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Heebo', sans-serif;
}

.reading-desk-close:hover {
  background: var(--brass-shine);
}

.reading-desk-body {
  overflow-y: auto;
  padding: 28px 32px 40px;
  background:
    radial-gradient(ellipse at 50% 0%, var(--paper) 0%, var(--paper-warm) 80%);
  color: var(--ink);
  flex: 1;
}

.reading-desk-body::-webkit-scrollbar { width: 10px; }
.reading-desk-body::-webkit-scrollbar-track { background: var(--paper-warm); }
.reading-desk-body::-webkit-scrollbar-thumb { background: var(--brass); border-radius: 4px; }

.reading-content {
  max-width: 760px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  padding: 32px 38px;
  box-shadow:
    0 4px 18px rgba(60, 30, 8, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
}

.reading-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 100%;
  background: rgba(184, 137, 58, 0.2);
  pointer-events: none;
}

.reading-cat {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--brass-deep);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  display: inline-block;
  padding: 3px 8px;
  background: rgba(184, 137, 58, 0.15);
  border-radius: 3px;
}

.reading-content h1 {
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 900;
  font-size: 30px;
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--ink);
  border-bottom: 2px solid var(--brass);
  padding-bottom: 12px;
}

.reading-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.reading-meta .meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  align-self: center;
}

.reading-excerpt {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 20px;
  border-inline-start: 3px solid var(--brass);
  padding-inline-start: 14px;
  font-style: italic;
}

.reading-content p {
  font-size: 15px;
  line-height: 1.7;
  margin: 0 0 14px;
  color: var(--ink);
}

.reading-tldr {
  margin-top: 24px;
  padding: 14px 18px;
  background: rgba(184, 137, 58, 0.12);
  border: 1px solid var(--brass);
  border-radius: 4px;
  font-size: 14px;
  color: var(--ink);
}

.reading-tldr strong {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--brass-deep);
  margin-bottom: 4px;
}

.reading-news-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-faint);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.reading-news-dek {
  font-size: 14.5px;
  color: var(--ink-soft);
  margin: 0 0 16px;
  line-height: 1.55;
}

.urgency-pill {
  display: inline-block;
  background: #b13a2a;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.urgency-pill.urgency-high {
  background: #c47a1a;
}

.urgency-pill.urgency-normal {
  background: #6a5a48;
}

/* ═════════════════════════════════════════════════════════════
   SHELF EMPTY STATE
   ═════════════════════════════════════════════════════════════ */
.shelf-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b4a2a;
  font-family: 'Frank Ruhl Libre', serif;
  font-style: italic;
  font-size: 14px;
  padding: 32px;
  text-align: center;
  z-index: 1;
  position: relative;
}

/* ═════════════════════════════════════════════════════════════
   DRAG HINT — small "Drag to read" indicator
   ═════════════════════════════════════════════════════════════ */
.shelf-hint {
  position: absolute;
  bottom: 100%;
  inset-inline-end: 0;
  margin-bottom: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #f4e4b8;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

.book:hover .shelf-hint {
  opacity: 1;
}

/* ═════════════════════════════════════════════════════════════
   LIBRARY STATS — small footer
   ═════════════════════════════════════════════════════════════ */
.library-stats {
  max-width: 1380px;
  margin: 24px auto 0;
  padding: 14px 24px;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-around;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.library-stats .stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.library-stats .stat-num {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.library-stats .stat-label {
  font-size: 10px;
  color: var(--ink-faint);
}

/* When dragging, the book is detached from shelf flex layout via inline
   styles (book.style.position = 'fixed' in JS). No class-based override
   needed — keep pointer-events on so pointer capture works correctly. */

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .book.is-dragging .book-spine { transform: none; }
  .book:hover .book-spine { transform: none; }
}

/* Mobile responsive */
@media (max-width: 720px) {
  .library-header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 12px;
  }
  .library-nav { justify-content: center; flex-wrap: wrap; }
  .chat-bar {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .chat-brand { border-right: none; min-width: 0; }
  .chat-input-strip, .chat-skin-strip { border-left: none; padding: 6px 10px; }
  .reading-desk-body { padding: 18px; }
  .reading-content { padding: 22px 18px; }
  .reading-content h1 { font-size: 24px; }
  body.book-open { padding-bottom: 80vh; }
}
