:root {
  --ink: #152322;
  --muted: #667371;
  --line: #d9e0de;
  --soft: #f2f5f4;
  --paper: #ffffff;
  --canvas: #eef2f1;
  --green: #176b52;
  --green-soft: #e3f1eb;
  --red: #a43d45;
  --red-soft: #f8e8e8;
  --amber: #8a5a13;
  --amber-soft: #f7edda;
  --blue: #315d8a;
  --blue-soft: #e7eef6;
  --shadow: 0 12px 40px rgba(21, 35, 34, 0.08);
  font-family: Inter, Pretendard, "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-width: 320px; font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
.hidden { display: none !important; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(120deg, #e9efed 0 52%, #dfe9e5 52% 100%);
}
.auth-panel {
  width: min(420px, 100%);
  padding: 42px;
  background: var(--paper);
  border: 1px solid rgba(21, 35, 34, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 18px;
}
.brand-mark.small { width: 38px; height: 38px; font-size: 13px; }
.eyebrow { margin: 22px 0 5px; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.auth-panel h1 { margin: 0 0 26px; font-size: 30px; }
.auth-note { color: var(--muted); margin: -14px 0 24px; }
.stack-form { display: grid; gap: 18px; }
.stack-form label, .edit-fields label, .comment-field { display: grid; gap: 7px; color: #3c4b49; font-size: 12px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5d2;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  outline: none;
}
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.12); }
.form-error { min-height: 18px; margin: -4px 0 0; color: var(--red); font-size: 12px; }

.button { min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 5px; font-weight: 750; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: #105a44; }
.button.secondary { border-color: var(--line); background: white; color: var(--ink); }
.button.withdraw { margin-top: 8px; border-color: #d7b2b5; background: white; color: var(--red); }
.button.withdraw:hover { background: var(--red-soft); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.wide { width: 100%; }
.text-button { padding: 3px; border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 750; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: white; font-size: 19px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 330px minmax(460px, 1fr) 328px;
  grid-template-rows: 64px calc(100vh - 64px);
  grid-template-areas: "top top top top" "filter list detail review";
  overflow: hidden;
}
.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: 330px minmax(260px, 520px) 1fr;
  align-items: center;
  gap: 28px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: white;
  z-index: 5;
}
.brand-lockup, .account-box { display: flex; align-items: center; gap: 11px; }
.brand-lockup div:last-child, .account-box div { display: grid; gap: 2px; }
.brand-lockup span, .account-box span { color: var(--muted); font-size: 11px; }
.search-box { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }
.search-box input { height: auto; padding: 0; border: 0; background: transparent; box-shadow: none; }
.account-box { justify-self: end; }
.account-box div { text-align: right; }

.filters-panel, .list-panel, .question-panel, .review-panel { min-height: 0; overflow-y: auto; }
.filters-panel { grid-area: filter; padding: 22px 18px; border-right: 1px solid var(--line); background: #f7f9f8; }
.list-panel { grid-area: list; border-right: 1px solid var(--line); background: white; }
.question-panel { grid-area: detail; background: white; }
.review-panel { grid-area: review; padding: 22px 20px 36px; border-left: 1px solid var(--line); background: #f7f9f8; }
.panel-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-heading h2, .section-heading h2, .content-section h2, .answer-section h2, .review-log h2 { margin: 0; font-size: 13px; }
.select-field { display: grid; gap: 7px; margin-top: 18px; color: var(--muted); font-size: 11px; font-weight: 750; }
.filter-section { margin-top: 25px; }
.field-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 750; }
.state-filters { display: grid; gap: 5px; }
.state-filter { display: flex; justify-content: space-between; padding: 9px 10px; border: 0; border-radius: 5px; background: transparent; color: #44514f; text-align: left; }
.state-filter:hover, .state-filter.active { background: #e3ebe8; color: var(--green); font-weight: 750; }
.state-filter span:last-child { min-width: 26px; text-align: right; color: var(--muted); }
.mine-filter { display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px; margin-top: 16px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: white; color: #44514f; font-size: 11px; font-weight: 750; }
.mine-filter input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.mine-filter strong { color: var(--green); }
.progress-block { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; }
.progress-track { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 4px; background: #dce4e1; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); transition: width 180ms ease; }
.progress-block p { color: var(--muted); font-size: 11px; }

.list-heading { position: sticky; top: 0; z-index: 2; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.96); }
.list-heading span { color: var(--muted); font-size: 12px; }
.question-list { min-height: 140px; }
.question-item { width: 100%; display: grid; gap: 8px; padding: 15px 16px; border: 0; border-bottom: 1px solid #e8edeb; background: white; color: inherit; text-align: left; }
.question-item:hover { background: #f6f9f8; }
.question-item.active { background: #e8f1ee; box-shadow: inset 3px 0 var(--green); }
.item-top, .item-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-top strong { font-size: 11px; color: var(--green); }
.item-question { margin: 0; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.55; font-size: 13px; }
.item-meta { color: var(--muted); font-size: 10px; }
.mini-state { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #aab5b2; }
.mini-state.approved, .mini-state.edited_approved { background: var(--green); }
.mini-state.rejected { background: var(--red); }
.mini-state.on_hold { background: var(--blue); }
.mini-state.conflict { background: var(--amber); }
#load-more { width: calc(100% - 28px); margin: 14px; }

.empty-state { min-height: 100%; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.empty-state h2 { font-size: 15px; font-weight: 600; }
.empty-symbol { width: 50px; height: 50px; display: grid; place-items: center; border: 1px solid #cbd5d2; border-radius: 50%; font-size: 22px; }
.question-detail { max-width: 860px; margin: 0 auto; padding: 32px clamp(28px, 4vw, 60px) 70px; }
.question-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.question-gid { margin: 0 0 9px; color: var(--green); font-size: 12px; font-weight: 800; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 4px 7px; border-radius: 4px; background: var(--soft); color: #53605e; font-size: 10px; font-weight: 700; }
.status-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 4px; background: #e9edec; color: #53605e; font-size: 11px; font-weight: 800; }
.status-badge.approved, .status-badge.edited_approved { background: var(--green-soft); color: var(--green); }
.status-badge.rejected { background: var(--red-soft); color: var(--red); }
.status-badge.on_hold { background: var(--blue-soft); color: var(--blue); }
.status-badge.conflict { background: var(--amber-soft); color: var(--amber); }
.content-section { padding: 28px 0 25px; }
.question-text { margin: 12px 0 22px; white-space: pre-wrap; font-size: 16px; line-height: 1.85; font-weight: 600; }
.option-list { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; counter-reset: option; }
.option-list li { display: grid; grid-template-columns: 28px 1fr; align-items: start; gap: 10px; padding: 11px 12px; border: 1px solid #e0e6e4; border-radius: 5px; line-height: 1.6; }
.option-letter { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: #52605e; font-size: 11px; font-weight: 800; }
.option-list li.correct { border-color: #9bc3b5; background: #f0f8f5; }
.option-list li.correct .option-letter { background: var(--green); color: white; }
.answer-section { display: grid; grid-template-columns: 86px 1fr; gap: 22px; padding: 23px; border-left: 3px solid var(--green); background: #f2f7f5; }
.answer-key { display: grid; align-content: start; gap: 6px; color: var(--muted); font-size: 11px; }
.answer-key strong { color: var(--green); font-size: 27px; }
.rationale { margin: 10px 0 0; white-space: pre-wrap; line-height: 1.75; }
.source-details { margin-top: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.source-details summary { padding: 15px 0; cursor: pointer; font-weight: 750; }
.source-details dl { display: grid; gap: 11px; margin: 0 0 18px; }
.source-details dl div { display: grid; grid-template-columns: 74px 1fr; gap: 12px; }
.source-details dt { color: var(--muted); font-size: 11px; font-weight: 750; }
.source-details dd { margin: 0; line-height: 1.55; }
.excluded-list { display: grid; gap: 6px; margin-bottom: 18px; }
.excluded-item { padding: 9px 10px; border-radius: 4px; background: var(--soft); line-height: 1.5; font-size: 12px; }
.excluded-item strong { color: var(--red); }
.history-section { margin-top: 30px; }
.history-list { display: grid; gap: 10px; margin-top: 12px; }
.history-card { padding: 12px; border: 1px solid var(--line); border-radius: 5px; }
.history-card header { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.history-card details { margin-top: 9px; }
.diff-grid { display: grid; gap: 5px; margin-top: 8px; }
.diff-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; padding: 7px; background: var(--soft); font-size: 11px; white-space: pre-wrap; }
.restore-actions { display: flex; gap: 6px; margin-top: 9px; }

.review-empty { min-height: 70vh; display: grid; place-content: center; color: var(--muted); text-align: center; line-height: 1.6; }
.review-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 17px; }
.review-heading .eyebrow { margin: 0 0 4px; }
.review-heading h2 { margin: 0; font-size: 20px; }
.review-heading > span { color: var(--muted); font-size: 10px; }
.conflict-banner { display: grid; gap: 3px; margin-bottom: 13px; padding: 10px; border: 1px solid #dfc08c; border-radius: 5px; background: var(--amber-soft); color: var(--amber); font-size: 11px; }
.decision-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.decision-button { min-height: 58px; display: grid; place-items: center; gap: 2px; padding: 7px 3px; border: 1px solid var(--line); border-radius: 5px; background: white; color: #465350; font-size: 11px; font-weight: 800; }
.decision-button span { font-size: 17px; }
.decision-button.approve.active { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.decision-button.reject.active { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.decision-button.edit.active { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.decision-button.hold.active { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.review-fields, .edit-fields { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.reason-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.reason-option { min-width: 0; display: flex; align-items: center; gap: 7px; font-size: 11px; line-height: 1.35; }
.reason-option input { width: 15px; height: 15px; flex: 0 0 15px; margin: 0; accent-color: var(--red); }
.edit-fields { display: grid; gap: 13px; }
.edit-options { display: grid; gap: 8px; }
.edit-option { display: grid; grid-template-columns: 22px 1fr; align-items: start; gap: 6px; }
.edit-option span { padding-top: 10px; color: var(--muted); font-size: 11px; font-weight: 800; }
.comment-field { margin-top: 18px; }
.draft-status { min-height: 16px; margin: 8px 0 0; color: var(--green); font-size: 10px; text-align: right; }
.review-actions { display: grid; grid-template-columns: 0.8fr 1.4fr; gap: 7px; }
.review-actions .button { width: 100%; }
.review-log { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.review-log h2 { margin-bottom: 11px; }
.review-record { padding: 10px 0; border-bottom: 1px solid var(--line); }
.review-record.stale { opacity: 0.58; }
.review-record header { display: flex; justify-content: space-between; gap: 7px; font-size: 11px; }
.review-record p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.review-record .record-decision { font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translateX(-50%); padding: 11px 16px; border-radius: 5px; background: #172624; color: white; box-shadow: var(--shadow); }

@media (max-width: 1450px) {
  .app-shell { grid-template-columns: 195px 300px minmax(420px, 1fr) 300px; }
  .question-detail { padding-left: 28px; padding-right: 28px; }
}
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 190px 290px minmax(400px, 1fr); grid-template-areas: "top top top" "filter list detail"; }
  .review-panel { position: fixed; top: 64px; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 8; box-shadow: -12px 0 32px rgba(21,35,34,.13); }
  .question-detail { padding-right: 380px; max-width: 1180px; }
}
@media (max-width: 900px) {
  .app-shell { display: block; min-height: 100vh; overflow: auto; }
  .topbar { position: sticky; top: 0; grid-template-columns: 1fr auto; gap: 10px; height: auto; min-height: 64px; padding: 10px 14px; }
  .search-box { grid-column: 1 / -1; grid-row: 2; }
  .filters-panel { overflow: visible; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .filters-panel .panel-heading, .filters-panel .select-field, .filters-panel .progress-block, .filters-panel .mine-filter { display: none; }
  .filter-section { margin: 0; }
  .state-filters { display: flex; overflow-x: auto; }
  .state-filter { flex: 0 0 auto; }
  .list-panel { max-height: 310px; overflow-y: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .question-panel { overflow: visible; }
  .question-detail { padding: 24px 18px 38px; }
  .review-panel { position: static; width: 100%; height: auto; padding: 20px 17px 38px; border-top: 1px solid var(--line); border-left: 0; box-shadow: none; overflow: visible; }
  .review-empty { min-height: 80px; }
}
@media (max-width: 520px) {
  .auth-panel { padding: 28px 22px; }
  .brand-lockup span, .account-box span { display: none; }
  .brand-lockup strong { font-size: 12px; }
  .account-box strong { font-size: 11px; }
  .answer-section { grid-template-columns: 55px 1fr; padding: 17px; }
  .question-header { display: grid; }
  .reason-list { grid-template-columns: 1fr; }
}
