@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;600;700&family=Instrument+Serif:ital@1&display=swap");

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --ink: #0a0a0a;
  --ink-2: #27272a;
  --muted: #71717a;
  --subtle: #a1a1aa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #b45309;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04), 0 1px 1px rgba(10, 10, 10, 0.03);
  --shadow: 0 1px 2px rgba(10, 10, 10, 0.04), 0 8px 24px -8px rgba(10, 10, 10, 0.1);
  --shadow-lg: 0 2px 4px rgba(10, 10, 10, 0.04), 0 24px 64px -16px rgba(10, 10, 10, 0.18);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo",
    "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Instrument Serif", "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--ink);
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

[hidden] {
  display: none !important;
}

svg.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

/* ───────── Background ───────── */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.bg-layer .grid {
  position: absolute;
  inset: -1px;
  background-image: linear-gradient(to right, rgba(10, 10, 10, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(10, 10, 10, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}
.bg-layer .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: orb-float 18s var(--ease) infinite alternate;
}
.bg-layer .orb.a {
  width: 520px;
  height: 520px;
  top: -180px;
  left: -120px;
  background: radial-gradient(circle, #e4e4e7, transparent 70%);
}
.bg-layer .orb.b {
  width: 460px;
  height: 460px;
  top: 10%;
  right: -160px;
  background: radial-gradient(circle, #d4d4d8, transparent 70%);
  animation-delay: -6s;
}
.bg-layer .noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes orb-float {
  to {
    transform: translate3d(60px, 40px, 0) scale(1.08);
  }
}

/* ───────── Nav ───────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(250, 250, 250, 0.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.nav.scrolled {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.82);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 14px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 4px 12px -4px rgba(10, 10, 10, 0.5);
  transition: transform 0.5s var(--ease-spring);
}
.brand:hover .brand-mark {
  transform: rotate(-8deg) scale(1.06);
}
.brand-mark svg.lucide {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.pulse-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0;
  animation: ping 2s var(--ease) infinite;
}
@keyframes ping {
  0% {
    transform: scale(0.4);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ───────── Buttons ───────── */
.btn {
  --h: 40px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn:hover {
  border-color: var(--line-strong);
  background: #fcfcfc;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-sm {
  --h: 32px;
  padding: 0 11px;
  border-radius: 9px;
  font-size: 13px;
}
.btn-sm svg.lucide {
  width: 15px;
  height: 15px;
}
.btn-lg {
  --h: 54px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 15.5px;
}
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 20px -8px rgba(10, 10, 10, 0.55);
}
.btn-primary:hover {
  background: #18181b;
  border-color: #18181b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 28px -10px rgba(10, 10, 10, 0.6);
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.9s var(--ease);
}
.btn-primary:hover::before {
  transform: translateX(120%);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
}
.btn .arrow {
  transition: transform 0.3s var(--ease);
}
.btn:hover .arrow {
  transform: translateX(3px);
}
.btn.loading {
  pointer-events: none;
}
.btn.loading > * {
  opacity: 0;
}
.btn.loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn.copied {
  color: var(--success);
  border-color: #bbf7d0;
  background: #f0fdf4;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ───────── Form ───────── */
.field {
  display: grid;
  gap: 7px;
}
.field > label,
.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.label .opt {
  color: var(--subtle);
  font-weight: 500;
}
.input,
.textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.textarea {
  height: auto;
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.6;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--subtle);
}
.input:hover,
.textarea:hover {
  border-color: var(--line-strong);
}
.input:focus,
.textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(10, 10, 10, 0.07);
}
.input.mono,
.textarea.mono {
  font-family: var(--mono);
  font-size: 13.5px;
}
.input-wrap {
  position: relative;
}
.input-wrap > svg.lucide {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}
.input-wrap > .input {
  padding-left: 40px;
}
.input-wrap .suffix {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

/* ───────── Card / chips ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip svg.lucide {
  width: 14px;
  height: 14px;
}
.chip-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.chip-success {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.chip-muted {
  color: var(--muted);
  background: var(--surface-2);
  border-color: transparent;
}
.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--muted);
}

/* ───────── Toast ───────── */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: min(92vw, 440px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.45s var(--ease-spring) both;
}
.toast.out {
  animation: toast-out 0.3s var(--ease) forwards;
}
.toast .icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}
.toast .icon svg.lucide {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}
.toast.error .icon {
  background: var(--danger);
}
.toast.success .icon {
  background: var(--success);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.92);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}

/* ───────── Motion helpers ───────── */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease);
  transition-delay: var(--d, 0s);
}
.reveal.in {
  opacity: 1;
  transform: none;
  filter: none;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(3px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-6px);
  }
  40%,
  60% {
    transform: translateX(6px);
  }
}
.shake {
  animation: shake 0.5s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
