:root {
  --cream: #FFF8EE;
  --cream-2: #FDEFDD;
  --paper: #FFFDF8;
  --orange: #F5813A;
  --orange-d: #E06A22;
  --green: #4CA771;
  --green-d: #3C8A5C;
  --yellow: #F6C445;
  --coral: #F07C63;
  --charcoal: #33302B;
  --charcoal-2: #6B655C;
  --line: #E7DBC7;
  --shadow: 0 4px 18px rgba(120, 90, 40, 0.10);
  --shadow-lg: 0 10px 34px rgba(120, 90, 40, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --sans: 'Noto Sans KR', system-ui, sans-serif;
  --hand: 'Gaegu', 'Noto Sans KR', cursive;
  --round: 'Gowun Dodum', 'Noto Sans KR', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--charcoal);
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--orange-d); }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--charcoal); color: #fff; padding: 10px 16px; z-index: 9999; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px; border: none; border-radius: 999px; font-weight: 700; font-size: 16px; background: var(--cream-2); color: var(--charcoal); transition: transform .08s, box-shadow .15s, background .15s; text-decoration: none; }
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-d); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-d); }
.btn-ghost { background: transparent; border: 2px solid var(--line); }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.btn-lg { min-height: 56px; padding: 14px 30px; font-size: 18px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { background: #E4573D; color: #fff; }
.icon-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: none; background: transparent; color: var(--charcoal); }
.icon-btn:hover { background: var(--cream-2); }

/* ===== Layout shell ===== */
.app-shell { display: flex; min-height: 100vh; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 60; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 12px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 17px; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--orange), var(--yellow)); display: grid; place-items: center; color: #fff; font-size: 19px; box-shadow: var(--shadow); }
.brand-sub { font-size: 11px; color: var(--charcoal-2); font-weight: 500; }
.topbar-spacer { flex: 1; }
.topbar .proj-name { font-size: 13px; color: var(--charcoal-2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #EAF6EF; color: var(--green-d); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.save-chip.saving { background: #FBF1D8; color: #9a7b12; }
.net-chip { font-size: 12px; padding: 4px 8px; border-radius: 999px; }
.net-online { background: #EAF6EF; color: var(--green-d); }
.net-offline { background: #FBE3DE; color: #b23a22; }

.body-wrap { display: flex; flex: 1; }
.sidebar { width: 240px; background: var(--paper); border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; flex-shrink: 0; }
.side-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--charcoal-2); padding: 12px 12px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 12px; border: none; background: transparent; font-size: 15px; font-weight: 600; color: var(--charcoal); margin-bottom: 2px; }
.nav-item .num { width: 24px; height: 24px; border-radius: 8px; background: var(--cream-2); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--charcoal-2); flex-shrink: 0; }
.nav-item.active { background: var(--orange); color: #fff; }
.nav-item.active .num { background: rgba(255,255,255,.25); color: #fff; }
.nav-item.done .num { background: var(--green); color: #fff; }
.nav-item:hover:not(.active) { background: var(--cream-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-header { background: var(--paper); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: 55px; z-index: 40; }
.progress-track { flex: 1; min-width: 120px; height: 10px; background: var(--cream-2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--yellow)); border-radius: 999px; transition: width .4s; }
.step-title { font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.content { padding: 20px max(16px, env(safe-area-inset-left)) 100px; max-width: 1100px; width: 100%; margin: 0 auto; flex: 1; }

/* ===== Bottom nav (mobile) ===== */
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--paper); border-top: 1px solid var(--line); z-index: 70; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
.bottom-nav button { flex: 1; border: none; background: transparent; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--charcoal-2); min-height: 52px; border-radius: 10px; }
.bottom-nav button.active { color: var(--orange-d); font-weight: 800; }
.bottom-nav button i { font-size: 18px; }
.hamburger { display: none; }

/* ===== Cards ===== */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.section-title { font-size: 22px; font-weight: 900; margin: 0 0 6px; }
.section-desc { color: var(--charcoal-2); margin: 0 0 18px; }
.help-note { background: #EAF6EF; border-radius: 12px; padding: 10px 14px; font-size: 14px; color: var(--green-d); display: flex; gap: 8px; align-items: flex-start; }
.warn-note { background: #FBF1D8; border-radius: 12px; padding: 10px 14px; font-size: 14px; color: #8a6d0e; display: flex; gap: 8px; }
.danger-note { background: #FBE3DE; border-radius: 12px; padding: 10px 14px; font-size: 14px; color: #b23a22; display: flex; gap: 8px; }

/* ===== Forms ===== */
label.field { display: block; margin-bottom: 14px; font-weight: 700; font-size: 14px; }
label.field span.lbl { display: block; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password], textarea, select, .input {
  width: 100%; padding: 11px 13px; border: 2px solid var(--line); border-radius: 12px; font-size: 15px; font-family: inherit; background: var(--paper); color: var(--charcoal); font-weight: 500;
}
.field-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--charcoal); }
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--orange); }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 600; color: var(--charcoal); min-height: 42px; }
.chip.selected { background: var(--orange); color: #fff; border-color: var(--orange); }
.chip.green.selected { background: var(--green); border-color: var(--green); }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; font-size: 14px; font-weight: 500; }
.checkbox-row input { width: 22px; height: 22px; margin-top: 2px; flex-shrink: 0; accent-color: var(--orange); }

/* ===== Start screen ===== */
.hero { text-align: center; padding: 50px 20px 30px; }
.hero h1 { font-family: var(--round); font-size: clamp(26px, 6vw, 44px); margin: 14px 0 8px; font-weight: 900; }
.hero .tag { color: var(--charcoal-2); font-size: clamp(14px,3vw,18px); }
.hero-mascot { font-size: 64px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }
.paper-texture { background-image: radial-gradient(var(--cream-2) 1px, transparent 1px); background-size: 22px 22px; }

/* ===== Place cards ===== */
.place-card { position: relative; overflow: hidden; }
.place-card .thumb { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 12px; background: var(--cream-2); }
.place-card .cat-badge { position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,.92); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.stars i { color: var(--yellow); }

/* ===== AI result cards ===== */
.ai-result { border-left: 5px solid var(--orange); }
.tone-badge { display: inline-block; background: var(--cream-2); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; color: var(--charcoal-2); }
.ai-badge { display: inline-flex; align-items: center; gap: 5px; background: #EEF3FF; color: #3A5BC7; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; }

/* ===== Toast & modal ===== */
#toast-root { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 9000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--charcoal); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .25s; max-width: 90vw; }
.toast.good { background: var(--green-d); }
.toast.bad { background: #C6432B; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.modal-overlay { position: fixed; inset: 0; background: rgba(40,30,15,.5); z-index: 8000; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--paper); border-radius: 20px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 24px; box-shadow: var(--shadow-lg); }
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ===== Map editor ===== */
.map-stage { position: relative; background: var(--cream); border: 2px dashed var(--line); border-radius: 16px; overflow: hidden; touch-action: none; }
.map-pin { position: absolute; transform: translate(-50%,-100%); cursor: grab; user-select: none; text-align: center; }
.map-pin .pin-icon { width: 40px; height: 40px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; box-shadow: var(--shadow); border: 2px solid #fff; }
.map-pin .pin-icon i { transform: rotate(45deg); color: #fff; }
.map-pin .pin-label { font-size: 11px; font-weight: 700; background: rgba(255,255,255,.9); border-radius: 8px; padding: 1px 6px; margin-top: 2px; display: inline-block; }
.map-tool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

/* ===== Canvas design studio ===== */
.canvas-stage { background: #fff; box-shadow: var(--shadow-lg); margin: 0 auto; position: relative; overflow: hidden; }
.canvas-el { position: absolute; cursor: move; }
.canvas-el.selected { outline: 2px solid var(--orange); }

/* ===== Badges ===== */
.badge-medal { text-align: center; }
.badge-medal .disc { width: 68px; height: 68px; border-radius: 50%; background: linear-gradient(135deg, var(--yellow), var(--orange)); display: grid; place-items: center; font-size: 30px; color: #fff; margin: 0 auto 6px; box-shadow: var(--shadow); }
.badge-medal.locked .disc { background: var(--cream-2); color: var(--charcoal-2); filter: grayscale(1); opacity: .6; }

/* ===== Misc ===== */
.spinner { width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--cream-2); border-top-color: var(--orange); }
@keyframes spin { to { transform: rotate(360deg); } }
.center-flex { display: flex; align-items: center; justify-content: center; gap: 10px; }
.muted { color: var(--charcoal-2); }
.tag-pill { display: inline-block; background: var(--cream-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; margin: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.space-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.confetti-burst { position: fixed; inset: 0; pointer-events: none; z-index: 9500; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .hamburger { display: inline-flex; }
  .content { padding-bottom: 90px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .step-header { top: 55px; }
  .topbar .proj-name { display: none; }
}
@media (max-width: 520px) {
  .topbar { gap: 5px; }
  .topbar .brand > span:last-child { display: none; }
  .topbar .brand { flex: 0 0 38px; }
  .topbar .user-chip { display: none; }
  .topbar .save-chip { padding: 4px 7px; }
}
@media (min-width: 861px) { .hamburger { display: none; } }

/* Drawer for mobile nav */
.drawer-overlay { position: fixed; inset: 0; background: rgba(40,30,15,.4); z-index: 90; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 82%; max-width: 300px; background: var(--paper); z-index: 100; padding: 16px 10px; overflow-y: auto; box-shadow: var(--shadow-lg); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

@media print {
  .topbar, .sidebar, .bottom-nav, .step-header, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}

/* Presentation big mode */
.present-mode { font-size: clamp(20px, 3.5vw, 34px); line-height: 1.8; }
.present-mode .hl { background: var(--yellow); border-radius: 6px; padding: 0 4px; }
