/* FOOREND AI STUDY — arcade editorial */
:root {
  --paper: #faf4e8;
  --card: #fffdf6;
  --ink: #17130e;
  --ink-soft: #4d453a;
  --red: #e8401c;
  --orange: #ff8a00;
  --lime: #b5e941;
  --lime-deep: #7dbb1e;
  --blue: #2f6bff;
  --line: #17130e;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 14px;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo",
    "Noto Sans KR", sans-serif;
  --mono: "SF Mono", ui-monospace, "D2Coding", Menlo, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}
.logo {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font); color: var(--ink);
}
.logo-mark { font-size: 22px; }
.logo-text { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
.logo-text b { color: var(--red); font-weight: 800; }
.top-progress { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-progress-track {
  flex: 1; height: 14px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--card); overflow: hidden;
}
.top-progress-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(135deg, var(--lime) 0 10px, var(--lime-deep) 10px 20px);
  transition: width 0.4s ease;
}
.top-progress-label { font-weight: 800; font-size: 13px; min-width: 38px; text-align: right; }
.top-team {
  font-size: 12px; font-weight: 700; white-space: nowrap;
  border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.top-team.ok { background: var(--lime); }

/* ---------- layout ---------- */
.layout {
  flex: 1; display: grid; grid-template-columns: 240px 1fr;
  gap: 24px; width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 24px 20px 120px;
}

/* mission rail */
.rail { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 8px; }
.rail-item {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 2px solid var(--ink); border-radius: 10px;
  background: var(--card); padding: 8px 10px; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--ink);
  transition: transform 0.08s ease;
}
.rail-item:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.rail-item.active { background: var(--ink); color: var(--paper); box-shadow: var(--shadow-sm); }
.rail-item.done .rail-no { background: var(--lime); color: var(--ink); }
.rail-no {
  flex: none; width: 26px; height: 26px; border: 2px solid currentColor; border-radius: 8px;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.rail-item.active .rail-no { border-color: var(--paper); }
.rail-meta { display: flex; flex-direction: column; min-width: 0; }
.rail-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-min { font-size: 10px; opacity: 0.65; font-weight: 700; }

/* ---------- stage ---------- */
.stage { min-width: 0; }
.screen {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px 36px 40px;
  animation: pop 0.25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
  background: var(--ink); color: var(--paper);
  border-radius: 999px; padding: 4px 14px; margin-bottom: 14px;
}
.kicker .time { color: var(--lime); }
.screen h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; line-height: 1.25; letter-spacing: -0.03em; margin-bottom: 6px; }
.screen h2 { font-size: 20px; font-weight: 800; margin: 28px 0 10px; letter-spacing: -0.02em; }
.screen h3 { font-size: 16px; font-weight: 800; margin: 18px 0 6px; }
.lead { font-size: 16px; color: var(--ink-soft); margin-bottom: 8px; max-width: 62ch; }
.screen p { margin: 10px 0; max-width: 68ch; }
.screen ul, .screen ol { margin: 10px 0 10px 22px; max-width: 66ch; }
.screen li { margin: 6px 0; }
.screen a { color: var(--blue); font-weight: 700; text-underline-offset: 3px; }
.small { font-size: 13px; color: var(--ink-soft); }
.mark { background: linear-gradient(transparent 55%, var(--lime) 55%); font-weight: 700; }
.accent { color: var(--red); font-weight: 800; }

blockquote {
  border-left: 6px solid var(--red); background: #fdf0e5;
  padding: 14px 18px; margin: 16px 0; border-radius: 0 10px 10px 0;
  font-weight: 600; max-width: 66ch;
}

/* tables */
.tbl { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.tbl th, .tbl td { border: 2px solid var(--ink); padding: 8px 12px; text-align: left; vertical-align: top; }
.tbl th { background: var(--ink); color: var(--paper); font-size: 12.5px; letter-spacing: 0.04em; }
.tbl-wrap { overflow-x: auto; }

/* callouts */
.callout {
  border: 2px solid var(--ink); border-radius: 12px; padding: 14px 18px;
  margin: 16px 0; background: #fffbe8; box-shadow: var(--shadow-sm);
}
.callout.warn { background: #fdeae4; }
.callout.good { background: #eef9d8; }
.callout .co-title { font-weight: 800; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }

/* code */
.codeblock {
  position: relative; background: var(--ink); color: #f4f0e6;
  border-radius: 12px; padding: 16px 18px; margin: 14px 0;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  overflow-x: auto; white-space: pre;
}
.codeblock .copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: var(--lime); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 8px; font-family: var(--font); font-size: 11px; font-weight: 800;
  padding: 3px 10px; cursor: pointer;
}
code.inline {
  font-family: var(--mono); font-size: 0.88em; background: #efe8d8;
  border: 1px solid #d8cfba; border-radius: 6px; padding: 1px 6px;
}

/* ---------- tool cards ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 16px; }
.tool-card {
  border: 2px solid var(--ink); border-radius: 12px; background: var(--paper);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.08s ease;
}
.tool-card.done { background: #eef9d8; }
.tool-card.skipped { background: #efeadf; opacity: 0.85; }
.tool-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tool-name { font-weight: 800; font-size: 16px; }
.tool-status {
  font-size: 11px; font-weight: 800; border: 2px solid var(--ink); border-radius: 999px;
  padding: 2px 10px; background: var(--card); white-space: nowrap;
}
.tool-status.s-visited { background: var(--orange); color: var(--ink); }
.tool-status.s-done { background: var(--lime); }
.tool-status.s-skipped { background: #d9d2c4; }
.tool-tag { font-size: 11px; font-weight: 800; color: var(--red); letter-spacing: 0.06em; }
.tool-tag.opt { color: var(--blue); }
.tool-body { font-size: 13.5px; color: var(--ink-soft); }
.tool-body b { color: var(--ink); }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tool-evidence { display: flex; gap: 8px; margin-top: 6px; }
.tool-evidence input {
  flex: 1; border: 2px solid var(--ink); border-radius: 8px; padding: 7px 10px;
  font-family: var(--font); font-size: 13px; background: var(--card);
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--ink); border-radius: 10px; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 800; color: var(--ink);
  background: var(--card); padding: 8px 16px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-decoration: none;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn.primary { background: var(--red); color: #fff; }
.btn.lime { background: var(--lime); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* forms */
.field { margin: 14px 0; max-width: 640px; }
.field label { display: block; font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; margin-bottom: 6px; }
.field input[type="text"], .field input[type="date"], .field textarea, .field select {
  width: 100%; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--card); padding: 10px 12px;
  font-family: var(--font); font-size: 14px; color: var(--ink);
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; box-shadow: 0 0 0 3px var(--lime);
}

/* role select */
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.role-card {
  border: 2px solid var(--ink); border-radius: 14px; background: var(--paper);
  padding: 22px; cursor: pointer; text-align: left; font-family: var(--font);
  transition: transform 0.08s ease;
}
.role-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.role-card.selected { background: var(--lime); box-shadow: var(--shadow); }
.role-emoji { font-size: 34px; }
.role-name { font-size: 18px; font-weight: 800; margin: 8px 0 4px; }
.role-desc { font-size: 13px; color: var(--ink-soft); }

/* quiz */
.quiz { border: 2px solid var(--ink); border-radius: 12px; padding: 16px 18px; margin: 14px 0; background: var(--paper); }
.quiz-q { font-weight: 800; margin-bottom: 10px; }
.quiz-actions { display: flex; gap: 10px; }
.quiz-result { margin-top: 10px; font-weight: 700; font-size: 14px; }
.quiz-result.ok { color: var(--lime-deep); }
.quiz-result.no { color: var(--red); }

/* gate */
.gate-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.gate-row {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--ink); border-radius: 12px; padding: 12px 16px; background: var(--paper);
}
.gate-row.pass { background: #eef9d8; }
.gate-row.fail { background: #fdeae4; }
.gate-icon { font-size: 20px; }
.gate-name { font-weight: 800; flex: 1; }
.gate-banner {
  border: 3px solid var(--ink); border-radius: 14px; text-align: center;
  padding: 26px; margin: 20px 0; font-size: 26px; font-weight: 800; letter-spacing: 0.12em;
  box-shadow: var(--shadow);
}
.gate-banner.open { background: var(--lime); }
.gate-banner.locked { background: #fdeae4; color: var(--red); }

/* badges */
.badge-strip { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--ink); border-radius: 999px; padding: 6px 14px;
  background: var(--card); font-size: 13px; font-weight: 800; box-shadow: var(--shadow-sm);
}
.badge.earned { background: var(--lime); }
.badge.dim { opacity: 0.35; box-shadow: none; }

/* output preview */
.output-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.output-col h3 { margin-top: 0; }
@media (max-width: 900px) { .output-cols { grid-template-columns: 1fr; } }

/* link cards */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 14px 0; }
.link-card {
  border: 2px solid var(--ink); border-radius: 12px; padding: 14px 16px;
  background: var(--paper); text-decoration: none; color: var(--ink);
  transition: transform 0.08s ease;
}
.link-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-sm); }
.link-card .lc-name { font-weight: 800; font-size: 14px; }
.link-card .lc-desc { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.link-card .lc-url { font-size: 11px; color: var(--blue); font-family: var(--mono); word-break: break-all; }

/* ---------- footer nav ---------- */
.navbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--paper); border-top: 2px solid var(--ink);
}
.nav-btn {
  border: 2px solid var(--ink); border-radius: 12px; background: var(--card);
  font-family: var(--font); font-size: 14px; font-weight: 800; color: var(--ink);
  padding: 10px 22px; cursor: pointer; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.nav-btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-btn.next { background: var(--ink); color: var(--paper); }
.nav-center { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); text-align: center; }
.nav-center .kbd {
  display: inline-block; border: 1.5px solid var(--ink-soft); border-radius: 5px;
  padding: 0 6px; font-size: 11px; font-family: var(--mono);
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(23, 19, 14, 0.55);
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
canvas[hidden] { display: none; }
.modal {
  width: min(560px, 100%); background: var(--card); border: 3px solid var(--ink);
  border-radius: 16px; box-shadow: 8px 8px 0 var(--ink); padding: 26px 28px;
  max-height: 85vh; overflow-y: auto; animation: pop 0.2s ease;
}
.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.modal .modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal .reason-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.modal .reason-btn {
  text-align: left; border: 2px solid var(--ink); border-radius: 10px;
  background: var(--paper); padding: 10px 14px; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 700; color: var(--ink);
}
.modal .reason-btn:hover { background: var(--lime); }
.modal .reason-help { font-size: 13px; background: #fffbe8; border: 2px solid var(--ink); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }

/* toast */
.toast {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-weight: 700; font-size: 14px;
  border-radius: 999px; padding: 10px 22px; z-index: 90; border: 2px solid var(--lime);
  animation: pop 0.2s ease;
}

/* confetti */
#confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

/* intro hero */
.hero-title {
  font-size: clamp(38px, 7vw, 64px); font-weight: 900; line-height: 1.1;
  letter-spacing: -0.04em; margin: 10px 0 16px;
}
.hero-title .stroke { color: var(--red); }
.hero-flow {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-weight: 800; font-size: 15px; margin: 8px 0 20px;
}
.hero-flow span {
  border: 2px solid var(--ink); border-radius: 999px; padding: 6px 16px;
  background: var(--card); box-shadow: var(--shadow-sm);
}
.hero-flow span:nth-child(3) { background: var(--orange); }
.hero-flow span:nth-child(5) { background: var(--lime); }

/* checklists */
.check-item { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; max-width: 66ch; }
.check-item input[type="checkbox"] {
  width: 20px; height: 20px; margin-top: 2px; accent-color: var(--lime-deep); flex: none; cursor: pointer;
}
.check-item label { cursor: pointer; }

/* saved chip */
.save-chip { display: inline-block; font-size: 12px; font-weight: 800; color: var(--lime-deep); margin-left: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px 12px 130px; gap: 12px; }
  .rail {
    position: sticky; top: 62px; z-index: 30; flex-direction: row; overflow-x: auto;
    background: var(--paper); padding: 6px 2px; gap: 6px;
  }
  .rail-item { flex: none; }
  .rail-meta { display: none; }
  .screen { padding: 24px 20px 30px; }
  .top-team { display: none; }
  .logo-text { display: none; }
}
