/* 새암 관리 화면 — 브랜드 토큰(brand/tokens.css, 낮 테마) 위에서. 고객 눈높이: 본문 18px, 버튼 48px 이상. */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 112.5%; } /* 18px */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 1rem; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 12px; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

.boot, .noscript { padding: 32px; font-size: 1.2rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 20; }
.muted { color: var(--text-muted); font-size: 0.95rem; }
.lead { color: var(--text-muted); margin: 0 0 16px; }
.hint { color: var(--text-muted); font-size: .95rem; margin: -8px 0 16px; }
.empty { padding: 24px; background: var(--surface); border-radius: var(--radius-md); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.publish { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.btn.danger { color: #9b1c1c; border-color: #e3b4b4; }
.btn.link { border-color: transparent; background: transparent; color: var(--accent); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .95rem; }
.btn.big { min-height: 56px; font-size: 1.1rem; padding: 12px 24px; }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 24px; margin-bottom: 24px; }
.login { width: 100%; max-width: 460px; display: grid; gap: 12px; }
.login-logo { width: 220px; margin-bottom: 4px; }
.otp { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }

/* ---------- 틀 ---------- */
.top { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand img { height: 40px; width: auto; display: block; }
.app-name { font-weight: 700; font-size: 1.1rem; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.me { font-size: .95rem; }
.menu { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.menu a { padding: 14px 18px; font-weight: 700; color: var(--text); text-decoration: none; border-bottom: 4px solid transparent; white-space: nowrap; font-size: 1.05rem; }
.menu a.active { border-bottom-color: var(--accent); color: var(--accent); }
.publish-bar { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 12px 24px; background: var(--surface-2); flex-wrap: wrap; }
.bar-status { font-size: .98rem; }
.bar-status.bad { color: #9b1c1c; font-weight: 600; }
.bar-status.good { color: var(--accent); }
.bar-status.busy { color: var(--accent-2); font-weight: 600; }
.bar-status.warn { color: #6b4a00; font-weight: 600; }
.content { max-width: 1040px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- 목록 ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list-item { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "badge main date" "badge sub date"; gap: 2px 14px; align-items: center;
  padding: 14px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--text); text-decoration: none; }
a.list-item:hover { border-color: var(--accent); }
.list-item.static { grid-template-columns: 1fr auto; grid-template-areas: "main del" "sub del"; }
.li-main { grid-area: main; font-weight: 700; font-size: 1.08rem; }
.li-sub { grid-area: sub; color: var(--text-muted); font-size: .95rem; }
.li-date { grid-area: date; color: var(--text-muted); font-size: .9rem; }
.badge { grid-area: badge; display: inline-block; padding: 4px 10px; border-radius: var(--radius-pill); font-size: .9rem; font-weight: 700; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.badge.published, .badge.b-success { background: #e2f0d6; border-color: #a9cf8d; color: #24520e; }
.badge.draft, .badge.b-queued, .badge.b-skipped { background: #f3f0e2; color: #4a4a3a; }
.badge.b-running { background: #fde9d6; border-color: #f2b984; color: #7a3405; }
.badge.b-failed { background: #fbe1e1; border-color: #e3a5a5; color: #8a1616; }
.build-item { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 14px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); }
.build-item .li-main, .build-item .li-sub { grid-area: auto; }
.build-item .li-sub, .build-error, .build-item details { grid-column: 2; }
.build-error { margin: 4px 0 0; color: #8a1616; }
.build-item .build-warning { grid-column: 2; margin: 4px 0 0; padding-left: 1.2em; color: #6b4a00; }
.build-item pre { white-space: pre-wrap; font-size: .8rem; background: var(--surface); padding: 8px; border-radius: 6px; max-height: 240px; overflow: auto; }

/* ---------- 편집 ---------- */
.editor h1 { margin-bottom: 8px; }
.state { margin: 0 0 12px; color: var(--text-muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; margin-bottom: 16px; }
.field { display: grid; gap: 6px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-weight: 700; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.req { color: var(--accent-2); font-weight: 600; font-size: .9rem; }
.counter { margin-left: auto; font-weight: 400; font-size: .85rem; color: var(--text-muted); }
.counter.over { color: #9b1c1c; font-weight: 700; }
.help { margin: 0; font-size: .92rem; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--text);
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius-sm);
}
input[readonly] { background: var(--surface); color: var(--text-muted); }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
.check.big { font-size: 1.05rem; padding: 12px; background: var(--surface); border-radius: var(--radius-sm); }
.guide { background: var(--surface-2); border-left: 6px solid var(--accent); padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.guide ul { margin: 6px 0 0; padding-left: 1.2em; }
.guide li { margin: 2px 0; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; padding-bottom: 8px; }
.actions .grow { flex: 1; }
.cover-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cover-thumb { width: 160px; height: 110px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.photo-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.photo { margin: 0; width: 150px; }
.photo img { width: 150px; height: 110px; object-fit: cover; border-radius: var(--radius-sm); }
.photo figcaption { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.preview { border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 16px 20px; min-height: 300px; background: #fff; max-width: 75ch; }
.preview img { border-radius: var(--radius-sm); }

/* Toast UI 조정: 글자 크게, 내장 미리보기 탭 숨김(미리보기는 공개본 규칙의 render.js) */
.md-editor .toastui-editor-defaultUI { border: 2px solid var(--line); border-radius: var(--radius-sm); }
.md-editor .toastui-editor-md-tab-container { display: none !important; }
.toastui-editor-tooltip { display: none; } /* HTML 문자열의 style="display:none"이 CSP로 막혀 기본 숨김을 CSS로 */
.md-editor .toastui-editor-contents, .md-editor .ProseMirror, .md-editor .toastui-editor-md-container .toastui-editor { font-size: 17px; line-height: 1.7; }
.md-editor .toastui-editor-defaultUI-toolbar button.saeam-photo { width: auto; padding: 0 12px; background: none; font-weight: 700; font-size: 15px; color: var(--accent); border: 1px solid var(--line); border-radius: 4px; }

/* ---------- 알림·대화상자 ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 600; margin: 8px 0; }
.alert.error { background: #fbe1e1; color: #7a1010; border: 1px solid #e3a5a5; }
.alert.ok { background: #e2f0d6; color: #24520e; border: 1px solid #a9cf8d; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(150%); background: var(--text); color: #fff;
  padding: 14px 20px; border-radius: var(--radius-md); max-width: min(92vw, 640px); font-weight: 600; transition: transform .25s; z-index: 50; }
.toast.show { transform: translateX(-50%) translateY(0); }
.dialog { border: none; border-radius: var(--radius-md); padding: 24px; max-width: min(560px, 94vw); width: 100%; color: var(--text); }
.dialog.wide { max-width: min(860px, 96vw); }
.dialog::backdrop { background: rgba(10, 22, 40, .55); }
.principles { padding-left: 1.2em; color: var(--text-muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.upload-preview { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.upload-preview img { max-height: 160px; width: auto; border-radius: var(--radius-sm); }
.file-input { font: inherit; padding: 8px 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; max-height: 60vh; overflow: auto; }
.media-pick { display: grid; gap: 4px; padding: 6px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: pointer; font: inherit; font-size: .88rem; text-align: left; }
.media-pick:hover, .media-pick:focus-visible { border-color: var(--accent); }
.media-pick img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; }
.media-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.media-card > img { width: 100%; height: 180px; object-fit: cover; display: block; }
.media-meta { padding: 12px; display: grid; gap: 6px; }
.media-meta p { margin: 0; }

/* ---------- 모바일(390px) ---------- */
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 8px; }
  .brand img { height: 32px; }
  .app-name { display: none; }
  .who { gap: 8px; }
  .me { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
  .menu { padding: 0 8px; }
  .menu a { padding: 12px 12px; font-size: 1rem; }
  .publish-bar { padding: 12px 16px; }
  .publish-bar .btn { width: 100%; }
  .content { padding: 16px; }
  .card { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .list-item { grid-template-columns: auto 1fr; grid-template-areas: "badge main" "badge sub" "badge date"; }
  .actions { gap: 8px; }
  .actions .btn { flex: 1 1 45%; }
  .actions .grow { display: none; }
  .md-editor .toastui-editor-defaultUI-toolbar { flex-wrap: wrap; }
}
