:root {
  --bg: #f3f4f6; --card: #ffffff; --text: #16191d; --muted: #5f6873; --line: #d5d9de; --soft: #eef0f2;
  --accent: #1f3a5f; --accent-text: #ffffff;
  --ok: #1d6b3f; --ok-bg: #e7f3ec; --warn: #8a5a00; --warn-bg: #fbf1dc;
  --bad: #a32b2b; --bad-bg: #fbeaea; --info: #1f3a5f; --info-bg: #e8edf4;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header */
header.top { background: var(--card); border-bottom: 1px solid var(--line); }
header.top .bar { display: flex; align-items: center; gap: 14px; min-height: 56px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.site-pick { display: flex; align-items: center; gap: 8px; }
.site-pick select { min-width: 210px; }
nav.main { display: flex; border-top: 1px solid var(--line); }
nav.main a { flex: 1; text-align: center; padding: 10px 6px; color: var(--muted); text-decoration: none; font-weight: 600;
  border-right: 1px solid var(--line); border-bottom: 3px solid transparent; }
nav.main a:first-child { border-left: 1px solid var(--line); }
nav.main a.on { color: var(--text); border-bottom-color: var(--accent); background: var(--soft); }
nav.main .n { font-weight: 400; color: var(--muted); }
.spacer { flex: 1; }
main { padding: 20px 0 60px; }

/* Boxes */
.box { background: var(--card); border: 1px solid var(--line); margin-bottom: 16px; }
.box > .hd { padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--soft); font-weight: 700;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.box > .hd .step { display: inline-block; min-width: 22px; text-align: center; border: 1px solid var(--text); font-size: 12px; }
.box > .hd .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.box > .bd { padding: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Forms */
label.f { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 0;
  padding: 9px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
textarea.code { font: 13px/1.55 ui-monospace, "Noto Sans Mono CJK KR", monospace; min-height: 260px; }
textarea.body { min-height: 520px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 9px 16px; border: 1px solid var(--text); background: #fff; color: var(--text); cursor: pointer;
  text-decoration: none; border-radius: 0; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 13px 34px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; }

/* Check lists */
.checks { border: 1px solid var(--line); max-height: 230px; overflow-y: auto; padding: 4px 0; background: #fff; }
.checks label { display: flex; gap: 8px; align-items: center; padding: 5px 10px; cursor: pointer; }
.checks label:hover { background: var(--soft); }
.checks .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
.checks .empty { padding: 8px 10px; color: var(--muted); }
.checks input { width: 16px; height: 16px; flex: none; }

/* Images */

/* Messages and status */
.flash { padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.flash.info { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.flash.error { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.note { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 10px 12px; margin-bottom: 12px; }
.badge { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.review { color: var(--warn); border-color: var(--warn); }
.badge.queued { color: var(--info); border-color: var(--info); }
.badge.published { color: var(--ok); border-color: var(--ok); }
.badge.failed, .badge.rejected { color: var(--bad); border-color: var(--bad); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Job */
.job { border: 1px solid var(--line); background: var(--card); margin-bottom: 16px; }
.job .head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; font-weight: 600; flex-wrap: wrap; }
.job pre { margin: 0; border-top: 1px solid var(--line); background: #15191e; color: #dfe3e8; padding: 12px 14px;
  max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.5 ui-monospace, "Noto Sans Mono CJK KR", monospace; }
.dot { width: 10px; height: 10px; background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Lists */
.tabs { display: flex; border: 1px solid var(--line); border-bottom: 0; background: var(--card); flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-right: 1px solid var(--line);
  border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); background: var(--soft); }
.list .item { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item .main { flex: 1; min-width: 0; }
.list .item .t { font-weight: 700; color: var(--text); text-decoration: none; display: block; }
.list .item .t:hover { text-decoration: underline; }
.list .item .ex { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .meta { color: var(--muted); font-size: 12px; }
.list .item .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty-box { padding: 36px 14px; text-align: center; color: var(--muted); }

/* Article page */
.actbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; position: sticky; top: 0; z-index: 5; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.layout.side-left { grid-template-columns: 260px minmax(0, 1fr); }
.post { font-size: 16px; line-height: 1.85; }
.post h2 { font-size: 19px; margin: 26px 0 8px; }
.post h3 { font-size: 17px; margin: 20px 0 6px; }
.post img.cover { width: 100%; display: block; border: 1px solid var(--line); margin-bottom: 14px; }

/* Login */
.login { max-width: 380px; margin: 12vh auto 0; }

@media (max-width: 860px) {
  .layout, .layout.side-left, .grid2 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  textarea.body { min-height: 380px; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  header.top .bar { gap: 8px; }
  .site-pick { width: 100%; order: 3; }
  .site-pick select { min-width: 0; flex: 1; }
  nav.main a { padding: 9px 2px; font-size: 13px; }
  .list .item { flex-direction: column; align-items: stretch; gap: 8px; }
  .list .item .acts { justify-content: flex-start; }
  .list .item .ex { white-space: normal; }
  .actbar .btn { flex: 1 1 auto; }
  .btn.big { width: 100%; }
  .tabs a { flex: 1 1 auto; text-align: center; padding: 9px 8px; }
  .box > .bd { padding: 12px; }
}

/* search above categories and tags */
.term-filter { margin-bottom: 6px; }
/* cover image choices */
.radio.block { display: block; margin: 0 0 6px; font-weight: 400; }
.sub-field { margin: 0 0 10px 26px; }
.sub-field select, .sub-field input[type=file] { max-width: 100%; }
/* publish time on the review list */
.sched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sched input[type=datetime-local] { width: auto; min-width: 0; }
@media (max-width: 560px) {
  .sched { width: 100%; }
  .sched input[type=datetime-local], .sched .btn { flex: 1 1 100%; }
}

/* the hidden attribute must win over display rules (search filter, panels) */
[hidden] { display: none !important; }

/* Images page: searchable list of names */
.img-filter { margin-bottom: 8px; }
.img-list { border: 1px solid var(--line); max-height: 520px; overflow-y: auto; background: #fff; }
.img-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.img-row:last-of-type { border-bottom: 0; }
.img-row .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.img-list .empty { padding: 10px; color: var(--muted); }

/* Config page: storage meter */
.meter { height: 14px; border: 1px solid var(--line); background: var(--soft); }
.meter span { display: block; height: 100%; background: var(--info); }
.meter span.low { background: var(--bad); }
.storage-low a { color: inherit; text-decoration: underline; }

/* Phones: side margins, larger touch targets, no zoom on focus */
.wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
@media (max-width: 560px) {
  header.top .bar { gap: 10px 8px; padding-top: 10px; padding-bottom: 10px; min-height: 0; }
  .brand { font-size: 18px; }
  .site-pick { flex-direction: column; align-items: stretch; gap: 2px; }
  .site-pick label { font-size: 12px; }
  nav.main a { padding: 13px 2px 11px; font-size: 13px; line-height: 1.25; white-space: nowrap; }
  nav.main .n { font-size: 12px; }
  main { padding-top: 16px; }
  h1 { font-size: 18px; margin-bottom: 12px; }
  /* 16px text stops phones from zooming in when a field is tapped */
  input[type=text], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
  input[type=password], input[type=search], select, textarea { font-size: 16px; padding: 10px; }
  input[type=file] { max-width: 100%; font-size: 14px; }
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; }
  .checks { max-height: 300px; }
  .checks label { padding: 9px 10px; }
  .checks input, .radio input, label input[type=checkbox], label input[type=radio] { width: 20px; height: 20px; flex: none; }
  .radio { margin-right: 14px; min-height: 36px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: 1 0 auto; white-space: nowrap; padding: 11px 14px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { font-size: 12px; margin-top: 8px; }
  .kv dt:first-child { margin-top: 0; }
  .img-row { padding: 8px 10px; }
  .flash { padding: 10px 12px; }
  .list .item .acts { flex-direction: column; align-items: stretch; }
  .list .item .acts > *, .list .item .acts form { width: 100%; }
  .list .item .acts .btn { width: 100%; }
  .list .item form.sched { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  .sched input[type=datetime-local] { width: 100%; }
  .job .head { padding: 10px 12px; }
}
