:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f0f1f8;
  --ink: #1a1c2e;
  --ink-soft: #5a5f7a;
  --border: #e2e4f0;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfb;
  --good: #1f9d63;
  --bad: #d64545;
  --radius: 14px;
  --shadow-sm: 0 2px 8px rgba(26, 28, 46, 0.06);
  --shadow-md: 0 14px 36px -14px rgba(26, 28, 46, 0.28);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #121324;
  --surface: #1c1e33;
  --surface-2: #24264080;
  --ink: #eef0fb;
  --ink-soft: #a3a7c6;
  --border: #2e3150;
  --accent: #8a8aff;
  --accent-ink: #10112a;
  --accent-soft: #26264a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 36px -14px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  transition: background .3s, color .3s;
}

/* ============ Shared Button ============ */
.btn {
  font-family: inherit; font-weight: 600; font-size: .95rem; line-height: 1;
  padding: 12px 20px; border-radius: 11px; border: 1.5px solid transparent; cursor: pointer;
  transition: transform .12s, background .18s, border-color .18s, box-shadow .18s, opacity .18s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--sm { padding: 8px 14px; font-size: .84rem; border-radius: 9px; }
.btn--lg { padding: 15px 26px; font-size: 1.05rem; border-radius: 13px; }

.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn--primary:hover:not(:disabled) { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn--secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--ghost:hover:not(:disabled) { background: var(--accent-soft); }

/* ============ Navbar ============ */
.ui-navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.ui-navbar--static { position: static; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; }
.ui-navbar__brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.ui-navbar__dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #ff7eb6); }
.ui-navbar__links { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.ui-navbar__links a {
  color: var(--ink-soft); text-decoration: none; font-size: .92rem; font-weight: 500;
  padding: 7px 12px; border-radius: 9px; transition: background .15s, color .15s;
}
.ui-navbar__links a:hover { background: var(--accent-soft); color: var(--accent); }
.ui-navbar__toggle {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; transition: border-color .15s;
}
.ui-navbar__toggle:hover { border-color: var(--accent); }
.ui-navbar--static .ui-navbar__links { margin-left: 0; }

/* ============ Hero ============ */
.hero { max-width: 760px; margin: 0 auto; padding: clamp(48px, 9vw, 90px) 24px 30px; text-align: center; }
.hero__eyebrow { color: var(--accent); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: .8rem; }
.hero__title { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 700; letter-spacing: -0.03em; margin: 12px 0; }
.hero__lead { color: var(--ink-soft); font-size: 1.1rem; max-width: 560px; margin: 0 auto; }

/* ============ Layout ============ */
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 24px 60px; display: flex; flex-direction: column; gap: 56px; }
.section { scroll-margin-top: 80px; }
.section__head h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.section__head p { color: var(--ink-soft); margin-top: 4px; }
.section__head { margin-bottom: 18px; }

.demo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 20px;
}
.demo__stage { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: center; }
.demo__stage--start { justify-content: flex-start; }

/* ============ Usage code block ============ */
.usage {
  margin-top: 14px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; overflow-x: auto;
}
.usage code { font-family: var(--mono); font-size: .82rem; color: var(--ink); white-space: pre; line-height: 1.7; }

/* ============ Card ============ */
.ui-card {
  width: 300px; max-width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
}
.ui-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.ui-card__media {
  height: 130px; display: grid; place-items: center; font-size: 3.4rem;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent) 22%, transparent));
}
.ui-card__body { padding: 18px 20px 20px; }
.ui-card__tag {
  display: inline-block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px;
}
.ui-card__title { font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.ui-card__text { color: var(--ink-soft); font-size: .92rem; margin-bottom: 16px; }
.ui-card__foot { display: flex; gap: 10px; }

/* ============ Modal ============ */
.ui-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.ui-modal[hidden] { display: none; }
.ui-modal__backdrop { position: absolute; inset: 0; background: rgba(10, 12, 26, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade .2s ease; }
.ui-modal__box {
  position: relative; z-index: 1; width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow-md); animation: pop .25s cubic-bezier(.22,1,.36,1);
}
.ui-modal__close {
  position: absolute; top: 14px; right: 16px; border: none; background: transparent;
  font-size: 1.7rem; line-height: 1; color: var(--ink-soft); cursor: pointer; border-radius: 8px; width: 34px; height: 34px;
}
.ui-modal__close:hover { background: var(--surface-2); color: var(--ink); }
.ui-modal__title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; padding-right: 30px; }
.ui-modal__text { color: var(--ink-soft); margin-bottom: 22px; }
.ui-modal__text kbd { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.ui-modal__actions { display: flex; gap: 10px; justify-content: flex-end; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

/* ============ Form input ============ */
.ui-field-group { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.ui-field { display: flex; flex-direction: column; gap: 7px; }
.ui-field__label { font-size: .85rem; font-weight: 600; }
.ui-field__input {
  font-family: inherit; font-size: 1rem; padding: 12px 15px; border-radius: 11px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.ui-field__input::placeholder { color: var(--ink-soft); opacity: .7; }
.ui-field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ui-field__help { font-size: .82rem; color: var(--ink-soft); }
.ui-field.is-valid .ui-field__input { border-color: var(--good); }
.ui-field.is-valid .ui-field__help { color: var(--good); }
.ui-field.is-error .ui-field__input { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 15%, transparent); }
.ui-field.is-error .ui-field__help { color: var(--bad); }

/* ============ Footer ============ */
.footer { text-align: center; color: var(--ink-soft); font-size: .85rem; padding: 30px 24px 50px; border-top: 1px solid var(--border); }

@media (max-width: 560px) {
  .ui-navbar__links { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
