:root {
  --bg: #FAF9F5;
  --surface: #FFFFFF;
  --surface-muted: #F3F4F6;
  --ink: #171717;
  --ink-body: #333333;
  --muted: #5F6672;
  --line: #E5E7EB;
  --accent: #007A75;
  --accent-hover: #00615D;
  --accent-soft: #E8F5F4;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
}

.login-kicker {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.login-title {
  margin: 0 0 10px;
  font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 700;
}

.login-desc {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  padding: 11px 13px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
}

.text-area {
  resize: vertical;
  line-height: 1.55;
}

.form-error {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  margin-top: 16px;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: #D1D5DB;
  color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--ink);
}

.btn-danger-outline {
  background: var(--surface);
  border-color: #FCA5A5;
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-name {
  font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  font-size: 17px;
  font-weight: 700;
}

.brand-sep {
  color: #9CA3AF;
}

.brand-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Workspace */
.workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.draft-rail {
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rail-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.rail-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.rail-hint {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.draft-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draft-item-btn {
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.draft-item-btn:hover {
  border-color: #9CA3AF;
}

.draft-item-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.draft-item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.draft-item-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.draft-item-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.recent-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.recent-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Reader pane */
.reader-pane {
  min-width: 0;
}

.empty-panel,
.draft-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 40px;
}

.empty-panel {
  text-align: center;
  padding: 72px 24px;
}

.empty-panel h2 {
  margin: 0 0 8px;
  font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  font-size: 22px;
}

.empty-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.status-banner {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #99D5D2;
}

.status-banner.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #FCD34D;
}

.article-head {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.article-title {
  margin: 0;
  font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  font-size: 28px;
  line-height: 1.38;
  font-weight: 700;
}

.article-subtitle {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.article-meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.view-switch {
  margin: 20px 0;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--bg);
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.article-body {
  max-width: 680px;
  color: var(--ink-body);
  font-size: 16.5px;
  line-height: 1.8;
}

.article-body h2,
.article-body h3 {
  margin: 30px 0 12px;
  color: var(--ink);
  font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  line-height: 1.4;
}

.article-body h3 {
  font-size: 20px;
}

.article-body p {
  margin: 0 0 16px;
}

.article-body blockquote {
  margin: 18px 0 24px;
  padding: 12px 18px;
  border-left: 3px solid var(--accent);
  background: var(--bg);
  color: var(--ink);
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body pre {
  padding: 14px 18px;
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}

.article-body .question-block {
  margin: 20px 0;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-body .question-block p {
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--ink);
}

.article-body .question-block p:last-child {
  margin-bottom: 0;
}

.article-body mark.check-highlight {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.article-raw {
  margin: 0;
  padding: 18px;
  background: #F8FAFC;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-body);
}

/* Decision box */
.decision-box {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 2px solid var(--ink);
}

.decision-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.decision-note {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.decision-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-confirm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--danger-soft);
  border-radius: 8px;
  font-size: 13px;
  color: var(--danger);
}

.revise-form {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.revise-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.action-feedback {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent);
}

.action-feedback.is-error {
  color: var(--danger);
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .draft-rail {
    position: static;
  }

  .empty-panel,
  .draft-panel {
    padding: 24px 20px;
  }

  .article-title {
    font-size: 23px;
  }
}
