/* 황성어버이집 블로그 자동화 — 웹 UI
   사용자가 비개발자이므로: 큰 글씨, 큰 버튼, 한 화면에 한 가지 일. */

:root {
  --ground: #F6F7F4;
  --surface: #FFFFFF;
  --surface-2: #EFF1EC;
  --ink: #1C211D;
  --ink-2: #4A5249;
  --ink-3: #767E73;
  --accent: #3F6B4C;
  --accent-hover: #355C41;
  --accent-soft: #E3EDE5;
  --accent-line: #C3D6C8;
  --warn: #8F5638;
  --warn-soft: #F5E9E2;
  --danger: #A6453C;
  --rule: #DFE3DC;
  --shadow: 0 1px 3px rgba(28, 33, 29, .06);
  --shadow-lg: 0 8px 32px rgba(28, 33, 29, .16);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #131714;
    --surface: #1B201C;
    --surface-2: #232823;
    --ink: #E7EBE5;
    --ink-2: #B4BCB1;
    --ink-3: #8B948A;
    --accent: #85B995;
    --accent-hover: #9BC9A8;
    --accent-soft: #1F2C23;
    --accent-line: #35513F;
    --warn: #C88F6E;
    --warn-soft: #2C221C;
    --danger: #D98B82;
    --rule: #2A302B;
    --shadow: none;
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/* hidden 속성이 항상 이기게 한다.
   브라우저 기본값은 [hidden]{display:none} 인데 특정도가 클래스와 같아서,
   .login{display:grid} 처럼 뒤에 선언된 클래스가 이겨버린다.
   그러면 숨겨야 할 오버레이(.sheet)가 화면을 덮은 채로 남는다. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Pretendard, 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.35; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.error { color: var(--danger); font-size: .92rem; }

/* ── 버튼 ───────────────────────────────────────────────── */

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: .8rem 1.4rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root:not([data-theme="light"]) .btn-primary { color: #10160f; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .btn-primary { color: #fff; }
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: .45rem .9rem; font-size: .9rem; }
.btn-block { width: 100%; }

/* ── 로그인 ─────────────────────────────────────────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}
.login-mark {
  width: 40px; height: 4px;
  background: var(--accent);
  border-radius: 2px;
  margin: 0 auto .5rem;
}
.login-card h1 { font-size: 1.3rem; }
.login-card input {
  font: inherit;
  padding: .85rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--ground);
  color: var(--ink);
  text-align: center;
}
.login-card input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ── 레이아웃 ───────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: .8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.brand-mark { width: 5px; height: 20px; background: var(--accent); border-radius: 3px; }

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.card-head { display: flex; gap: .9rem; align-items: flex-start; }
.card-head h2 { font-size: 1.15rem; }
.card-head p { font-size: .95rem; margin-top: .15rem; }

.step-badge {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: .95rem;
  border: 1px solid var(--accent-line);
}

.empty {
  color: var(--ink-3);
  font-size: .95rem;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 1.1rem;
  text-align: center;
}

.row-actions { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.foot { color: var(--ink-3); font-size: .88rem; text-align: center; padding-top: .5rem; }

/* ── 키워드 목록 ────────────────────────────────────────── */

.kw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }

.kw {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.kw:hover { background: var(--surface-2); }
.kw:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.kw:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.kw input { width: 1.25rem; height: 1.25rem; margin-top: .25rem; accent-color: var(--accent); flex: none; }
.kw-main { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.kw-name { font-weight: 600; }
.kw-meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.kw-reason { color: var(--ink-3); font-size: .88rem; }

.chip {
  font-size: .76rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  white-space: nowrap;
}
.chip-rec { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.chip-easy { color: var(--accent); border-color: var(--accent-line); }
.chip-hard { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }

/* ── 진행 ───────────────────────────────────────────────── */

.card-progress { border-color: var(--accent-line); background: var(--accent-soft); }
.progress-head { display: flex; align-items: center; gap: .9rem; }
.progress-head h2 { font-size: 1.05rem; }
.progress-head > div { flex: 1; min-width: 0; }
.progress-head p { font-size: .92rem; }

.spinner {
  flex: none;
  width: 20px; height: 20px;
  border: 3px solid var(--accent-line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--accent-line); }
}

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.steps li {
  font-size: .84rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  color: var(--ink-3);
  background: var(--surface);
}
.steps li.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.steps li.past { color: var(--accent); }

.log-wrap summary { cursor: pointer; font-size: .9rem; color: var(--ink-2); }
.log {
  margin-top: .6rem;
  max-height: 15rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: .8rem;
  font-size: .84rem;
  line-height: 1.6;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.hint { font-size: .85rem; color: var(--ink-3); }

/* ── 글 목록 ────────────────────────────────────────────── */

.posts { display: flex; flex-direction: column; gap: .7rem; }

.post {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: .9rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  background: var(--surface);
  font: inherit;
  color: inherit;
  transition: border-color .15s, background .15s;
}
.post:hover { background: var(--surface-2); border-color: var(--accent-line); }
.post:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.post-thumb {
  flex: none;
  width: 88px; height: 50px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--rule);
}
.post-main { min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.post-title { font-weight: 600; line-height: 1.45; }
.post-sub { font-size: .85rem; color: var(--ink-3); display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── 상세 시트 ──────────────────────────────────────────── */

.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 24, 21, .5);
  display: grid;
  place-items: end center;
  padding: 2rem 1rem 0;
}
.sheet-panel {
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-lg);
  width: min(46rem, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 { font-size: 1.1rem; }
.sheet-body {
  overflow-y: auto;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.warnbox {
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  padding: .9rem 1.1rem;
  font-size: .92rem;
}
.warnbox b { display: block; margin-bottom: .3rem; }
.warnbox ul { margin: 0; padding-left: 1.1rem; }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field-label { font-size: .82rem; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.field-value {
  background: var(--surface-2);
  border-radius: 6px;
  padding: .7rem .9rem;
  font-size: .95rem;
}

.md {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 1.1rem;
  max-height: 24rem;
  overflow: auto;
  white-space: pre-wrap;
  font-size: .9rem;
  line-height: 1.75;
  font-family: Consolas, 'D2Coding', ui-monospace, monospace;
}

.gallery { display: flex; gap: .7rem; flex-wrap: wrap; }
.gallery figure { margin: 0; display: flex; flex-direction: column; gap: .35rem; width: 150px; }
.gallery img {
  width: 150px; height: 100px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--rule); background: var(--surface-2);
}

/* ── 토스트 ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--ground);
  padding: .7rem 1.3rem;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .card { padding: 1.2rem; }
  .post-thumb { width: 68px; height: 40px; }
}
