:root {
  --bg: #FAF8F4;
  --bg-card: #FFFFFF;
  --ink: #16181D;
  --ink-soft: #5B5F6B;
  --line: #E8E4DA;
  --accent: #4F46E5;
  --accent-soft: #EEECFB;
  --mint: #2FAE82;
  --mint-soft: #E4F5EE;
  --amber: #C2780A;
  --amber-soft: #FBF0DE;
  --radius: 14px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bg: #121317;
  --bg-card: #1B1D23;
  --ink: #F2F1ED;
  --ink-soft: #9A9CA6;
  --line: #2C2E36;
  --accent: #8B85F5;
  --accent-soft: #26243F;
  --mint: #4FD8A4;
  --mint-soft: #1B3A30;
  --amber: #E0A340;
  --amber-soft: #3A2E18;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html { overflow-x: hidden; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  opacity: 0.97;
  backdrop-filter: blur(8px);
  z-index: 50;
  transition: background .25s ease, box-shadow .2s;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
}
.brand-mark {
  color: var(--accent);
  font-size: 22px;
}
.topnav { display: flex; gap: 28px; align-items: center; }
.topnav a {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-soft);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.topnav a:hover, .topnav a.active {
  color: var(--ink);
  border-color: var(--accent);
}
.theme-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg { transition: transform .3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.theme-toggle:active svg { transform: rotate(25deg); }

/* ---------- Layout shell ---------- */
#app { max-width: 980px; margin: 0 auto; padding: 56px 24px 80px; min-height: 60vh; }

/* ---------- Home / Toolbox ---------- */
.hero {
  text-align: center;
  margin-bottom: 48px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.hero h1 .grad-word {
  background: linear-gradient(100deg, var(--accent) 0%, #B5A8FF 35%, var(--mint) 70%, var(--accent) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: skGradFlow 6s ease-in-out infinite;
}
@keyframes skGradFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.hero h1 .reveal-line {
  display: block;
  overflow: hidden;
}
.hero h1 .reveal-inner {
  display: block;
  animation: skRevealUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.hero h1 .reveal-line:nth-child(2) .reveal-inner { animation-delay: 0.12s; }
@keyframes skRevealUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.hero p {
  color: var(--ink-soft);
  font-size: 17px;
  max-width: 480px;
  margin: 0 auto;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
@media (max-width: 640px) { .shelf { grid-template-columns: 1fr; } }

.drawer {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.drawer:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(20,20,30,0.06);
  border-color: var(--accent);
}
.drawer-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  border-radius: 10px;
  color: var(--accent);
}
.drawer h3 { font-family: var(--font-display); font-size: 19px; margin: 4px 0 0; }
.drawer p { color: var(--ink-soft); font-size: 14px; margin: 0; }
.drawer-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  font-size: 11.5px;
  font-weight: 600;
  background: var(--mint-soft);
  color: var(--mint);
  padding: 3px 9px;
  border-radius: 100px;
}

/* ---------- Tool page shell ---------- */
.tool-header { margin-bottom: 28px; }
.tool-header .eyebrow {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.tool-header h2 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 6px 0 8px;
}
.tool-header p { color: var(--ink-soft); font-size: 15px; max-width: 560px; }

.tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.tab-btn { flex-shrink: 0; }
.tab-btn {
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: var(--font-body);
}
.tab-btn.active { color: var(--accent); border-color: var(--accent); }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg-card);
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone svg { color: var(--ink-soft); margin-bottom: 12px; }
.dropzone strong { display: block; font-size: 16px; margin-bottom: 4px; }
.dropzone span { color: var(--ink-soft); font-size: 13.5px; }
.dropzone input[type=file] { display: none; }

/* ---------- File cards / results ---------- */
.file-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.file-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.file-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-info .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.file-info .meta .saved { color: var(--mint); font-weight: 600; }
.file-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Controls ---------- */
.control-row { display: flex; align-items: center; gap: 14px; margin: 18px 0; flex-wrap: wrap; }
.control-row label { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
input[type=range] { accent-color: var(--accent); width: 180px; }
select, input[type=text], textarea {
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--ink);
}
textarea { font-family: var(--font-mono); width: 100%; resize: vertical; }

button.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
button.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
button.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.status-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; gap: 10px; }
.summary-pill {
  background: var(--mint-soft);
  color: var(--mint);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 100px;
}

/* ---------- Dev tools panels ---------- */
.dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .dev-grid { grid-template-columns: 1fr; } }
.dev-panel label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 8px; display: block; }
.dev-panel textarea { min-height: 280px; }
.stat-strip { display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.stat-strip div { font-size: 13px; color: var(--ink-soft); }
.stat-strip b { color: var(--ink); font-family: var(--font-mono); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); margin-top: 60px; padding: 48px 32px 24px; }
.footer-inner { max-width: 980px; margin: 0 auto; display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.footer-brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.footer-brand p { font-family: var(--font-body); font-weight: 400; color: var(--ink-soft); font-size: 13.5px; margin-top: 8px; max-width: 260px; }
.footer-links { display: flex; gap: 56px; }
.footer-links h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 0 0 10px; }
.footer-links a { display: block; font-size: 14px; margin-bottom: 8px; color: var(--ink-soft); }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { max-width: 980px; margin: 32px auto 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Static pages ---------- */
.static-page { max-width: 680px; }
.static-page h2 { font-family: var(--font-display); font-size: 28px; }
.static-page h3 { font-size: 18px; margin-top: 28px; }
.static-page p, .static-page li { color: var(--ink-soft); font-size: 15px; line-height: 1.7; }

/* ---------- Motion system ---------- */
@keyframes skFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes skFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes skPulseRing {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.18); }
  70% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
@keyframes skShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes skSpin {
  to { transform: rotate(360deg); }
}
@keyframes skMarkGlow {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(8deg); }
}

.hero { animation: skFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.hero p { animation: skFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both; }

.shelf .drawer {
  animation: skFadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.shelf .drawer:nth-child(1) { animation-delay: 0.05s; }
.shelf .drawer:nth-child(2) { animation-delay: 0.1s; }
.shelf .drawer:nth-child(3) { animation-delay: 0.15s; }
.shelf .drawer:nth-child(4) { animation-delay: 0.2s; }

.drawer-icon { transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1), background .2s; }
.drawer:hover .drawer-icon { transform: scale(1.08) rotate(-4deg); background: var(--accent); color: #fff; }
.drawer:hover h3 { color: var(--accent); transition: color .15s; }
.drawer h3 { transition: color .15s; }

.brand-mark { display: inline-block; animation: skMarkGlow 4s ease-in-out infinite; transform-origin: center; }

.tool-header { animation: skFadeUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; }

.dropzone { transition: border-color .2s, background .2s, transform .15s; }
.dropzone.dragover { transform: scale(1.01); animation: skPulseRing 1.4s ease-out infinite; }
.dropzone svg { transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.dropzone:hover svg { transform: translateY(-3px); }

.file-card {
  animation: skFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: box-shadow .15s, border-color .15s;
}
.file-card:hover { box-shadow: 0 4px 16px rgba(20,20,30,0.05); border-color: #DCD7C9; }

.file-thumb.skeleton {
  background: linear-gradient(90deg, var(--accent-soft) 25%, #F4F2FC 50%, var(--accent-soft) 75%);
  background-size: 200% 100%;
  animation: skShimmer 1.3s ease-in-out infinite;
}

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(79,70,229,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: skSpin .7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.summary-pill {
  animation: skFadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

button.btn { transition: opacity .15s, transform .12s, box-shadow .15s; }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.97); }
.btn-secondary:hover { transform: translateY(-1px); }

.tab-btn { transition: color .15s, border-color .15s; }

#app { animation: skFadeIn 0.3s ease both; }

.topbar { transition: box-shadow .2s; }
.topbar.scrolled { box-shadow: 0 1px 0 var(--line), 0 4px 16px rgba(20,20,30,0.04); }

/* ---------- Mobile nav ---------- */
.nav-burger {
  display: none;
  background: none; border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 6px;
}
@media (max-width: 760px) {
  .nav-burger { display: block; }
  .topnav {
    position: fixed;
    top: 64px; left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
  }
  .topnav.open { max-height: 360px; box-shadow: 0 12px 24px rgba(20,20,30,0.08); }
  .topnav a { width: 100%; padding: 14px 24px; border-bottom: none; }
  .topnav a.active { background: var(--accent-soft); color: var(--accent); }
  .theme-toggle { margin: 8px 24px; }
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: skFadeUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
  display: flex; align-items: center; gap: 8px;
}
.toast.error { background: var(--amber); color: #fff; }
.toast.success { background: var(--mint); color: #fff; }
.toast.fade-out { animation: skFadeOut 0.25s ease both; }
@keyframes skFadeOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Flashcards ---------- */
.flash-stage {
  perspective: 1200px;
  max-width: 480px;
  margin: 0 auto;
}
.flash-card {
  position: relative;
  height: 260px;
  cursor: pointer;
}
.flash-card-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform .5s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.flash-card.flipped .flash-card-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 28px;
  font-size: 19px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(20,20,30,0.05);
}
.flash-face.back { transform: rotateY(180deg); color: var(--accent); }
.flash-face .hint { position: absolute; bottom: 16px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.flash-deck-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash-deck-row { display: flex; gap: 10px; }
.flash-deck-row input { flex: 1; }

/* ---------- Hero signature widget ---------- */
.hero-demo {
  max-width: 420px;
  margin: 28px auto 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  box-shadow: 0 12px 32px rgba(20,20,30,0.06);
  animation: skFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}
.hero-demo-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.hero-demo-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.hero-demo-label { font-size: 12px; color: var(--ink-soft); font-family: var(--font-mono); }
.hero-demo-bars { display: flex; flex-direction: column; gap: 8px; }
.hero-demo-row { display: flex; align-items: center; gap: 10px; }
.hero-demo-name { font-size: 12.5px; color: var(--ink-soft); width: 70px; flex-shrink: 0; }
.hero-demo-track { flex: 1; height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; }
.hero-demo-fill { height: 100%; background: var(--accent); border-radius: 6px; width: 0%; transition: width 1.1s cubic-bezier(0.16, 1, 0.3, 1); }
.hero-demo-pct { font-size: 11.5px; font-family: var(--font-mono); color: var(--mint); width: 34px; text-align: right; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
