/* ==========================================================================
   KavyaManch v3 - visual refresh layered on top of app.css
   Palette stays exactly as in the design system (burgundy / ivory / gold).
   Gold is used only for: active nav pill, rail accents, focus rings.
   ========================================================================== */

/* ---- Focus + motion safety ------------------------------------------------ */
.chip:focus-visible,
.translit-toggle:focus-visible,
.header-search input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@keyframes km-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .chip, .translit-toggle { transition: none; }
}

/* ---- Header search (desktop) --------------------------------------------- */
.header-search { display: none; }

@media (min-width: 900px) {
  .header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    max-width: 440px;
    margin: 0 16px;
    padding: 0 14px;
    height: 40px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: border-color 0.15s ease, background-color 0.15s ease;
  }
  .header-search:focus-within { border-color: var(--accent); background: var(--surface); }
  .header-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
  }
  .header-search input::placeholder { color: var(--text-muted); }
  .header-search-icon { display: inline-flex; }
}

/* ---- Burgundy sidebar with gold active pill (desktop) -------------------- */
@media (min-width: 900px) {
  .desktop-sidebar {
    background: linear-gradient(180deg, #6B2236 0%, #542333 55%, #3F1825 100%);
    border: 0;
    border-radius: 18px;
    padding: 14px 10px;
    box-shadow: 0 10px 28px rgba(84, 35, 51, 0.22);
  }
  [data-theme="dark"] .desktop-sidebar {
    background: linear-gradient(180deg, #3A2330 0%, #2D1C25 100%);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  }
  .desktop-sidebar .sidebar-section-label { color: #E2C98F; opacity: 0.8; }
  .desktop-sidebar .sidebar-link { color: #F4E7E1; border-radius: 12px; padding: 10px 12px; }
  .desktop-sidebar .sidebar-link:hover { background: rgba(255, 255, 255, 0.09); color: #FFFFFF; }
  .desktop-sidebar .sidebar-link.active,
  [data-theme="dark"] .desktop-sidebar .sidebar-link.active {
    background: linear-gradient(135deg, #E2C98F, #B89455);
    color: #3A1623;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  }
  .desktop-sidebar .category-badge { background: #E2C98F; color: #3A1623; border-color: transparent; }
  .desktop-sidebar .gold-divider { border-color: rgba(226, 201, 143, 0.3); }
  .desktop-sidebar .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #F4E7E1;
    border-color: rgba(255, 255, 255, 0.16);
  }
  .desktop-sidebar .btn-secondary:hover { background: rgba(255, 255, 255, 0.18); }
}

/* ---- Three-column layout with right rail (home only, >= 1200px) ---------- */
.home-rail { display: none; }

@media (min-width: 1200px) {
  body.has-rail .header-inner,
  body.has-rail .app-shell { max-width: 1320px; }
  body.has-rail .app-shell { grid-template-columns: 248px minmax(0, 1fr) 300px; }
  body.has-rail .main-column { max-width: 720px; margin: 0 auto; }
  body.has-rail .home-rail {
    display: block;
    position: sticky;
    top: calc(var(--header-height) + 18px);
    align-self: start;
  }
}

.rail-card { padding: 16px; margin-bottom: 14px; }
.rail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.rail-quote {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--gold);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
}
.rail-writers { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rail-writer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rail-writer-link { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; }
.rail-writer-text { min-width: 0; line-height: 1.3; }
.rail-writer-text strong { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-writer-text small { color: var(--text-muted); font-size: 0.78rem; }
.rail-cta { background: linear-gradient(135deg, #542333, #3F1825); border-color: transparent; }
.rail-cta .rail-title { color: #E6CF9B; }
.rail-cta .muted { color: rgba(247, 240, 233, 0.8); margin: 0 0 12px; font-size: 0.9rem; }
.rail-cta .btn-primary { background: #D5B878; color: #2B1620; border-color: transparent; }
.rail-cta .btn-primary:hover { background: #E2C98F; }

/* ---- Category chips (replace the two dropdowns) -------------------------- */
.home-tabs { margin-bottom: 12px; }
.home-tabs .tab-link svg { vertical-align: -2px; margin-right: 2px; }

.chip-filter-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.chip-row {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--secondary-rose); text-decoration: none; color: var(--text); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.chip-lang-form { flex: 0 0 auto; }
.chip-lang-form select { min-width: 128px; height: 38px; }

@media (max-width: 520px) {
  .chip-filter-bar { flex-direction: column; align-items: stretch; }
  .chip-lang-form select { width: 100%; }
}

/* ---- Fresh Voices banner -------------------------------------------------- */
.fresh-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--secondary-rose);
  border-radius: var(--radius-md);
}
.fresh-banner-icon { color: var(--gold-ink); display: inline-flex; padding-top: 2px; }
.fresh-banner p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }

/* ---- Roman -> Hindi typing toggle ---------------------------------------- */
.translit-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 0 0; }
.translit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 0.78rem var(--font-sans);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
[data-theme="dark"] .translit-toggle { color: var(--text); }
.translit-bar.is-off .translit-toggle {
  border-color: var(--border-strong);
  background: var(--surface-muted);
  color: var(--text-muted);
}
.translit-hint { font-size: 0.78rem; color: var(--text-muted); }

/* ==========================================================================
   v3.1  Interaction layer (hover / active / focus)
   One timing for the whole site: 220ms. Movement and shadows only on devices that
   truly hover (mouse / trackpad), so phones never get "sticky" hover states.
   ========================================================================== */
:root { --km-t: 220ms; --km-ease: cubic-bezier(0.2, 0.7, 0.2, 1); }

.btn, .action-btn, .sidebar-link, .sidebar-sublink, .mobile-nav-item, .tab-link, .chip,
.header-icon-btn, .header-ghost-link, .more-menu-item, .hashtag-link, .stat-link,
.people-row, .rail-writer-link, .interactive-card, .hub-tile, .post-card, .book-card-row,
.profile-header-card, .composer-card, .password-toggle, .translit-toggle, .follow-btn {
  transition: background-color var(--km-t) var(--km-ease), color var(--km-t) var(--km-ease),
              border-color var(--km-t) var(--km-ease), box-shadow var(--km-t) var(--km-ease),
              transform var(--km-t) var(--km-ease), opacity var(--km-t) var(--km-ease);
}

/* Keyboard focus: always visible, on every interactive element */
.btn:focus-visible, .action-btn:focus-visible, .sidebar-link:focus-visible, .sidebar-sublink:focus-visible,
.mobile-nav-item:focus-visible, .tab-link:focus-visible, .header-icon-btn:focus-visible,
.more-menu-item:focus-visible, .more-menu summary:focus-visible, .stat-link:focus-visible,
.password-toggle:focus-visible, .composer-card:focus-visible, .people-main:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Pressed feedback (works on touch too) */
.btn:active, .action-btn:active, .chip:active, .follow-btn:active { transform: scale(0.97); }
.mobile-nav-item:active { opacity: 0.7; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { box-shadow: 0 4px 14px rgba(84, 35, 51, 0.28); transform: translateY(-1px); }
  .btn-secondary:hover { transform: translateY(-1px); }
  .action-btn:hover { background: var(--secondary-rose); color: var(--accent); }
  [data-theme="dark"] .action-btn:hover { color: var(--text); }
  .action-btn:hover svg { transform: scale(1.1); }
  .action-btn svg { transition: transform var(--km-t) var(--km-ease); }

  .post-card:hover, .profile-header-card:hover, .book-card-row:hover, .composer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(40, 38, 41, 0.1);
    border-color: var(--border-strong);
  }
  .interactive-card:hover, .hub-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(40, 38, 41, 0.1); }
  .people-row:hover { background: var(--surface-muted); }
  .rail-writer-link:hover strong, .people-main:hover strong, .post-author-name:hover { color: var(--accent); }
  .stat-link:hover .stat-value { color: var(--accent); }
  .hashtag-link:hover { color: var(--accent); text-decoration: underline; }
  .header-icon-btn:hover { background: var(--secondary-rose); color: var(--accent); }
  .mobile-nav-item:hover { color: var(--accent); }
  .password-toggle:hover { color: var(--accent); }
  .more-menu-item:hover { background: var(--secondary-rose); }
  .tab-link:hover { color: var(--accent); }
  .chip:hover { transform: translateY(-1px); }
  .follow-btn.is-following:hover { border-color: var(--danger, #991B1B); color: var(--danger, #991B1B); }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .action-btn, .post-card, .chip, .follow-btn, .profile-header-card, .interactive-card { transition: none; }
  .btn:hover, .post-card:hover, .chip:hover, .action-btn:hover svg { transform: none; }
}

/* ---- Post author line with Follow button -------------------------------- */
.post-author-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.follow-btn { min-height: 30px; padding: 0 14px; font-size: 0.8rem; border-radius: 999px; line-height: 1; }
.post-header-right { display: flex; align-items: center; gap: 8px; }

/* ---- Action bar: three large, touch-friendly targets --------------------- */
.post-actions-bar .action-btn { min-height: 44px; min-width: 44px; justify-content: center; }

/* ---- Share fallback targets ---------------------------------------------- */
.share-targets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---- Sidebar: sub-links, profile text ------------------------------------ */
.sidebar-sublinks { display: grid; gap: 2px; margin: 2px 0 6px 18px; padding-left: 10px; border-left: 1px solid rgba(226, 201, 143, 0.35); }
.sidebar-sublink { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; font-size: 0.86rem; color: inherit; text-decoration: none; }
.sidebar-sublink:hover { background: rgba(255, 255, 255, 0.09); }
.sidebar-sublink.active { font-weight: 700; color: #E2C98F; }
.sidebar-profile-text { display: grid; line-height: 1.25; min-width: 0; }
.sidebar-profile-text small { opacity: 0.75; font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Home composer ---------------------------------------------------------- */
.composer-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 14px; color: var(--text-muted); text-decoration: none; }
.composer-ph { flex: 1; font-size: 0.95rem; }
.composer-icon { display: inline-flex; color: var(--accent); }

/* ---- Profile stats as links ---------------------------------------------- */
.stat-link { color: inherit; text-decoration: none; display: block; }

/* ---- Followers / Following list ------------------------------------------ */
.people-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.people-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border-radius: var(--radius-md); }
.people-main { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); text-decoration: none; }
.people-text { display: grid; min-width: 0; line-height: 1.3; }
.people-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-text small { color: var(--text-muted); font-size: 0.8rem; }

/* ---- Form validation + password toggle ----------------------------------- */
.field-error { margin: 6px 0 0; min-height: 0; font-size: 0.85rem; line-height: 1.4; color: #B42318; }
.field-error:empty { display: none; }
[data-theme="dark"] .field-error { color: #F4A9A0; }
.form-group.has-error .form-control { border-color: #B42318; box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12); }
.password-field { position: relative; display: block; }
.password-field .form-control { padding-right: 48px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); cursor: pointer;
}
.password-toggle:active { transform: translateY(-50%) scale(0.94); }

/* Reading view stays still: no lifting card while someone is reading */
body.is-reader-page .post-card:hover { transform: none; box-shadow: none; }

/* ==========================================================================
   v3.2  Step 1: quick fixes
   ========================================================================== */

/* Screen-reader / search text that must stay in the page but not be shown (card posts) */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Post text: nl2br() already turns each line break into <br>, so pre-wrap showed every break TWICE.
   Normal wrapping removes the doubled gaps; stanza breaks (blank lines) are still kept by the <br><br>. */
.poetry-body, .reader-body { white-space: normal; line-height: 1.7; margin: 8px 0; }
.poetry-title { margin: 8px 0 4px; }

/* Branding stays visible on phones: emblem + name + tagline (tagline wraps under the name) */
@media (max-width: 640px) {
  .brand-tagline {
    display: block;
    max-width: 44vw;
    font-size: 0.64rem;
    line-height: 1.25;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .header-inner { gap: 8px; }
  .brand-link { min-width: 0; flex: 1 1 auto; }
  .header-actions { gap: 4px; }
  .header-write-btn { padding: 0 12px; font-size: 0.82rem; white-space: nowrap; }
}

/* Infinite scroll */
.feed-sentinel { min-height: 1px; padding: 6px 0 18px; text-align: center; }
.feed-end { text-align: center; color: var(--text-muted); font-size: 0.88rem; margin: 18px 0 28px; }
.skeleton-card {
  display: grid; gap: 10px; padding: 18px; border-radius: var(--radius-lg, 16px);
  background: var(--surface); border: 1px solid var(--border);
}
.skeleton-line {
  display: block; height: 12px; border-radius: 8px; width: 100%;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--secondary-rose) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%; animation: km-shimmer 1.3s linear infinite;
}
.skeleton-line.w40 { width: 40%; } .skeleton-line.w70 { width: 70%; }
@keyframes km-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-line { animation: none; } }

/* Save sits at the far right of the action bar */
.js-bookmark-btn.is-active { color: var(--accent); }
.js-bookmark-btn.is-active svg { fill: currentColor; }

/* Discover format chips scroll sideways on phones instead of wrapping into a tall block */
.chip-scroll { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .chip { flex: 0 0 auto; }

/* ==========================================================================
   v3.3  Create studio: compact, format-aware, live card editor
   ========================================================================== */
[hidden] { display: none !important; }          /* so hidden fields never show, whatever their display rule */

.studio-compact { padding: 12px 14px 18px; }

/* Sticky bar: Write/Preview | Draft + Publish */
.studio-bar {
  position: sticky;
  top: calc(var(--header-height) + 6px);
  z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 -4px 12px; padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(40, 38, 41, 0.08);
}
.studio-bar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.studio-bar-actions .btn { white-space: nowrap; }

/* Segmented switch (Write/Preview and Text only/Make a card) */
.mode-switch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px;
}
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-muted);
  font: 600 0.86rem var(--font-sans); cursor: pointer;
  transition: background-color var(--km-t) var(--km-ease), color var(--km-t) var(--km-ease);
}
.mode-btn.is-active { background: var(--accent); color: #fff; }
.mode-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .mode-btn:not(.is-active):hover { background: var(--secondary-rose); color: var(--accent); } }

/* Format chips: one scrolling row instead of a dropdown */
.format-chips { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 8px; scrollbar-width: none; }
.format-chips::-webkit-scrollbar { display: none; }
.format-chip { flex: 0 0 auto; position: relative; cursor: pointer; }
.format-chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.format-chip span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 15px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 0.86rem; font-weight: 600; white-space: nowrap;
  transition: background-color var(--km-t) var(--km-ease), color var(--km-t) var(--km-ease), border-color var(--km-t) var(--km-ease);
}
.format-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.format-chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Card studio */
.card-studio { margin: 4px 0 12px; }
.card-studio .card-preview-frame { margin-top: 8px; padding: 10px; }
.card-studio .card-preview-frame canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 58vh; margin: 0 auto; border-radius: 10px; }
.tool-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 6px; }
.tool-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; min-height: 56px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-muted);
  font: 600 0.72rem var(--font-sans); cursor: pointer;
  transition: background-color var(--km-t) var(--km-ease), color var(--km-t) var(--km-ease), border-color var(--km-t) var(--km-ease);
}
.tool-tab.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .tool-tab.is-active { color: var(--text); }
.tool-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .tool-tab:hover { background: var(--secondary-rose); color: var(--accent); } }
.tool-panel { padding: 8px 2px 2px; }
.tool-panel .controls-row { margin-bottom: 4px; }

/* Originality + small checkbox rows */
.orig-line {
  display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 12px; padding: 10px 12px;
  border: 1px solid var(--gold); border-radius: 12px; background: var(--surface-tint); cursor: pointer; font-size: 0.9rem;
}
.orig-line input { margin-top: 4px; flex: 0 0 auto; }
.orig-line small { display: block; font-size: 0.78rem; margin-top: 2px; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; margin-top: 4px; }

/* More options */
.more-options { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-muted); }
.more-options > summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 0.92rem;
}
.more-options > summary::-webkit-details-marker { display: none; }
.more-options > summary svg:last-child { margin-left: auto; transition: transform var(--km-t) var(--km-ease); }
.more-options[open] > summary svg:last-child { transform: rotate(180deg); }
.more-options-body { padding: 4px 14px 14px; }

@media (max-width: 520px) {
  .studio-compact { padding: 10px 10px 16px; }
  .studio-bar .draft-status-pill, .studio-bar .bar-label { display: none; }
  .mode-btn { padding: 0 11px; }
  .tool-tab span { font-size: 0.68rem; }
}
@media (prefers-reduced-motion: reduce) { .more-options > summary svg:last-child, .mode-btn, .format-chip span, .tool-tab { transition: none; } }

/* ==========================================================================
   v3.4  Stories
   ========================================================================== */
.stories-bar { margin: 0 0 12px; }
.stories-scroller { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.stories-scroller::-webkit-scrollbar { display: none; }
.story-tile-wrap { position: relative; flex: 0 0 auto; scroll-snap-align: start; }
.story-tile { display: grid; justify-items: center; gap: 6px; width: 72px; padding: 0; border: 0; background: none; color: var(--text); cursor: pointer; font: inherit; }
.story-ring {
  display: inline-flex; width: 68px; height: 68px; padding: 3px; border-radius: 50%;
  background: var(--border-strong);
  transition: transform var(--km-t, 220ms) var(--km-ease, ease), box-shadow var(--km-t, 220ms) var(--km-ease, ease);
}
.story-ring.unseen { background: conic-gradient(from 210deg, #B89455, #E2C98F, #8C435B, #542333, #B89455); }
.story-ring.empty  { background: var(--surface-muted); border: 1px dashed var(--border-strong); }
.story-avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--surface); background: var(--surface-muted); }
.story-name { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.74rem; color: var(--text-muted); }
.story-tile:focus-visible, .story-add:focus-visible, .story-icon-btn:focus-visible, .sc-swatch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.story-add {
  position: absolute; right: 2px; top: 44px; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; padding: 0;
}
.story-add svg { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { .story-tile:hover .story-ring { transform: scale(1.05); box-shadow: 0 6px 16px rgba(84, 35, 51, 0.22); } }
.story-tile:active .story-ring { transform: scale(0.96); }

body.story-open { overflow: hidden; }

/* Viewer */
.story-viewer { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(15, 10, 13, 0.92); }
.story-frame {
  position: relative; display: flex; flex-direction: column; width: min(100vw, 440px); height: min(100dvh, 780px);
  border-radius: 0; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
@media (min-width: 520px) { .story-frame { border-radius: 22px; } }
.story-progress { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 5; }
.story-seg { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.story-seg-fill { display: block; height: 100%; background: #fff; }
.story-head { position: absolute; top: 20px; left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; z-index: 6; color: inherit; }
.story-head-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, 0.7); }
.story-head-who { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.story-head-name { color: inherit; font-weight: 700; font-size: 0.92rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-head-meta { font-size: 0.74rem; opacity: 0.8; }
.story-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.18); color: inherit; cursor: pointer; }
.story-icon-btn:hover { background: rgba(0, 0, 0, 0.32); }
.story-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 84px 28px 70px; }
.story-text { margin: 0; text-align: center; font-family: var(--font-serif); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.story-hit { position: absolute; top: 76px; bottom: 56px; border: 0; background: transparent; cursor: pointer; z-index: 4; -webkit-tap-highlight-color: transparent; }
.story-hit.prev { left: 0; width: 32%; }
.story-hit.next { right: 0; width: 68%; }
.story-views { position: absolute; bottom: 16px; left: 18px; display: flex; align-items: center; gap: 6px; font-size: 0.84rem; z-index: 6; opacity: 0.9; }

/* Composer */
.story-composer { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: var(--bg); height: 100dvh; }
.sc-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.sc-close { background: var(--surface-muted); color: var(--text); }
.sc-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px; }
.sc-card { display: flex; align-items: center; justify-content: center; width: min(100%, 380px); height: min(100%, 560px); border-radius: 22px; padding: 28px; box-shadow: 0 10px 30px rgba(40, 38, 41, 0.18); }
.sc-input {
  width: 100%; height: 100%; resize: none; border: 0; outline: 0; background: transparent; text-align: center;
  font-family: var(--font-serif); font-size: 1.9rem; line-height: 1.6; padding: 0; display: block;
}
.sc-input::placeholder { color: currentColor; opacity: 0.55; }
.sc-tools { padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); display: grid; gap: 10px; }
.sc-tools .translit-bar { margin: 0; }
.sc-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; }
.sc-swatches { display: flex; gap: 10px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.sc-swatches::-webkit-scrollbar { display: none; }
.sc-swatch { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; transition: transform var(--km-t, 220ms) ease; }
.sc-swatch.is-on { box-shadow: 0 0 0 3px var(--gold); transform: scale(1.08); }

@media (prefers-reduced-motion: reduce) { .story-ring, .sc-swatch { transition: none; } }
