:root {
  --ivory: #FDFBF4;
  --ink: #2B2B2B;
  --muted: #777;
  --border: #E5E0D2;
  --orange: #F08E3D;
  --mint: #4FC4B5;
  --hint-bg: #FFF6E5;
  --accent-grad: linear-gradient(135deg, #F08E3D, #4FC4B5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'Gaegu', 'Noto Sans KR', sans-serif; letter-spacing: -0.5px; }
h1 { font-size: 28px; }

.screen { padding: 20px; max-width: 900px; margin: 0 auto; }

/* Card */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 460px;
  margin: 60px auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.card.center { text-align: center; }
.tiny { font-size: 12px; color: var(--muted); }

/* Buttons */
button.primary, button.secondary {
  border: none; border-radius: 22px; padding: 10px 20px;
  font-weight: 700; cursor: pointer; font-size: 15px;
}
button.primary { background: var(--accent-grad); color: white; }
button.primary:disabled { filter: grayscale(1); opacity: 0.5; cursor: not-allowed; }
button.secondary { background: #F5EFDE; color: var(--ink); border: 1px solid var(--border); }
button:hover { filter: brightness(1.05); }

/* Header */
header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(253, 251, 244, 0.95); backdrop-filter: blur(8px);
  padding: 16px 0; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.brand { font-family: 'Gaegu'; font-size: 22px; font-weight: 700; }
.rank-strip {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; font-size: 13px;
}
.progress {
  flex: 1; height: 8px; background: #F5EFDE;
  border-radius: 4px; overflow: hidden;
}
.progress > div {
  width: 0%; height: 100%;
  background: var(--accent-grad);
  transition: width 0.4s ease;
}
.rank-badge {
  display: inline-block;
  background: linear-gradient(135deg, #4FC4B5, #2A7A70);
  color: white; padding: 4px 12px; border-radius: 14px;
  font-weight: 700; font-size: 12px;
}
.rank-badge.big { font-size: 18px; padding: 8px 18px; margin-right: 12px; }

/* Top Nav */
.tabs-top { display: flex; gap: 8px; margin-top: 12px; }
.nav-btn {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  background: #F5EFDE; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.nav-btn.active { background: var(--accent-grad); color: white; border-color: transparent; }

/* Uploader */
.uploader {
  background: white; border: 1px dashed var(--border); border-radius: 14px;
  padding: 20px; margin: 14px 0; text-align: center;
}
.uploader img { max-width: 320px; max-height: 280px; border-radius: 10px; margin: 12px auto; display: block; }
textarea { width: 100%; min-height: 60px; padding: 10px; margin: 10px 0;
  border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }

.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
label { font-weight: 600; font-size: 14px; }
select, input[type=number] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: white;
}

/* OCR + persona */
.persona {
  background: #FFEFE5; border-left: 3px solid var(--orange);
  padding: 10px 14px; margin: 10px 0; font-style: italic;
  color: #8B4B1C; border-radius: 0 8px 8px 0; font-size: 14px;
}
.ocr {
  background: #FAF6E8; border-left: 4px solid var(--orange);
  padding: 12px 16px; border-radius: 6px; font-size: 14px;
  margin: 12px 0; white-space: pre-wrap;
}

/* Panel tabs */
.tabs-panel { display: flex; gap: 4px; margin-top: 16px; }
.tab {
  flex: 1; padding: 10px; background: #F5EFDE;
  border: 1px solid var(--border); border-bottom: none; cursor: pointer;
  font-weight: 600; font-size: 13px; border-radius: 10px 10px 0 0;
}
.tab.active { background: var(--accent-grad); color: white; border-color: transparent; }
.panel {
  display: none; padding: 18px; background: white;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 12px 12px; min-height: 120px;
  white-space: pre-wrap; line-height: 1.8;
}
.panel.active { display: block; }

/* Hint staging */
.hint-step {
  background: var(--hint-bg); border: 1px dashed var(--orange);
  border-radius: 10px; padding: 12px; margin: 8px 0;
}
.hint-step button {
  background: var(--orange); color: white; border: none;
  padding: 6px 14px; border-radius: 16px; cursor: pointer; font-weight: 700; font-size: 12px;
}
.hint-step.revealed { border-style: solid; background: #FFF1D4; }

/* Outcome */
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.outcome {
  margin-top: 14px; padding: 14px;
  background: #E8F6F3; border-left: 4px solid var(--mint);
  border-radius: 0 8px 8px 0; font-weight: 600;
}

/* History */
#historyList { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.hist-card {
  background: white; border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.hist-card img { width: 100%; max-height: 140px; object-fit: cover; border-radius: 8px; }
.hist-meta { font-size: 12px; color: var(--muted); }

/* Me */
.me-card {
  background: white; border: 1px solid var(--border); border-radius: 14px; padding: 22px;
}

/* Multi detect */
#multiList { list-style: none; padding: 0; }
#multiList li {
  padding: 12px; margin: 6px 0;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
}
#multiList li:hover { background: #FFF8E8; }
