:root {
  --navy-950: #071a31;
  --navy-900: #0b2340;
  --navy-800: #103158;
  --navy-700: #1d4d7b;
  --ink: #172536;
  --muted: #647286;
  --line: #d8dde3;
  --paper: #fffef9;
  --paper-soft: #f5f3ed;
  --wash: #edf2f6;
  --blue: #145f9c;
  --blue-dark: #0c4778;
  --green: #216951;
  --green-bg: #e5f3ec;
  --amber: #8a5a09;
  --amber-bg: #fff2d8;
  --red: #9d3340;
  --red-bg: #fbe9ec;
  --shadow: 0 8px 25px rgba(11, 35, 64, .09);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper-soft); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper-soft);
  font-size: 19px;
  line-height: 1.85;
  min-width: 320px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: var(--blue-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #75bde9; outline-offset: 2px; }

.boot-screen, .login-shell {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 32px;
  text-align: center;
  background: var(--paper-soft);
}

.boot-mark, .eyebrow, .field-label, .section-kicker, .brand-kicker, .record-meta, .tiny, .badge, .job-time {
  letter-spacing: .08em;
  text-transform: uppercase;
}

.boot-mark { color: var(--navy-800); font-size: .78rem; font-weight: 800; }

.login-card {
  width: min(100%, 440px);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 42px 36px;
  text-align: left;
}

.login-card h1, .empty-state h1 { margin: 0 0 8px; font-family: Georgia, "Times New Roman", serif; color: var(--navy-950); font-size: clamp(2rem, 5vw, 2.6rem); line-height: 1.2; }
.login-card p { color: var(--muted); margin: 0 0 24px; font-size: .92rem; line-height: 1.65; }

.app-frame { min-height: 100vh; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 26px 16px 18px;
  color: #eaf3fb;
  background: var(--navy-950);
}
.brand { padding: 0 12px 28px; border-bottom: 1px solid rgba(232, 243, 251, .18); }
.brand a { color: #fff; text-decoration: none; display: inline-block; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: bold; letter-spacing: -.04em; }
.brand-kicker { margin: 6px 0 0; color: #98b7d1; font-size: .67rem; font-weight: 700; }
.sidebar-nav { padding: 22px 0; }
.nav-button {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  color: #c8d8e7;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  font-size: .91rem;
}
.nav-button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-button.is-active { color: #fff; border-left-color: #8dd1f5; background: rgba(91, 178, 224, .17); font-weight: 700; }
.nav-index { color: #8eacc4; font-size: .67rem; font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid rgba(232,243,251,.18); font-size: .75rem; color: #a9bed0; line-height: 1.55; }
.sidebar-foot strong { color: #fff; display: block; font-size: .8rem; }

.main-shell { min-width: 0; }
.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(20px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 249, .94);
}
.crumb { min-width: 0; }
.crumb strong { display: block; font-family: Georgia, "Times New Roman", serif; color: var(--navy-950); font-size: 1.15rem; line-height: 1.2; }
.crumb span { display: block; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #9aacb8; }
.status-dot.good { background: #3cad77; box-shadow: 0 0 0 4px rgba(60,173,119,.13); }
.status-dot.warn { background: #dfa133; box-shadow: 0 0 0 4px rgba(223,161,51,.13); }

.content { padding: clamp(22px, 3vw, 42px) clamp(18px, 4vw, 54px) 80px; }
.panel { max-width: 1400px; margin: 0 auto; }
.hidden { display: none !important; }

button, .button-link {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--navy-800);
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.35;
}
button:hover:not(:disabled) { background: var(--navy-700); }
button.secondary { color: var(--navy-800); border-color: #b9c7d4; background: #fff; }
button.secondary:hover:not(:disabled) { background: var(--wash); }
button.quiet { min-height: 34px; padding: 5px 8px; color: var(--blue-dark); border: 0; background: transparent; text-decoration: underline; font-weight: 600; }
button.danger { color: #8b2938; border-color: #dfb7be; background: #fff; }
button.danger:hover:not(:disabled) { background: var(--red-bg); }
button.pay-action { background: var(--blue); }
button.pay-action:hover:not(:disabled) { background: var(--blue-dark); }

input, select, textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid #bfc9d2;
  border-radius: 2px;
  background: #fff;
  padding: 9px 11px;
  font-size: .9rem;
  line-height: 1.55;
}
textarea { min-height: 118px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--blue); }
input[type="number"] { max-width: 165px; }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; }
.field + .field { margin-top: 17px; }
.form-row .field + .field { margin-top: 0; }
.field-label { display: block; color: #415166; margin-bottom: 5px; font-size: .67rem; font-weight: 800; }
.field-hint { margin: 5px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.55; }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; color: #33445a; font-size: .86rem; line-height: 1.5; }
.checkbox-row input { margin-top: 4px; }

.notice, .error-box, .config-note, .job-card, .info-card { padding: 13px 16px; border-left: 4px solid var(--blue); background: #eaf4fa; color: #294458; font-size: .82rem; line-height: 1.65; }
.notice { margin: 0 0 20px; }
.notice.warn, .config-note.warn { border-left-color: #c9891d; background: var(--amber-bg); color: #6c4707; }
.notice.error, .error-box { border-left-color: var(--red); background: var(--red-bg); color: #762d39; }
.notice.good { border-left-color: var(--green); background: var(--green-bg); color: #285f4c; }
.flash { max-width: 1400px; margin: 0 auto 18px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-kicker { margin: 0 0 5px; color: var(--blue-dark); font-size: .68rem; font-weight: 800; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.section-head h1 { margin: 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 3.5vw, 42px); letter-spacing: -.035em; line-height: 1.17; }
.section-head .description { max-width: 55ch; margin: 5px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.6; }

.dashboard-grid { display: grid; grid-template-columns: minmax(290px, .85fr) minmax(0, 1.7fr); gap: 22px; align-items: start; }
.stack { display: grid; gap: 20px; }
.card { border: 1px solid var(--line); background: var(--paper); box-shadow: 0 3px 12px rgba(8,31,54,.035); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; line-height: 1.35; }
.card-body { padding: 17px; }

.source-list, .record-list, .job-list { margin: 0; padding: 0; list-style: none; }
.source-item { padding: 11px 0; border-bottom: 1px solid #e7e7e2; }
.source-item:last-child, .record-item:last-child, .job-item:last-child { border-bottom: 0; }
.source-name { display: block; color: var(--ink); font-size: .88rem; font-weight: 750; line-height: 1.4; }
.source-meta { display: block; color: var(--muted); margin-top: 2px; font-size: .72rem; line-height: 1.45; }
.source-select { display: flex; gap: 9px; align-items: flex-start; }
.source-select input { margin-top: 4px; }
.source-select .source-name { cursor: pointer; }
.record-item { border-bottom: 1px solid #e3e6e8; }
.record-button { width: 100%; padding: 13px 14px; color: var(--ink); border: 0; background: transparent; text-align: left; }
.record-button:hover { background: var(--wash); }
.record-button.is-selected { border-left: 4px solid var(--blue); background: #edf6fb; padding-left: 10px; }
.record-title { display: block; font-size: .88rem; font-weight: 760; line-height: 1.48; }
.record-meta { display: block; margin-top: 5px; color: var(--muted); font-size: .63rem; line-height: 1.4; }
.badge { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 7px; border-radius: 20px; color: #3b5063; background: #e8edf1; font-size: .6rem; font-weight: 800; line-height: 1.1; }
.badge.draft { color: #815507; background: var(--amber-bg); }
.badge.approved, .badge.done { color: #206248; background: var(--green-bg); }
.badge.active { color: #14547f; background: #dceffa; }
.badge.failed { color: #8c2c39; background: var(--red-bg); }

.article-workbench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.reading-paper { padding: clamp(24px, 4vw, 58px); background: var(--paper); border: 1px solid #e4e0d5; box-shadow: var(--shadow); }
.article-paper-head { max-width: 820px; margin: 0 auto 27px; padding-bottom: 20px; border-bottom: 1px solid #d7d3c7; }
.article-paper-head .article-category { margin: 0 0 9px; color: var(--blue-dark); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.article-paper-head h1 { margin: 0; color: #132237; font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 4.1vw, 42px); font-weight: 700; letter-spacing: -.045em; line-height: 1.23; }
.article-subtitle { margin: 15px 0 0; color: #4a596b; font-size: 1rem; line-height: 1.72; }
.article-byline { margin: 17px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.article-body { max-width: 820px; margin: 0 auto; font-family: Georgia, "Noto Serif KR", "AppleMyungjo", serif; font-size: 19px; line-height: 1.85; }
.article-body p { margin: 0 0 1.35em; }
.article-body h2 { margin: 2.2em 0 .72em; color: var(--navy-950); font-family: Georgia, "Noto Serif KR", serif; font-size: 1.45rem; line-height: 1.35; }
.article-body hr { margin: 2.1em 0; border: 0; border-top: 1px solid #cfcabe; }
.source-caption { max-width: 820px; margin: 26px auto 0; padding-top: 15px; border-top: 1px solid #ddd7c9; color: #617082; font-family: "Noto Sans KR", system-ui, sans-serif; font-size: .77rem; line-height: 1.65; }
.source-caption a { word-break: break-all; }
.article-image { width: 100%; max-width: 820px; max-height: 500px; display: block; object-fit: cover; margin: 0 auto 25px; background: #edf1f3; }
.comparison-toggle { margin-left: auto; }
.comparison-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: #d6d9dc; }
.comparison-pane { min-width: 0; padding: clamp(20px, 3vw, 42px); background: var(--paper); }
.comparison-pane h2 { margin: 0 0 16px; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; }
.raw-text { white-space: pre-wrap; color: #27384a; font-size: .88rem; line-height: 1.85; }
.raw-source { margin-bottom: 16px; padding: 10px 12px; background: var(--wash); color: #3c5468; font-size: .76rem; line-height: 1.6; }
.raw-source a { word-break: break-all; }

.editor-card { border: 1px solid var(--line); background: #fff; }
.editor-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.editor-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; color: var(--navy-900); font-size: 1.25rem; }
.editor-card header p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.editor-content { padding: 21px; }
.editor-content textarea[name="body"] { min-height: 360px; font-family: Georgia, "Noto Serif KR", serif; line-height: 1.85; }
.action-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 20px; }
.action-row .right { margin-left: auto; }
.action-explanation { flex: 1 1 100%; margin: 4px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.5; }

.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.review-check { padding: 13px; border: 1px solid #d9dfe3; background: #fbfcfc; }
.review-check label { display: flex; gap: 9px; align-items: flex-start; color: #283a4d; font-size: .8rem; font-weight: 700; line-height: 1.45; }
.review-check textarea { min-height: 78px; margin-top: 10px; font-family: inherit; font-size: .77rem; }
.review-check.is-invalid { border-color: #d27782; background: #fff9f9; }
.review-status-line { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; color: #4d6175; font-size: .8rem; }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 22px; align-items: start; }
.definition-list { margin: 0; padding: 0; }
.definition-list > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e5e8e9; }
.definition-list dt { color: #53677a; font-size: .76rem; font-weight: 800; }
.definition-list dd { margin: 0; color: #25384a; font-size: .81rem; }
.setting-state { display: inline-flex; gap: 7px; align-items: center; font-weight: 700; }
.config-note { margin-top: 18px; }

.job-item { padding: 12px 0; }
.job-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-action { color: #21384d; font-size: .82rem; font-weight: 760; }
.job-detail { margin: 5px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.job-item.active { padding-left: 10px; border-left: 3px solid var(--blue); }
.empty-copy { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.7; }
.empty-state { max-width: 760px; margin: 8vh auto; padding: 44px 36px; border: 1px solid var(--line); background: var(--paper); text-align: center; }
.small-note { color: var(--muted); font-size: .75rem; line-height: 1.6; }

@media (max-width: 1080px) {
  .dashboard-grid { grid-template-columns: 320px minmax(0, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  body { font-size: 17px; }
  .article-body { font-size: 17px; }
  .app-frame { display: block; }
  .sidebar { position: static; height: auto; overflow: visible; padding: 16px; }
  .brand { display: flex; justify-content: space-between; align-items: center; padding: 0 5px 14px; }
  .brand-kicker { text-align: right; }
  .sidebar-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 12px 0 0; }
  .nav-button { min-height: 68px; display: block; padding: 8px; border-left: 0; border-bottom: 3px solid transparent; font-size: .7rem; text-align: center; }
  .nav-button.is-active { border-left-color: transparent; border-bottom-color: #8dd1f5; }
  .nav-index { display: block; margin-bottom: 3px; }
  .sidebar-foot { display: none; }
  .topbar { min-height: 62px; padding: 10px 16px; }
  .topbar-actions button { min-height: 36px; padding: 6px 9px; font-size: .72rem; }
  .content { padding: 24px 14px 52px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row.three, .review-grid { grid-template-columns: 1fr; }
  .comparison-layout { grid-template-columns: 1fr; }
  .reading-paper { padding: 25px 20px; }
  .editor-content { padding: 16px; }
  .definition-list > div { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 480px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { gap: 3px; }
  .topbar-actions .session-state { display: none; }
  .section-head { display: block; }
  .section-head > button { margin-top: 13px; }
  .card-head { align-items: flex-start; }
  .action-row .right { margin-left: 0; }
  .login-card { padding: 32px 24px; }
}

/* 서버 revision 식별자와 작업 JSON이 지면을 밀어내지 않도록 한다. */
.card, .card-body, .stack, .article-workbench { min-width: 0; }
.badge { max-width: 100%; overflow-wrap: anywhere; word-break: break-all; }
.job-detail { overflow-wrap: anywhere; word-break: break-word; }
.editor-content textarea[name="body"] { font-size: 19px; }
@media(max-width:800px){ .editor-content textarea[name="body"] {font-size:17px;} }
