:root {
  --green-950: #15392e;
  --green-800: #205743;
  --green-700: #177f5b;
  --green-100: #e8f3ee;
  --green-50: #f3f8f5;
  --gold: #d99a33;
  --red: #b63838;
  --ink: #1f2925;
  --muted: #66736d;
  --line: #dce5e0;
  --surface: #ffffff;
  --page: #f4f7f5;
  --shadow: 0 16px 40px rgba(25, 55, 44, .09);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, "Noto Sans KR", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px clamp(16px, 4vw, 48px);
  color: #fff;
  background: var(--green-950);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .14);
}
.admin-brand { color: #fff; font-size: 19px; font-weight: 900; text-decoration: none; }
.admin-header nav { display: flex; align-items: center; gap: 6px; }
.admin-header nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .78);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.admin-header nav a:hover,
.admin-header nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .12); }

.admin-main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 72px; }
.eyebrow { margin: 0 0 7px; color: var(--green-700); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.2; }
h2 { margin: 0; font-size: 21px; }

.notice, .auth-card, .editor-card, .post-sidebar {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.notice { padding: 18px 20px; margin-bottom: 20px; }
.notice p { margin: 7px 0 0; color: var(--muted); }
.notice--warning { border-color: #edcf91; background: #fff9eb; }

.auth-card { width: min(520px, 100%); margin: 7vh auto 0; padding: clamp(24px, 5vw, 46px); }
.auth-card > p:not(.eyebrow):not(.form-message) { margin: 12px 0 28px; color: var(--muted); }
.auth-card form { display: grid; gap: 10px; }
.auth-card .button { margin-top: 12px; width: 100%; }

label { display: block; margin: 0 0 7px; color: var(--green-950); font-size: 14px; font-weight: 900; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cfdad4;
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(23, 127, 91, .13); }
input[type="file"] { padding: 8px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green-700); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 17px;
  font-weight: 900;
}
.button:disabled { cursor: wait; opacity: .62; }
.button--primary { color: #fff; background: var(--green-700); }
.button--primary:hover { background: #126d4d; }
.button--light { color: var(--green-950); border-color: var(--line); background: #fff; }
.button--light:hover { background: var(--green-50); }
.button--danger { color: var(--red); border-color: #e7bcbc; background: #fff7f7; }
.button--small { min-height: 36px; padding: 0 12px; color: #fff; background: var(--green-700); }

.app-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.account-label { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; gap: 8px; }
.admin-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.post-sidebar { position: sticky; top: 84px; max-height: calc(100vh - 108px); overflow: hidden; }
.sidebar-heading, .editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); }
.sidebar-heading > div { display: flex; align-items: baseline; gap: 9px; }
.sidebar-heading span { color: var(--muted); font-size: 13px; font-weight: 800; }
.post-list { max-height: calc(100vh - 185px); overflow: auto; padding: 9px; }
.post-list-empty { padding: 40px 16px; color: var(--muted); text-align: center; line-height: 1.6; }
.post-item {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px;
  color: inherit;
  background: transparent;
  text-align: left;
}
.post-item:hover { background: var(--green-50); }
.post-item.is-active { border-color: #bcd8cb; background: var(--green-100); }
.post-item strong { display: block; margin: 5px 0 7px; font-size: 15px; line-height: 1.4; }
.post-item-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.post-state { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 7px; color: var(--green-800); background: #deefe7; font-weight: 900; }
.post-state.is-private { color: #765419; background: #f8eac9; }

.editor-card { overflow: hidden; }
.editor-heading .eyebrow { margin-bottom: 4px; }
.draft-label { border-radius: 999px; padding: 6px 10px; color: var(--green-800); background: var(--green-100); font-size: 12px; font-weight: 900; }
#post-form { display: grid; gap: 10px; padding: clamp(20px, 4vw, 34px); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-row--compact { display: flex; flex-wrap: wrap; gap: 20px; padding: 10px 12px; border-radius: 11px; background: var(--green-50); }
.checkbox-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.field-hint { margin: -3px 0 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.field-hint code, .notice code { border-radius: 5px; padding: 2px 5px; background: rgba(21, 57, 46, .07); }
.image-field { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; }
.image-preview-wrap { display: grid; place-items: center; min-height: 170px; overflow: hidden; border-radius: 10px; color: var(--muted); background: #edf2ef; font-size: 13px; }
.image-preview-wrap img { display: block; width: 100%; height: 170px; object-fit: cover; }
.editor-actions { display: flex; align-items: center; gap: 9px; margin-top: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }
.form-message { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: 14px; font-weight: 800; }
.form-message--app { margin: 0 0 12px; }
.form-message.is-success { color: var(--green-700); }
.form-message.is-error { color: var(--red); }
.form-message.is-warning { color: #8a641d; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .post-sidebar { position: static; max-height: none; }
  .post-list { max-height: 360px; }
}

@media (max-width: 640px) {
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-header nav { width: 100%; overflow-x: auto; }
  .admin-header nav a { white-space: nowrap; }
  .admin-main { width: min(100% - 20px, 1440px); padding-top: 22px; }
  .app-heading { align-items: stretch; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .field-row, .image-field { grid-template-columns: 1fr; }
  .image-preview-wrap { min-height: 140px; }
  .editor-actions { align-items: stretch; flex-wrap: wrap; }
  .editor-actions .action-spacer { display: none; }
  .editor-actions .button { flex: 1 1 calc(50% - 9px); }
  #save-button { flex-basis: 100%; order: -1; }
}
