:root {
  --bg-1: #fef9c3;
  --bg-2: #dbeafe;
  --bg-3: #fde2e4;
  --card: rgba(255, 255, 255, 0.92);
  --line: #c7d2fe;
  --text: #1f2937;
  --muted: #4b5563;
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --danger: #ef4444;
  --ok: #059669;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Pretendard", "Noto Sans KR", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(130deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  background-attachment: fixed;
  font-size: 18px;
}
.container,
.mobile {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 1.25rem;
}
.container { max-width: 1440px; margin: 0 auto; }
.mobile { max-width: 960px; margin: 0 auto; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); }
h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
h3 { font-size: clamp(1.15rem, 1.8vw, 1.35rem); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.08);
}
.stack { display: grid; gap: 0.9rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

label { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.95rem; }
input, textarea, button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #bfdbfe;
  background: #fff;
  color: var(--text);
  padding: 0.8rem 0.9rem;
  font-size: 1rem;
}
textarea { min-height: 120px; resize: vertical; }
button {
  cursor: pointer;
  background: linear-gradient(180deg, #818cf8, #6366f1);
  color: #fff;
  border-color: #6366f1;
  font-weight: 700;
}
button:hover { filter: brightness(1.05); }
button.primary { background: linear-gradient(180deg, #22c55e, #16a34a); border-color: #16a34a; }
button.danger { background: linear-gradient(180deg, #f87171, #ef4444); border-color: #ef4444; }
button.ghost { background: #fff; color: var(--primary-strong); border-color: #a5b4fc; }
button:disabled { cursor: not-allowed; opacity: 0.65; }

.small { color: var(--muted); font-size: 0.95rem; }
.hidden { display: none; }
.center { text-align: center; }
.session-link { color: #4338ca; word-break: break-all; font-weight: 600; }

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  border: 1px solid #a5b4fc;
  background: #eef2ff;
  color: #4338ca;
  font-size: 0.85rem;
}
.tag.active { border-color: #6ee7b7; background: #ecfdf5; color: #047857; }
.tag.closed { border-color: #fcd34d; background: #fffbeb; color: #b45309; }

.choice-buttons {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.choice {
  min-height: 90px;
  font-size: 1.1rem;
  border-radius: 16px;
  border: 2px solid #bfdbfe;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.choice.selected {
  border-color: #16a34a;
  background: linear-gradient(180deg, #bbf7d0, #86efac);
  color: #14532d;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2) inset;
  transform: scale(1.015);
}
.choice.dimmed {
  opacity: 0.55;
}

.topic-board {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  padding: 0.7rem;
  display: grid;
  gap: 0.55rem;
}
.topic-title {
  border-radius: 10px;
  background: #bdd0f3;
  padding: 1rem;
  text-align: center;
  font-size: clamp(1.1rem, 2.6vw, 1.8rem);
  font-weight: 800;
  line-height: 1.35;
}
.topic-options {
  display: grid;
  gap: 0.5rem;
}
.topic-option-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: stretch;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #d1d5db;
}
.topic-option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  color: #111827;
  border-right: 1px solid #d1d5db;
}
.topic-option-text {
  display: flex;
  align-items: center;
  padding: 0.85rem 1rem;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  line-height: 1.4;
  font-weight: 600;
  color: #111827;
  white-space: pre-wrap;
  word-break: keep-all;
}
.option-a { background: #d9ecd2; }
.option-b { background: #f2dfc6; }
.option-c { background: #dcd5eb; }
.option-d { background: #fbe0d9; }
.option-e { background: #d5ecf0; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
}
.result-card {
  border-radius: 14px;
  padding: 0.85rem;
  text-align: center;
  border: 1px solid #c7d2fe;
  background: #f8fafc;
}
.result-title { font-size: 1.05rem; font-weight: 700; }
.result-value { font-size: 1.7rem; font-weight: 800; margin-top: 0.3rem; }
.result-percent { color: var(--muted); font-size: 0.95rem; margin-top: 0.2rem; }

.reason-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
  max-height: 420px;
  overflow: auto;
}
.reason-option-card h3 {
  line-height: 1.35;
}
.reason-item {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem;
}
.reason-meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: #4b5563;
  margin-bottom: 0.35rem;
}
.reason-item p {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.kpi { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.kpi div { flex: 1; min-width: 220px; padding: 0.75rem; border-radius: 12px; text-align: center; background: #f8fafc; border: 1px solid #c7d2fe; }

.log-box {
  min-height: 200px;
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111827;
  color: #e5e7eb;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .container, .mobile { padding: 0.8rem; }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  background: rgba(255, 255, 255, 0.5);
}
.loading-overlay.hidden { display: none; }
.loading-box {
  min-width: 180px;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  border: 1px solid #c7d2fe;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.2);
  text-align: center;
}
.gear {
  display: inline-block;
  font-size: 2rem;
  animation: spin 1s linear infinite;
}
.loading-text {
  margin-top: 0.4rem;
  color: #4338ca;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 0.95rem;
  z-index: 10000;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
