/* 루프킷 (Loopkit) — 바이럴 루프 계기판
   DESIGN.md frontmatter 토큰을 :root 에 1:1 미러. 핵심 팔레트=절제 콘솔, 액센트=단일 전기 라임-그린. */

:root {
  /* Surfaces — near-black 콘솔 레이어(순흑 금지) */
  --bg: #0E0F12;
  --bg-2: #0A0B0E;
  --surface: #15171C;
  --surface-2: #1B1E25;
  /* Ink (3단계) */
  --ink: #ECEFF4;
  --muted: #9AA3B2;
  --faint: #5C6573;
  /* Lines */
  --line: #262A33;
  --line-soft: #1E222A;
  /* Accent — 단일 시그니처 */
  --accent: #B6FF3C;
  --accent-deep: #7BD80F;
  --accent-ink: #0C1402;
  /* Semantic — 절제된 경고(의미만) */
  --warn: #FFC24B;
  --danger: #FF6B57;

  /* Decor — 그라데이션/글로우/그레인(핵심 팔레트와 달라도 됨) */
  --grad-bg-glow: radial-gradient(820px 520px at 86% -12%, rgba(182,255,60,.07), transparent 60%), radial-gradient(680px 460px at -8% 112%, rgba(123,216,15,.05), transparent 55%);
  --grad-grid: linear-gradient(transparent 95%, rgba(38,42,51,.5) 95%) 0 0 / 100% 28px, linear-gradient(90deg, transparent 95%, rgba(38,42,51,.5) 95%) 0 0 / 28px 100%;
  --grad-accent: linear-gradient(135deg, var(--accent), var(--accent-deep));
  --grad-card: linear-gradient(150deg, #C6FF4A 0%, #7BD80F 48%, #2E6B05 100%);

  /* Elevation / focus / glow */
  --shadow-sm: 0 1px 0 rgba(255,255,255,.02) inset, 0 8px 22px -16px rgba(0,0,0,.8);
  --shadow-md: 0 14px 34px -18px rgba(0,0,0,.85);
  --glow-accent: 0 0 0 1px rgba(182,255,60,.4), 0 0 22px -2px rgba(182,255,60,.45);
  --shadow-focus: 0 0 0 3px rgba(182,255,60,.22);

  /* Typography */
  --font-display: 'Space Grotesk', 'Pretendard', system-ui, sans-serif;
  --font-body: 'Inter', 'Pretendard', system-ui, 'Apple SD Gothic Neo', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
  --fs-display: clamp(40px, 7vw, 64px);
  --lh-display: 1.04;
  --fw-display: 700;
  --fs-h1: clamp(24px, 4vw, 32px);
  --lh-h1: 1.15;
  --fw-h1: 700;
  --fs-h2: 18px;
  --lh-h2: 1.3;
  --fw-h2: 600;
  --fs-body: 15px;
  --lh-body: 1.6;
  --fs-meta: 12.5px;
  --lh-meta: 1.45;

  /* Radius */
  --r-sm: 8px;
  --r-base: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Motion */
  --t-fast: 120ms;
  --t-base: 200ms;
  --ease: cubic-bezier(.2,.8,.2,1);
  --ease-tick: cubic-bezier(.34,1.2,.64,1);

  /* Dimensions */
  --maxw: 920px;

  /* i18n switcher bridge — dark theme override */
  --i18n-switch-bg: rgba(255,255,255,.04);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: rgba(182,255,60,.18);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--surface-2);
  --i18n-switch-menu-border: var(--line);
  --i18n-switch-shadow: 0 10px 28px rgba(0,0,0,.6);
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native DARK. Opposite (light) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="light"]{
  --bg: #f4f4f6;
  --bg-2: #f3f4f5;
  --surface: #f5f5f7;
  --surface-2: #f6f7f8;
  --ink: #40526f;
  --muted: #626e81;
  --faint: #7f8999;
  --line: rgba(0,0,0,0.10);
  --line-soft: rgba(0,0,0,0.10);
  --accent: #4b7800;
  --accent-deep: #457908;
  --accent-ink: #ffffff;
  --warn: #946200;
  --danger: #d61900;
  --i18n-switch-bg: #6c6c6c;
  --i18n-switch-active-bg: #4b7800;
}









* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-2);
  background-image: var(--grad-bg-glow);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(182,255,60,.28); color: var(--ink); }

a { color: var(--accent); }

button { font-family: inherit; }

/* ===== Shell ===== */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 clamp(16px, 5vw, 28px) 64px;
  position: relative;
}
.shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--grad-grid);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}
.shell > * { position: relative; z-index: 1; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--glow-accent);
  color: var(--accent);
  flex: none;
}
.brand-mark svg { width: 19px; height: 19px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.01em;
}
.brand-tagline {
  font-size: var(--fs-meta);
  color: var(--muted);
}

/* ===== Tabs ===== */
.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 8px 0;
  margin-bottom: 22px;
  background: rgba(10,11,14,.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.tab .tab-step {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--faint);
}
.tab .tab-label { font-size: 14px; font-weight: 600; }
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab[aria-selected="true"] .tab-step { color: var(--accent); }
.tab:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--r-sm); }

/* ===== Panels ===== */
.panel { display: none; animation: fadein var(--t-base) var(--ease); }
.panel.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head { margin-bottom: 18px; }
.panel-head h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: var(--fw-h1);
  margin: 0 0 6px;
  letter-spacing: -.01em;
}
.panel-head p { margin: 0; color: var(--muted); max-width: 60ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-base);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card + .card { margin-top: 16px; }
.card h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-h2);
  margin: 0 0 12px;
}

/* ===== Fields ===== */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: var(--fs-meta);
  color: var(--muted);
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="url"] {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--grad-accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: var(--fs-body);
  cursor: pointer;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn-primary:hover { box-shadow: var(--glow-accent); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--shadow-focus), var(--glow-accent); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-meta);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* ===== Segmented toggle ===== */
.seg-toggle {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.seg-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  min-height: 34px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.seg-toggle button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.seg-label {
  display: block;
  font-size: var(--fs-meta);
  color: var(--muted);
  margin-bottom: 7px;
}
.seg-group { margin-bottom: 16px; }

/* ===== Card builder layout ===== */
.card-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .card-builder { grid-template-columns: 1fr; } }

.canvas-frame {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-base);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
#cardCanvas {
  max-width: 100%;
  max-height: 460px;
  height: auto;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
}
@media (max-width: 720px) {
  .canvas-frame { position: sticky; top: 84px; }
  #cardCanvas { max-height: 360px; }
}

/* ===== Link panel ===== */
.link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 6px;
}
.link-box .link-val { flex: 1; min-width: 0; color: var(--accent); }
.ref-id { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.ref-id b { color: var(--ink); }

.share-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--fs-meta);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.share-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.share-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.share-btn svg { width: 16px; height: 16px; display: block; }

.muted-note { color: var(--muted); font-size: var(--fs-meta); }
.empty-note { color: var(--faint); font-size: var(--fs-meta); }

/* ===== Loop panel ===== */
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--faint);
  font-size: var(--fs-meta);
  font-weight: 600;
  letter-spacing: .01em;
}
.demo-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.stat {
  flex: 1 1 140px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px 15px;
}
.stat .stat-label { font-size: var(--fs-meta); color: var(--muted); }
.stat .stat-val {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 4px;
}
.stat .stat-sub { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }

.progress-bar { height: 8px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; margin: 10px 0; border: 1px solid var(--line); }
.progress-bar > span { display: block; height: 100%; background: var(--grad-accent); border-radius: var(--r-pill); transition: width var(--t-base) var(--ease); }

.tiers { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tier-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.tier-step .tier-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--faint);
}
.tier-step .tier-body { flex: 1; min-width: 0; }
.tier-step .tier-name { font-weight: 600; }
.tier-step .tier-state { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--faint); }
.tier-step.unlocked { border-color: rgba(182,255,60,.45); }
.tier-step.unlocked .tier-count { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tier-step.unlocked .tier-state { color: var(--accent); }
.tier-step.just-unlocked { box-shadow: var(--glow-accent); animation: pulse-glow 700ms var(--ease-tick); }
@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 1px rgba(182,255,60,.6), 0 0 0 0 rgba(182,255,60,.5); }
  60% { box-shadow: 0 0 0 1px rgba(182,255,60,.5), 0 0 26px 2px rgba(182,255,60,.5); }
  100% { box-shadow: var(--shadow-sm); }
}

.leaderboard { list-style: none; margin: 8px 0 0; padding: 0; }
.leaderboard li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-body);
}
.leaderboard li:last-child { border-bottom: none; }
.leaderboard .lb-rank { font-family: var(--font-mono); color: var(--muted); width: 28px; flex: none; }
.leaderboard .lb-name { flex: 1; min-width: 0; }
.leaderboard .lb-count { font-family: var(--font-mono); color: var(--ink); }
.leaderboard li.is-you { background: rgba(182,255,60,.08); border-radius: var(--r-sm); }
.leaderboard li.is-you .lb-name { color: var(--accent); font-weight: 600; }

/* ===== Health panel ===== */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist-item {
  display: flex;
  gap: 12px;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.checklist-item:hover { border-color: var(--line); }
.checklist-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.checklist-item .check-box {
  width: 22px; height: 22px;
  flex: none;
  border-radius: 6px;
  border: 1.5px solid var(--faint);
  display: grid;
  place-items: center;
  margin-top: 1px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.checklist-item .check-box svg { width: 13px; height: 13px; opacity: 0; transition: opacity var(--t-fast) var(--ease); color: var(--accent-ink); }
.checklist-item input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.checklist-item input:checked + .check-box svg { opacity: 1; }
.checklist-item input:focus-visible + .check-box { box-shadow: var(--shadow-focus); }
.checklist-item .ci-body { flex: 1; min-width: 0; }
.checklist-item .ci-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.checklist-item .ci-label { font-weight: 600; }
.checklist-item .ci-weight {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}
.checklist-item .ci-why { font-size: var(--fs-meta); color: var(--muted); margin-top: 4px; line-height: 1.5; }
.checklist-item.unmet .ci-label { color: var(--faint); }

/* score ring */
.score-block { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.score-ring { position: relative; width: 132px; height: 132px; flex: none; }
.score-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.score-ring .ring-track { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.score-ring .ring-fill { fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset var(--t-base) var(--ease), stroke var(--t-base) var(--ease); }
.score-ring .ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-ring .ring-num { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; }
.score-ring .ring-grade { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }
.score-meta { flex: 1; min-width: 180px; }
.score-meta .grade-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.score-meta .grade-delta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); margin-top: 4px; }

.prescription {
  margin-top: 16px;
  padding: 14px 16px 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
}
.prescription .rx-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.prescription .rx-head svg { width: 15px; height: 15px; }
.prescription .rx-body { color: var(--ink); }

/* grade color variants on ring + numbers */
.grade-A .ring-fill { stroke: var(--accent); }
.grade-A .grade-name, .grade-A .ring-num { color: var(--accent); }
.grade-B .ring-fill, .grade-C .ring-fill { stroke: var(--warn); }
.grade-B .grade-name, .grade-C .grade-name, .grade-B .ring-num, .grade-C .ring-num { color: var(--warn); }
.grade-D .ring-fill { stroke: var(--danger); }
.grade-D .grade-name, .grade-D .ring-num { color: var(--danger); }

/* ===== Footer ===== */
.site-foot {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: var(--fs-meta);
  line-height: 1.6;
}
.site-foot p { margin: 0 0 4px; }

/* ===== Ad slot (money-lab pattern) ===== */
.ad-slot { display: none; margin: 22px 0; text-align: center; }
.ad-slot.is-preview, .ad-slot.is-live { display: block; }
.ad-slot .ad-label { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.ad-slot .ad-ph { display: none; border: 1px dashed var(--line); border-radius: var(--r-sm); padding: 22px; color: var(--faint); font-size: var(--fs-meta); }
.ad-slot.is-preview .ad-ph { display: block; }
.ad-slot.is-preview .adsbygoogle { display: none !important; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 11px 16px;
  font-size: var(--fs-body);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== i18n switcher ===== */
.i18n-switch { --i18n-switch-bg: rgba(255,255,255,.04); }

/* ===== RTL ===== */
[dir="rtl"] .prescription { border-left: 1px solid var(--line); border-right: 2px solid var(--accent); }
[dir="rtl"] .tab { align-items: flex-end; }
[dir="rtl"] .brand { margin-right: 0; margin-left: auto; }
[dir="rtl"] .toast { border-left: 1px solid var(--line); border-right: 3px solid var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
