/* ============================================================
   SCREENSHOT EXPLAINER — Stylesheet
   Premium dark UI. Self-contained token system.
   Sections:
     1. Tokens
     2. Reset & Base
     3. Ambient Background
     4. Layout Shell
     5. Header
     6. Panels (shared)
     7. Upload / Dropzone
     8. Custom Select + Textarea
     9. Explain Button
     10. Loading State
     11. Result Card
     12. Toasts
     13. Utilities / Scrollbar / Focus
     14. Animations
     15. Responsive
     16. Reduced Motion
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,380..800;1,14..32,380..800&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  /* Ink scale (dark theme base) */
  --ink-0: #ffffff;
  --ink-1: #f2f2f5;
  --ink-2: #a6a6b3;
  --ink-3: #7a7a88;
  --ink-4: #4a4a56;
  --ink-5: #2a2a33;
  --ink-6: #1a1a21;
  --ink-7: #121216;
  --ink-8: #0a0a0d;

  --surface-0: rgba(255, 255, 255, 0.03);
  --surface-1: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-3: rgba(255, 255, 255, 0.13);

  --border-0: rgba(255, 255, 255, 0.07);
  --border-1: rgba(255, 255, 255, 0.11);
  --border-2: rgba(255, 255, 255, 0.18);

  --bg: var(--ink-8);
  --bg-panel: var(--ink-7);
  --text: var(--ink-0);
  --text-soft: var(--ink-2);
  --text-muted: var(--ink-3);

  /* Signature accent — indigo/violet beam, evokes an analysis scan-line */
  --accent: #7c8cff;
  --accent-dim: #545fce;
  --accent-bright: #a5b0ff;
  --accent-glow: rgba(124, 140, 255, 0.22);
  --gradient-accent: linear-gradient(135deg, #7c8cff 0%, #b26bff 100%);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);

  /* Typography */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --text-xs: 11.5px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16.5px;
  --text-lg: 19px;
  --text-xl: 23px;
  --text-2xl: 30px;
  --text-3xl: clamp(30px, 4.4vw, 40px);

  --weight-normal: 400;
  --weight-medium: 520;
  --weight-semi: 620;
  --weight-bold: 720;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-2xl: 28px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.55), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 0 1px var(--accent-glow), 0 8px 32px var(--accent-glow);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 130ms;
  --dur-base: 220ms;
  --dur-slow: 420ms;

  --container-max: 1100px;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   3. AMBIENT BACKGROUND
   ============================================================ */
.bg-ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}

.bg-orb--a {
  width: 560px;
  height: 560px;
  top: -220px;
  right: -140px;
  background: radial-gradient(circle, rgba(124, 140, 255, 0.16) 0%, transparent 70%);
  animation: driftA 22s ease-in-out infinite;
}

.bg-orb--b {
  width: 520px;
  height: 520px;
  bottom: -240px;
  left: -160px;
  background: radial-gradient(circle, rgba(178, 107, 255, 0.12) 0%, transparent 70%);
  animation: driftB 28s ease-in-out infinite;
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 65% 55% at 50% 10%, black 25%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 10%, black 25%, transparent 100%);
}

@keyframes driftA {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-30px, 30px); }
}

@keyframes driftB {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -20px); }
}

/* ============================================================
   4. LAYOUT SHELL
   ============================================================ */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--space-10) var(--space-3) var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ============================================================
   5. HEADER
   ============================================================ */
.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.brand-mark {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-accent);
  color: var(--ink-0);
  box-shadow: 0 6px 20px rgba(124, 140, 255, 0.35);
}

.brand-text h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-text p {
  margin-top: 2px;
  font-size: var(--text-md);
  color: var(--text-muted);
  max-width: 380px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-soft);
  white-space: nowrap;
  margin-top: 6px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.25); }
}

/* ============================================================
   6. PANELS (shared card surface)
   ============================================================ */
.panel {
  background: var(--surface-0);
  backdrop-filter: blur(20px);
  overflow: visible;
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-0);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-4);;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}

.panel:hover {
  border-color: var(--border-1);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.step-tag {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--accent-bright);
}

.panel-head h2 {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--text);
  letter-spacing: -0.01em;
}

.panel-sub {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ============================================================
   7. UPLOAD / DROPZONE
   ============================================================ */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
  cursor: pointer;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: rgba(124, 140, 255, 0.05);
}

.dropzone.drag-active {
  border-color: var(--accent);
  background: rgba(124, 140, 255, 0.09);
  transform: scale(1.005);
  box-shadow: var(--shadow-glow);
}

.dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-10) var(--space-5);
}

.upload-icon-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  color: var(--accent-bright);
  margin-bottom: var(--space-2);
  animation: floatIcon 3.2s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.dropzone-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text);
}

.dropzone-or {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 2px 0;
}

.dropzone-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* Preview state */
.dropzone-preview {
  padding: var(--space-4);
}

.preview-frame {
  position: relative;
  width: 100%;
  max-height: 320px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-1);
  background: var(--ink-8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-frame img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
}

.scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  top: -40%;
  background: linear-gradient(180deg, transparent 0%, rgba(124, 140, 255, 0.28) 50%, transparent 100%);
  pointer-events: none;
  opacity: 0;
}

.scan-beam.scanning {
  opacity: 1;
  animation: scanSweep 1.8s ease-in-out infinite;
}

@keyframes scanSweep {
  0% { top: -40%; }
  100% { top: 100%; }
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.preview-meta-text {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--text-soft);
}

.file-icon {
  flex-shrink: 0;
  color: var(--accent-bright);
}

.preview-meta-text div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.file-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ============================================================
   8. CUSTOM SELECT + TEXTAREA
   ============================================================ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.custom-select {
  position: relative;
  outline: none;
  z-index: 9999;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
  text-align: left;
}

.custom-select-trigger:hover {
  border-color: var(--border-2);
  background: var(--surface-2);
}

.custom-select.open .custom-select-trigger,
.custom-select-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.select-icon-wrap {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

.select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--dur-base) var(--ease);
}

.custom-select.open .chevron {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 9999;
  list-style: none;
  background: rgba(18, 18, 22, 0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  max-height: 320px;
  overflow-y: auto;
  transform-origin: top center;
  animation: menuIn var(--dur-base) var(--ease-spring) both;
}

/* Blur backdrop when dropdown is open */


.explain-section.dropdown-blurred,
.panel.dropdown-blurred,
.app-header.dropdown-blurred,
.app-footer.dropdown-blurred,
#customActionWrap.dropdown-blurred {
  filter: blur(6px) brightness(0.6);
  pointer-events: none;
  transition: filter var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.custom-select-menu li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2_5, 10px) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.custom-select-menu li:hover,
.custom-select-menu li.hovered {
  background: var(--surface-2);
  color: var(--text);
}

.custom-select-menu li.active {
  color: var(--accent-bright);
  background: rgba(124, 140, 255, 0.1);
}

.opt-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

/* Custom action textarea */
.custom-action-wrap {
  margin-top: var(--space-3);
  margin-left: 0;
  margin-right: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow: hidden;
  animation: expandIn var(--dur-slow) var(--ease) both;
}

@keyframes expandIn {
  from { opacity: 0; max-height: 0; transform: translateY(-6px); }
  to { opacity: 1; max-height: 260px; transform: translateY(0); }
}

.custom-textarea {
  width: 100%;
  min-height: 92px;
  max-height: 260px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}

.custom-textarea::placeholder {
  color: var(--text-muted);
}

.custom-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.custom-textarea.input-error {
  border-color: var(--error);
}

.custom-textarea.input-error:focus {
  box-shadow: 0 0 0 4px var(--error-bg);
}

.textarea-footer {
  display: flex;
  justify-content: flex-end;
}

.word-counter {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.word-counter.limit-warn {
  color: var(--warning);
}

.word-counter.limit-exceeded {
  color: var(--error);
  font-weight: var(--weight-semi);
}

/* ============================================================
   9. EXPLAIN BUTTON
   ============================================================ */
.explain-section {
  display: flex;
  justify-content: center;
  padding: var(--space-2) 0;
}

.explain-btn {
  position: relative;
  overflow: hidden;
  width: auto;
  max-width: none;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-8);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--gradient-accent);
  color: #0a0a0d;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  box-shadow: 0 10px 32px rgba(124, 140, 255, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-base) var(--ease), opacity var(--dur-base) var(--ease);
}

.explain-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  background-size: 220% 100%;
  background-position: 150% 0;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  pointer-events: none;
}

.explain-btn:hover:not(:disabled)::after {
  opacity: 1;
  animation: sheen 1.1s ease;
}

@keyframes sheen {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

.explain-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(124, 140, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.explain-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.explain-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.explain-btn-content {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.explain-icon {
  animation: sparklePulse 2.4s ease-in-out infinite;
}

@keyframes sparklePulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.12) rotate(8deg); }
}

.explain-btn.is-loading .explain-btn-content {
  display: none;
}

.explain-btn.is-loading .explain-btn-spinner {
  display: inline-flex !important;
}

.explain-btn-spinner .spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(10, 10, 13, 0.25);
  border-top-color: #0a0a0d;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: scale(0);
  animation: rippleOut 600ms var(--ease) forwards;
  pointer-events: none;
}

@keyframes rippleOut {
  to {
    transform: scale(3.2);
    opacity: 0;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   10. LOADING STATE
   ============================================================ */
.loading-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  width: 100%;
  max-width: 320px;
}

.loading-orbit {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid var(--border-1);
  border-top-color: var(--accent);
  border-right-color: var(--accent-bright);
  animation: spin 1.1s linear infinite;
}

.orbit-core {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gradient-accent);
  box-shadow: 0 0 24px var(--accent-glow);
  animation: corePulse 1.6s ease-in-out infinite;
}

@keyframes corePulse {
  0%, 100% { transform: scale(0.9); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}

.loading-message {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text-soft);
  text-align: center;
  min-height: 24px;
}

.progress-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 6%;
  border-radius: var(--radius-pill);
  background: var(--gradient-accent);
  transition: width 900ms var(--ease);
}

/* ============================================================
   11. RESULT CARD
   ============================================================ */
.result-card {
  padding: var(--space-6);
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-0);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.result-tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin-bottom: 4px;
}

.result-header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  color: var(--text);
  letter-spacing: -0.01em;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  color: var(--text-soft);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(1px) scale(0.94);
}

.icon-btn.is-success {
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.35);
  background: var(--success-bg);
}

.result-body {
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--text-soft);
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
  padding-right: var(--space-3);
}

/* Prose elements inside result */
.result-body h1,
.result-body h2,
.result-body h3 {
  color: var(--text);
  font-weight: var(--weight-semi);
  letter-spacing: -0.01em;
  margin: var(--space-5) 0 var(--space-2);
  line-height: 1.3;
}
.result-body h1 { font-size: var(--text-lg); }
.result-body h2 { font-size: var(--text-md); }
.result-body h3 {
  font-size: var(--text-base);
  color: var(--accent-bright);
}

.result-body p {
  margin: 0 0 var(--space-3);
  color: var(--text-soft);
}

.result-body p.numbered-item {
  padding-left: var(--space-4);
  border-left: 2px solid var(--border-1);
  margin-bottom: var(--space-2);
}

.result-body ul {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.result-body li {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  color: var(--text-soft);
  line-height: 1.7;
  flex-wrap: wrap;
}

.result-body li::before {
  content: "";
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
}

.result-body strong {
  color: var(--text);
  font-weight: var(--weight-semi);
}

.result-body em {
  color: var(--text-soft);
  font-style: italic;
}

.result-body code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--accent-bright);
}

.result-body .math-inline,
.result-body .math-block {
  color: var(--accent-bright);
  background: rgba(124, 140, 255, 0.08);
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-block;
}

.result-body .math-block {
  display: block;
  text-align: center;
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  background: rgba(124, 140, 255, 0.06);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.result-body hr {
  border: none;
  border-top: 1px solid var(--border-0);
  margin: var(--space-4) 0;
}

.result-body br {
  display: block;
  content: "";
  margin-top: var(--space-1);
}

/* ============================================================
   12. TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 360px;
  width: calc(100% - 32px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-1);
  background: rgba(18, 18, 22, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  color: var(--text);
  pointer-events: auto;
  animation: toastIn var(--dur-slow) var(--ease-spring) both;
}

.toast.toast-out {
  animation: toastOut var(--dur-base) var(--ease) both;
}

.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.toast-error .toast-icon { color: var(--error); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-text {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: var(--weight-semi);
  margin-bottom: 1px;
}

.toast-desc {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ============================================================
   13. UTILITIES / SCROLLBAR / FOCUS
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(124, 140, 255, 0.32);
  color: var(--ink-0);
}

.app-footer {
  text-align: center;
  padding-top: var(--space-4);
}

.app-footer p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Buttons (secondary/browse) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border: 1px solid var(--border-1);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(1px) scale(0.97);
}

/* ============================================================
   14. ANIMATIONS (fade/slide utility classes)
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.animate-fade-in-up { animation: fadeInUp var(--dur-slow) var(--ease) both; }
.animate-fade-in-down { animation: fadeInDown var(--dur-slow) var(--ease) both; }
.animate-fade-in { animation: fadeIn var(--dur-slow) var(--ease) both; }
.animate-scale-in { animation: scaleIn var(--dur-slow) var(--ease-spring) both; }

.delay-100 { animation-delay: 80ms; }
.delay-200 { animation-delay: 160ms; }
.delay-300 { animation-delay: 240ms; }

/* Shimmer utility (unused directly but kept for skeleton-style states) */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
/* ── WHY THIS TOOL ──────────────────────────────────── */
.ss-why {
  margin: 0 auto 40px;
  max-width: 860px;
  width: 100%;
}

.ss-why__heading {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-0, #fff);
  margin-bottom: 8px;
}

.ss-why__subheading {
  font-size: 0.9rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
  margin-bottom: 24px;
  line-height: 1.6;
}

.ss-why__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.ss-why__card {
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.ss-why__card:hover {
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  transform: translateY(-2px);
}

.ss-why__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.55);
  margin-bottom: 18px;
  flex-shrink: 0;
}

.ss-why__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin-bottom: 12px;
}

.ss-why__desc {
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.7);
}

@media (max-width: 900px) {
  .ss-why__grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .ss-why__grid { grid-template-columns: 1fr; }
}
/* ============================================================
   15. RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .app-shell {
    padding: var(--space-6) var(--space-2) var(--space-10);
    gap: var(--space-4);
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: var(--space-4);
    border-radius: var(--radius-xl);
  }

  .dropzone-empty {
    padding: var(--space-6) var(--space-3);
  }

  .explain-btn {
    max-width: 100%;
    padding: 0 var(--space-5);
  }

  .file-name {
    max-width: 160px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }

  .result-header {
    flex-direction: column;
  }
}

/* ============================================================
   16. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.icon-btn.is-bookmarked {
  color: var(--accent-bright);
  border-color: rgba(124, 140, 255, 0.35);
  background: var(--accent-glow);
}