/* ============================================================
   Šaltinių medžioklė — global tokens + OS chrome styles
   ============================================================ */

:root {
  /* Brand from design-system.md */
  --accent: #1d3557;
  --accent-soft: rgba(29, 53, 87, 0.08);
  --accent-border: rgba(29, 53, 87, 0.18);
  --bg: #f4f1ea;
  --paper: #ffffff;
  --offwhite: #fafaf7;
  --highlight: #fff4a3;
  --success: #5a8a3a;
  --error: #a33d3d;
  --margin-note: #f4f1e8;

  /* Windows 11 desktop tones (warm-shifted per design system) */
  --desk-1: #f4ead8;
  --desk-2: #e8d6b0;
  --desk-3: #d9bd8a;

  /* Typography */
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Variable", Roboto, sans-serif;
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;

  /* Shadows */
  --shadow-paper: 0 2px 8px rgba(0, 0, 0, 0.06), 0 12px 24px rgba(0, 0, 0, 0.04);
  --shadow-sticky: 0 2px 4px rgba(0, 0, 0, 0.08), 0 6px 12px rgba(0, 0, 0, 0.06);
  --shadow-sticky-up: 0 2px 4px rgba(0, 0, 0, 0.08), 0 6px 12px rgba(0, 0, 0, 0.06), 0 16px 28px rgba(0, 0, 0, 0.12);
  --shadow-window: 0 12px 28px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
  --shadow-window-deep: 0 24px 48px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ui);
  font-size: 14px;
  color: #1a1a1a;
  background: #000;
  overflow: hidden;
  height: 100vh;
  /* Use dynamic viewport on mobile so the address-bar collapse
     doesn't leave a gap below the taskbar. */
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:focus-visible,
[tabindex]:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
   OS shell — desktop, taskbar, window
   ============================================================ */

.os-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* Fullscreen narrative scene — covers everything (no window chrome) */
.fullscreen-scene {
  position: absolute;
  inset: 0;
  z-index: 250;
  background: #fafaf7;
  overflow-y: auto;
  overflow-x: hidden;
  animation: fullscreenIn 600ms cubic-bezier(.18, 1.1, .3, 1) both;
}
@keyframes fullscreenIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* S4: full-page narrative (no OS shell). Page itself scrolls. */
.s4-fullpage {
  min-height: 100vh;
  background: #fafaf7;
  animation: fullscreenIn 600ms cubic-bezier(.18, 1.1, .3, 1) both;
}
/* When s4 is mounted, release body's height/overflow lock so the page scrolls. */
body.s4-active, html.s4-active {
  overflow: auto !important;
  height: auto !important;
  min-height: 100vh;
  background: #fafaf7 !important;
}

/* Wallpaper: warm Windows 11-style abstract bloom */
.wallpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 70% 30%, #f4d9a8 0%, transparent 55%),
    radial-gradient(ellipse 50% 70% at 30% 70%, #e8c890 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 50% 50%, #f0e0c4 0%, transparent 60%),
    linear-gradient(135deg, #e8d2a0 0%, #d4b478 100%);
  z-index: 0;
}

.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 30%, rgba(0,0,0,0.08) 100%);
  pointer-events: none;
}

/* Desktop icons surface */
.desktop {
  position: absolute;
  inset: 0 0 56px 0;
  padding: 24px;
  z-index: 1;
}

.desktop-icon {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 88px;
  padding: 6px;
  border-radius: 4px;
  text-align: center;
  user-select: none;
  cursor: default;
  transition: background 0.12s ease;
}
.desktop-icon:hover { background: rgba(255,255,255,0.18); }
.desktop-icon.selected { background: rgba(0, 80, 180, 0.28); outline: 1px solid rgba(255,255,255,0.4); }
.desktop-icon .icon-glyph { width: 48px; height: 48px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.desktop-icon .icon-label {
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  line-height: 1.2;
  word-break: break-word;
}

/* Sticky note on desktop */
.desktop-sticky {
  position: absolute;
  background: var(--highlight);
  box-shadow: var(--shadow-sticky);
  padding: 14px 16px;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  border-radius: 2px 4px 3px 5px;
  max-width: 220px;
  transform: rotate(-2deg);
  color: #2a2410;
}

/* Taskbar */
.taskbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background: rgba(243, 243, 243, 0.86);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  z-index: 100;
  box-shadow: 0 -1px 2px rgba(0,0,0,0.04);
}
.taskbar-apps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}
.taskbar-app {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.12s ease;
}
.taskbar-app:hover { background: rgba(0,0,0,0.06); }
.taskbar-app.open::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 6px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.taskbar-app.active::after {
  width: 18px;
  background: var(--accent);
}
.taskbar-app .ti {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.taskbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  font-size: 12px;
  color: #1a1a1a;
}
.taskbar-clock {
  text-align: right;
  line-height: 1.15;
  font-feature-settings: "tnum";
  padding: 4px 8px;
  border-radius: 4px;
}
.taskbar-clock:hover { background: rgba(0,0,0,0.06); }
.taskbar-lang {
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.taskbar-lang:hover { background: rgba(0,0,0,0.06); }

/* ============================================================
   Window chrome
   ============================================================ */

.win {
  position: absolute;
  background: var(--offwhite);
  border-radius: 8px;
  box-shadow: var(--shadow-window);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: box-shadow 0.15s ease;
  border: 1px solid rgba(0,0,0,0.08);
}
.win.focused { z-index: 20; box-shadow: var(--shadow-window-deep); }
.win.maximized { border-radius: 0; }

.win-titlebar {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f4f4f4;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  user-select: none;
  flex-shrink: 0;
}
.win-titlebar .title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  font-size: 12px;
  color: #1a1a1a;
  min-width: 0;
  flex: 1;
}
.win-titlebar .title > span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-titlebar .title-icon { width: 16px; height: 16px; flex-shrink: 0; }
.win-controls {
  display: flex;
  align-items: stretch;
  height: 100%;
}
.win-controls button {
  width: 46px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  font-size: 10px;
  transition: background 0.12s ease;
}
.win-controls button:hover { background: rgba(0,0,0,0.06); }
.win-controls .close:hover { background: #e81123; color: #fff; }

.win-body {
  flex: 1;
  overflow: auto;
  background: var(--offwhite);
  position: relative;
}
.win.cascade-win { position: absolute; }
.cascade-win.behind .win-titlebar { background: #eaeaea; }
.cascade-behind-overlay {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  z-index: 1;
}
.cascade-behind-overlay:hover { background: rgba(29, 53, 87, 0.04); }

/* Split layout (Scene 1) */
.split-pane {
  position: absolute;
  top: 60px;
  bottom: 58px;
  z-index: 90;
}
.split-pane.left  { left: 2%;  right: 51%; }
.split-pane.right { left: 51%; right: 2%; z-index: 100; }
/* Mobile branch: full-bleed single Edge window (no Word strip). The phone
   gets the entire viewport above the taskbar. */
.split-pane.right.mobile {
  position: absolute;
  left: 0; right: 0;
  top: 0; bottom: 56px;
  z-index: 100;
}
.split-win {
  position: absolute !important;
  inset: 0;
  opacity: 1;
  pointer-events: auto;
}
.split-win.faded { opacity: 0.92; }
.split-win.interactive {
  box-shadow: 0 20px 48px rgba(0,0,0,0.24), 0 4px 12px rgba(0,0,0,0.12);
}
.split-win:not(.interactive) {
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}

/* ============================================================
   Utility: primary / secondary buttons (design system)
   ============================================================ */

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 6px;
  min-height: 44px;
  transition: box-shadow 0.15s ease, background 0.15s ease, transform 0.05s ease;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { box-shadow: 0 2px 6px rgba(29, 53, 87, 0.32); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-secondary:hover { background: var(--accent-soft); }

/* ============================================================
   Scrollbar (Windows-style thin)
   ============================================================ */
.win-body::-webkit-scrollbar,
*::-webkit-scrollbar { width: 12px; height: 12px; }
.win-body::-webkit-scrollbar-track,
*::-webkit-scrollbar-track { background: transparent; }
.win-body::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
.win-body::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover { background-color: rgba(0,0,0,0.32); background-clip: padding-box; }

/* Misc */
.no-select { user-select: none; -webkit-user-select: none; }
.tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }


/* ============================================================
   Scene-draft (and s4) shared primitives — extracted from
   scene-draft.jsx so they survive component unmount.
   ============================================================ */

        .draft-root {
          background: #e8e8e8;
          min-height: 100%;
          display: flex;
          flex-direction: column;
          font-family: var(--ui);
          color: #1a1a1a;
          position: relative;
        }

        /* Ribbon */
        .draft-ribbon {
          height: 40px;
          background: #f3f3f3;
          border-bottom: 1px solid #e0e0e0;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 0 12px;
          flex-shrink: 0;
        }
        .draft-ribbon-tabs { display: flex; gap: 2px; }
        .draft-ribbon-tab {
          font-size: 12px;
          font-weight: 400;
          color: #1a1a1a;
          padding: 6px 12px;
          border-radius: 4px;
          cursor: default;
        }
        .draft-ribbon-tab:hover { background: rgba(0,0,0,0.05); }
        .draft-ribbon-tab.active {
          color: var(--accent);
          font-weight: 600;
          border-bottom: 2px solid var(--accent);
          border-radius: 4px 4px 0 0;
        }
        .draft-ribbon-tools {
          display: flex; align-items: center; gap: 8px;
          font-size: 13px;
          color: #444;
        }
        .draft-tool {
          width: 24px; height: 24px;
          display: inline-flex; align-items: center; justify-content: center;
          border-radius: 3px;
        }
        .draft-tool:hover { background: rgba(0,0,0,0.06); }
        .draft-tool-sep { width: 1px; height: 16px; background: #ccc; }

        /* Canvas + page */
        .draft-canvas {
          flex: 1;
          padding: 24px 16px 64px;
          overflow-y: auto;
          position: relative;
        }
        .draft-page-info {
          font-family: var(--mono);
          font-size: 11px;
          color: #888;
          text-align: center;
          margin-bottom: 12px;
          letter-spacing: 0.04em;
        }
        .draft-page {
          background: #ffffff;
          max-width: 720px;
          margin: 0 auto;
          padding: 56px 64px;
          box-shadow: var(--shadow-paper);
          min-height: 480px;
        }
        @media (max-width: 560px) {
          .draft-page { padding: 40px 24px; }
        }
        .draft-heading {
          font-family: var(--serif);
          font-size: 18px;
          font-weight: 700;
          color: #1a1a1a;
          margin: 0 0 16px;
          line-height: 1.3;
        }
        .draft-paragraph {
          font-family: var(--serif);
          font-size: 16px;
          line-height: 1.65;
          color: #1a1a1a;
          margin: 0 0 24px;
          text-align: justify;
          hyphens: auto;
        }

        /* Yellow highlighter */
        .draft-highlight {
          background: var(--highlight);
          box-shadow: inset 0 -2px 0 rgba(0,0,0,0.04);
          padding: 1px 2px;
          margin: 0 1px;
          position: relative;
          border-radius: 1px;
          transition: background 0.3s ease, box-shadow 0.3s ease;
        }
        .draft-highlight.cited {
          background: rgba(255, 244, 163, 0.6);
        }
        .draft-highlight.finalized {
          background: transparent;
          box-shadow: none;
          padding: 0;
          margin: 0;
          transition: background 0.6s ease, box-shadow 0.6s ease;
        }

        /* Author-year inline citation (after all 3 verified) */
        .draft-author-year {
          background: none;
          border: none;
          padding: 0;
          color: var(--accent);
          font-family: var(--serif);
          font-size: inherit;
          font-style: italic;
          cursor: pointer;
          line-height: inherit;
          transition: color 0.15s, background 0.15s;
          border-radius: 2px;
          animation: authorYearIn 0.45s ease both;
        }
        @keyframes authorYearIn {
          from { opacity: 0; transform: translateY(-2px); }
          to   { opacity: 1; transform: translateY(0); }
        }
        .draft-author-year:hover {
          background: var(--accent-soft);
        }
        .draft-comment-marker {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          width: 16px;
          height: 16px;
          border-radius: 50%;
          background: var(--accent);
          color: #fff;
          font-family: var(--ui);
          font-size: 10px;
          font-weight: 700;
          margin-left: 4px;
          margin-right: 2px;
          vertical-align: super;
          line-height: 1;
          cursor: help;
          box-shadow: 0 1px 2px rgba(0,0,0,0.18);
          animation: commentPulse 2.4s ease-in-out infinite;
        }
        @keyframes commentPulse {
          0%, 100% { transform: scale(1); box-shadow: 0 1px 2px rgba(0,0,0,0.18), 0 0 0 0 rgba(29, 53, 87, 0.5); }
          50%      { transform: scale(1.06); box-shadow: 0 1px 2px rgba(0,0,0,0.18), 0 0 0 5px rgba(29, 53, 87, 0); }
        }

        /* Footnote marker (cited mode) */
        .draft-footnote {
          background: none;
          padding: 0 2px;
          margin-left: 2px;
          color: var(--accent);
          font-family: var(--serif);
          font-weight: 700;
          cursor: pointer;
          line-height: 1;
          transition: opacity 0.4s ease, transform 0.4s cubic-bezier(.18, 1.2, .4, 1);
          animation: footnoteIn 0.45s cubic-bezier(.18, 1.2, .4, 1) both;
        }
        @keyframes footnoteIn {
          0% { opacity: 0; transform: scale(0.4) translateY(-4px); }
          70% { transform: scale(1.18) translateY(0); }
          100% { opacity: 1; transform: scale(1); }
        }
        .draft-footnote sup {
          font-size: 0.95em;
          color: var(--accent);
          text-decoration: underline;
          text-decoration-color: rgba(29,53,87,0.4);
          text-underline-offset: 2px;
        }
        .draft-footnote:hover sup {
          background: var(--accent-soft);
          text-decoration-color: var(--accent);
        }
        .draft-footnote.opened sup {
          color: var(--success);
          text-decoration-color: var(--success);
        }

        /* Suggestion card (both modes) */
        .draft-suggestion-card {
          background: #fff;
          border: 1.5px solid var(--accent);
          border-radius: 8px;
          padding: 18px 22px;
          max-width: 480px;
          margin: 24px auto 0;
          box-shadow: 0 4px 16px rgba(29, 53, 87, 0.08);
        }
        .draft-suggestion-label {
          font-family: var(--mono);
          font-size: 10px;
          letter-spacing: 0.12em;
          text-transform: uppercase;
          color: var(--accent);
          font-weight: 700;
          margin-bottom: 6px;
        }
        .draft-suggestion-body {
          font-family: var(--serif);
          font-size: 14px;
          line-height: 1.5;
          color: #1a1a1a;
          margin-bottom: 14px;
        }

        .draft-find-btn {
          display: inline-flex;
          align-items: center;
          gap: 10px;
          background: var(--accent);
          color: #fff;
          padding: 12px 24px;
          border-radius: 6px;
          font-size: 14px;
          font-weight: 600;
          font-family: var(--ui);
          min-height: 44px;
          transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
          animation: findGlow 2s ease-in-out infinite;
        }
        .draft-find-btn:hover {
          background: #163d6b;
          animation: none;
          box-shadow: 0 2px 8px rgba(29, 53, 87, 0.32);
        }
        .draft-find-btn:active { transform: translateY(1px); }
        @keyframes findGlow {
          0%, 100% { box-shadow: 0 0 0 0 rgba(29, 53, 87, 0.45); }
          50%      { box-shadow: 0 0 0 8px rgba(29, 53, 87, 0); }
        }
        /* Busy state — user has clicked the button and the AI is "searching"
           on the other pane. Lock the button so a second click can't
           re-trigger scene transitions. */
        .draft-find-btn.is-busy {
          background: #5a5750;
          cursor: wait;
          animation: none;
          opacity: 0.92;
          box-shadow: none;
        }
        .draft-find-btn.is-busy:hover {
          background: #5a5750;
          box-shadow: none;
        }
        .draft-find-spinner {
          width: 14px; height: 14px;
          border-radius: 50%;
          border: 2px solid rgba(255,255,255,0.25);
          border-top-color: #fff;
          animation: draftFindSpin 0.9s linear infinite;
          flex-shrink: 0;
        }
        @keyframes draftFindSpin { to { transform: rotate(360deg); } }
        .draft-suggestion-card.asking .draft-suggestion-body { opacity: 0.7; }

        /* Per-source progress chips */
        .draft-cite-progress {
          display: flex;
          gap: 8px;
          margin-bottom: 14px;
          flex-wrap: wrap;
        }
        .cite-chip {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          padding: 4px 10px 4px 6px;
          background: #f3f3f0;
          border: 1px solid #ddd;
          border-radius: 14px;
          font-size: 12px;
          font-family: var(--ui);
          color: #555;
          transition: all 0.25s ease;
        }
        .cite-chip-num {
          width: 18px; height: 18px;
          border-radius: 50%;
          background: #ddd;
          color: #555;
          display: inline-flex; align-items: center; justify-content: center;
          font-family: var(--serif);
          font-weight: 700;
          font-size: 12px;
          line-height: 1;
        }
        .cite-chip.opened {
          background: rgba(90, 138, 58, 0.1);
          border-color: rgba(90, 138, 58, 0.3);
          color: var(--success);
        }
        .cite-chip.opened .cite-chip-num {
          background: var(--success);
          color: #fff;
          font-family: var(--ui);
        }
        .cite-chip.current {
          background: var(--accent-soft);
          border-color: var(--accent);
          color: var(--accent);
          font-weight: 600;
        }
        .cite-chip.current .cite-chip-num {
          background: var(--accent);
          color: #fff;
        }

        /* Primary check-source button */
        .draft-cite-btn.primary-cta {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 10px;
          background: var(--accent);
          color: #fff;
          padding: 12px 24px;
          border-radius: 6px;
          font-size: 14px;
          font-weight: 600;
          font-family: var(--ui);
          min-height: 44px;
          width: 100%;
          transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
          animation: ctaGlow 2s ease-in-out infinite;
        }
        .draft-cite-btn.primary-cta:hover {
          background: #163d6b;
          animation: none;
          box-shadow: 0 2px 8px rgba(29, 53, 87, 0.32);
        }
        .draft-cite-btn.primary-cta:active { transform: translateY(1px); }
        @keyframes ctaGlow {
          0%, 100% { box-shadow: 0 0 0 0 rgba(29, 53, 87, 0.45); }
          50%      { box-shadow: 0 0 0 8px rgba(29, 53, 87, 0); }
        }

        .draft-cite-all-opened {
          display: inline-flex;
          align-items: center;
          gap: 8px;
          color: var(--success);
          font-size: 13px;
          font-weight: 600;
          font-family: var(--ui);
        }

        /* Conclusion card (after all 3 verified) */
        .draft-suggestion-card.conclusion {
          background: #fff8dc;
          border-left: 4px solid var(--accent);
          border-top: 1px solid var(--accent-border);
          border-right: 1px solid var(--accent-border);
          border-bottom: 1px solid var(--accent-border);
          animation: conclusionIn 0.5s cubic-bezier(.18, 1.1, .3, 1) both;
        }
        @keyframes conclusionIn {
          from { opacity: 0; transform: translateY(8px); }
          to   { opacity: 1; transform: translateY(0); }
        }
        .conclusion-label {
          color: #8b4a14;
          margin-bottom: 10px;
          font-weight: 700;
          letter-spacing: 0.14em;
          display: flex;
          align-items: center;
        }
        .conclusion-title {
          font-family: var(--serif);
          font-size: 17px;
          font-weight: 700;
          color: #1a1a1a;
          line-height: 1.3;
          margin-bottom: 10px;
        }
        .conclusion-body {
          font-family: var(--serif);
          font-style: italic;
          font-size: 14px;
          line-height: 1.6;
          color: #2a2a2a;
          margin: 0 0 14px;
        }
        .conclusion-chips {
          display: flex;
          gap: 8px;
          flex-wrap: wrap;
        }
        .conclusion-chip {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          padding: 3px 10px 3px 4px;
          background: rgba(90, 138, 58, 0.12);
          border-radius: 14px;
          font-size: 12px;
          font-family: var(--ui);
          color: var(--success);
          font-weight: 600;
        }
        .conclusion-chip .cite-chip-num {
          background: var(--success);
          color: #fff;
          font-family: var(--ui);
        }

        /* Publish card */
        .draft-suggestion-card.publish {
          margin-top: 16px;
          animation: publishIn 0.5s cubic-bezier(.18, 1.1, .3, 1) 0.15s both;
        }
        @keyframes publishIn {
          from { opacity: 0; transform: translateY(8px); }
          to   { opacity: 1; transform: translateY(0); }
        }
        .draft-suggestion-card.publish .draft-find-btn {
          background: var(--accent);
          animation: none;
          box-shadow: 0 4px 12px rgba(29, 53, 87, 0.22);
        }
        .draft-suggestion-card.publish .draft-find-btn:hover {
          box-shadow: 0 6px 16px rgba(29, 53, 87, 0.32);
        }
        .draft-suggestion-card.publish .draft-find-btn:disabled {
          opacity: 0.6; cursor: wait;
        }

        /* Publishing overlay */
        .publishing-overlay {
          position: absolute;
          inset: 0;
          background: rgba(29, 53, 87, 0.62);
          backdrop-filter: blur(4px);
          -webkit-backdrop-filter: blur(4px);
          z-index: 300;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 24px;
          animation: overlayFadeIn 0.25s ease;
        }
        @keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
        .publishing-card {
          background: #fff;
          padding: 20px 28px;
          border-radius: 12px;
          box-shadow: 0 20px 40px rgba(0,0,0,0.32);
          display: flex;
          align-items: center;
          gap: 18px;
          max-width: 440px;
          animation: publishingPop 0.4s cubic-bezier(.18, 1.1, .3, 1) both;
        }
        @keyframes publishingPop {
          from { opacity: 0; transform: scale(0.92); }
          to   { opacity: 1; transform: scale(1); }
        }
        .publishing-icon {
          color: var(--accent);
          /* Explicit box matching the SVG, with inline-flex centering. Without
             this the div sized to inline-baseline content and rotated around
             a pivot below the globe's visual center, making the spinner wobble. */
          display: inline-flex;
          align-items: center;
          justify-content: center;
          width: 24px;
          height: 24px;
          flex-shrink: 0;
          transform-origin: 50% 50%;
          animation: publishingSpin 1.6s linear infinite;
        }
        @keyframes publishingSpin {
          from { transform: rotate(0deg); }
          to   { transform: rotate(360deg); }
        }
        .publishing-text {
          flex: 1;
          font-family: var(--ui);
          color: #1a1a1a;
        }
        .publishing-text strong {
          display: block;
          font-size: 14px;
          margin-bottom: 8px;
        }
        .publishing-bar {
          height: 3px;
          background: rgba(29, 53, 87, 0.12);
          border-radius: 2px;
          overflow: hidden;
        }
        .publishing-bar > div {
          height: 100%;
          width: 30%;
          background: linear-gradient(90deg, var(--accent), #4a73a8, var(--accent));
          background-size: 200% 100%;
          animation: barSlide 1.2s linear forwards;
        }
        @keyframes barSlide {
          0%   { transform: translateX(-100%); }
          100% { transform: translateX(330%); }
        }


/* ============================================================
   MOBILE & TABLET — responsive overrides
   Strategy:
   - ≤900px (tablet/landscape phones): tighten chrome, single-window stack
   - ≤640px (phone portrait): full-screen everything, simplify taskbar,
     bottom-sheet notification panels, vertical stacking
   The "windows on a desktop" metaphor collapses to "single full-screen
   panel + tiny taskbar" — readable, touch-friendly.
   ============================================================ */

@media (max-width: 900px) {
  /* Cascade depth offsets only make sense with elbow room. Collapse them.
     Scope away from .split-win (Scene 1 uses .cascade-win + .split-win on
     the same node, and the split layout wants full-bleed). */
  .cascade-win:not(.split-win) {
    left: 12px !important;
    right: 12px !important;
    top: 32px !important;
    bottom: 56px !important;
    transform: none !important;
    border-radius: 8px !important;
  }
  .cascade-win.behind { display: none !important; }

  /* Scene 1 split layout: at tablet sizes, drop the 6% wallpaper padding
     and let the two windows fill the screen edge-to-edge. The metaphor
     "two programs open side by side" works best when they actually fill
     the available space — the desktop's airy padding is wasted on a 768px
     viewport where each window otherwise gets ~270px.
     NB: at ≤820 the SplitLayout JSX switches to single-pane (Edge full +
     Word strip). These rules still cover the brief tablet-landscape
     window between 820–900 where the desktop split is rendered.
     :not(.mobile) so the mobile single-pane (full-bleed) isn't clobbered
     by the tablet-split !important rules below. */
  .split-pane.left  { left: 0 !important;  right: 50% !important; top: 12px !important; bottom: 56px !important; }
  .split-pane.right:not(.mobile) { left: 50% !important; right: 0 !important;  top: 12px !important; bottom: 56px !important; }
  .split-win {
    /* The window itself must fill its split-pane parent — override the
       inset offsets that .cascade-win would otherwise apply. */
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    inset: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    transform: none !important;
  }
  .split-pane.left .split-win  { border-right: 1px solid rgba(0,0,0,0.12) !important; }

  /* Reduce the Word doc's page padding when it's living inside a tablet-
     width window. The base 56px / 64px padding only makes sense when the
     page has 700+px to itself; at ~380px (tablet split) it eats most of
     the column. */
  .draft-page,
  .word-page,
  .s3-word-page {
    padding: 32px 22px !important;
    max-width: 100% !important;
  }
  .draft-canvas { padding: 16px 10px 32px !important; }
}

/* Phone portrait — full-screen single-pane experience */
@media (max-width: 640px) {
  body, html { font-size: 14px; }

  /* Wallpaper: keep but simpler — no second radial gradient layer */
  .wallpaper {
    background:
      radial-gradient(ellipse 80% 60% at 50% 40%, #f0e0c4 0%, transparent 60%),
      linear-gradient(135deg, #e8d2a0 0%, #d4b478 100%);
  }
  .wallpaper::after { display: none; }

  /* === Taskbar: compact, hide secondary pinned apps === */
  .taskbar {
    height: 56px;
    padding: 0 4px;
  }
  /* The 110px left spacer was for visual balance against the clock —
     irrelevant on a narrow screen. */
  .taskbar > div[aria-hidden="true"]:first-child { display: none; }
  .taskbar-apps {
    gap: 2px;
    margin: 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex: 1;
    justify-content: flex-start;
  }
  .taskbar-apps::-webkit-scrollbar { display: none; }
  .taskbar-app {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  /* Hide the never-actually-used pinned apps so the open windows are visible. */
  .taskbar-app[aria-label="Search"],
  .taskbar-app[aria-label="Files"],
  .taskbar-app[aria-label="Chrome"],
  .taskbar-app[aria-label="Crossref"] {
    display: none;
  }
  .taskbar-right { gap: 2px; padding-right: 4px; }
  .taskbar-clock {
    font-size: 10px;
    padding: 4px 6px;
    line-height: 1.15;
  }
  .taskbar-lang {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 36px;
    min-width: 36px;
  }

  /* === Cascade windows: full-bleed above taskbar === */
  .cascade-win,
  .cascade-win.focused {
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 56px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    transform: none !important;
    opacity: 1 !important;
    box-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
  }

  /* Window chrome */
  .win-titlebar { height: 40px; }
  .win-titlebar .title { font-size: 13px; padding-left: 12px; }
  .win-controls button { width: 44px; }

  /* === Split layout (Scene 1) === */
  /* Mobile branch is a single Edge window taking the full viewport above
     the taskbar — no Word strip. (The base .split-pane.right.mobile rule
     already sets this geometry; nothing to override here.) */
  .split-win {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* Intro: hide the recycle bin on phones — let the reminder + doc breathe */
  .desktop-icon { display: none; }
  /* …but keep the doc target (it has its own class, not .desktop-icon) */

  /* === Scene-draft Word page === */
  .draft-page {
    padding: 28px 18px !important;
    max-width: 100% !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06) !important;
  }
  .draft-canvas { padding: 16px 8px 48px !important; }
  .draft-page-info { font-size: 10px; }
  .draft-heading { font-size: 16px; }
  .draft-paragraph {
    font-size: 15px;
    line-height: 1.7;
    text-align: left;
    hyphens: auto;
  }
  .draft-ribbon { padding: 0 8px; }
  .draft-ribbon-tabs { overflow-x: auto; scrollbar-width: none; }
  .draft-ribbon-tabs::-webkit-scrollbar { display: none; }
  .draft-ribbon-tab { padding: 6px 8px; font-size: 11px; flex-shrink: 0; }
  .draft-ribbon-tools { display: none; }
  .draft-suggestion-card {
    padding: 14px 16px !important;
    margin: 18px -4px 0 !important;
    max-width: 100% !important;
  }
  .draft-suggestion-body { font-size: 14px; }
  .draft-find-btn,
  .draft-cite-btn.primary-cta {
    width: 100%;
    justify-content: center;
  }
}
