/* 화면별 모양: 홈(목록), 단계형 폼, 문서 상세, 전체 화면 미리보기, 자동완성. 공용 부품은 base.css. */

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px;
  background: var(--c-accent); color: var(--c-accent-contrast);
  font-size: 13px; font-weight: 800;
}

/* ───────── 홈(목록) ───────── */
/* 오늘 카드: 먹색 면 위에 노란 주 단추 하나. 장식 원/그라데이션 없이 면 대비로만 강조함 */
.today-card {
  padding: var(--space-5) var(--space-4) var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--c-hero);
  color: var(--c-hero-text);
}
.today-date { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--c-hero-muted); }
.today-date::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c-accent); flex: none; }
.today-card h2 { font-size: var(--fs-xl); margin: var(--space-1) 0 var(--space-4); letter-spacing: -0.01em; }
.today-card > * { min-width: 0; }
.today-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.today-new { white-space: normal; text-align: center; }
.today-new, .today-new:hover, .today-new:active { background: var(--c-hero-btn); color: var(--c-hero-btn-text); border-color: var(--c-hero-btn); }
.today-new:active { filter: brightness(.96); }
.today-copy {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .08);
  color: inherit;
  text-decoration: none;
}
.today-copy:active { background: rgba(255, 255, 255, .14); }
.today-copy-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.today-copy-text span { font-size: var(--fs-sm); color: var(--c-hero-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 화면 폭이 아니라 본문 폭으로 판정함: PC에서는 왼쪽 메뉴가 폭을 먹어 화면 폭 960px에서도 본문이 700px 안팎뿐이라
   제목 칸이 2px로 눌려 글자가 세로로 쪼개졌음(2026-11-24 통합 검증). */
.home { container-type: inline-size; }
@container (min-width: 900px) {
  /* 넓은 본문: 왼쪽에 날짜와 제목, 오른쪽에 두 단추를 한 줄로 */
  .today-card {
    display: grid; grid-template-columns: minmax(12em, 1fr) auto;
    grid-template-areas: "date act" "title act";
    align-items: center; column-gap: var(--space-5); row-gap: 0;
    padding: var(--space-5) var(--space-6);
  }
  .today-date { grid-area: date; align-self: end; }
  .today-card h2 { grid-area: title; margin-bottom: 0; align-self: start; }
  .today-actions { grid-area: act; grid-template-columns: auto minmax(240px, 320px); align-items: stretch; }
  .today-new { white-space: nowrap; padding-left: var(--space-5); padding-right: var(--space-5); }
}

.list-search { margin-bottom: var(--space-2); }
.search-row { display: flex; gap: var(--space-2); }
.search-field { position: relative; flex: 1; min-width: 0; margin: 0; }
.search-field input.input { padding-left: 46px; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--c-muted); }
.filter-btn { flex: none; }
.period-chips { flex-wrap: wrap; overflow: visible; }
.range-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--space-2); align-items: end; margin-top: var(--space-3); }
.range-row .field { margin: 0; }
.range-row .range-sep { padding-bottom: 14px; color: var(--c-muted); }
.radio-list { display: grid; gap: var(--space-1); }
.radio-row {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--touch);
  padding: 0 var(--space-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}
.radio-row input { width: 24px; height: 24px; accent-color: var(--c-primary); flex: none; margin: 0; }
.radio-row:has(input:checked) { border-color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-text); font-weight: 800; }

.active-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0 0; }
.active-filters .chip .mi { font-size: 1.15em; margin-left: 2px; }

.list-summary { margin: var(--space-4) 0 var(--space-2); color: var(--c-muted); }
.list-summary strong { color: var(--c-text); }

.month-group + .month-group { margin-top: var(--space-5); }
.month-head {
  position: sticky; top: var(--topbar-h); z-index: 5;
  margin: 0 calc(-1 * var(--space-4)) var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--c-bg);
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--c-muted);
}
@media (min-width: 960px) { .month-head { margin: 0 0 var(--space-2); padding-left: 0; padding-right: 0; } }

.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
@media (min-width: 720px) { .doc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); } }
@media (min-width: 1280px) { .doc-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.doc-card {
  display: flex; align-items: center; gap: var(--space-3);
  height: 100%;
  min-height: 88px;
  padding: var(--space-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  color: var(--c-text);
  text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.doc-card:hover { border-color: var(--c-border-strong); }
.doc-card:active { background: var(--c-surface-2); }
.doc-date {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 60px; min-height: 64px;
  border-radius: 12px;
  background: var(--c-surface-2);
  color: var(--c-text);
  line-height: 1.1;
}
.doc-date-ym { font-size: calc(11px * var(--font-scale)); font-weight: 700; color: var(--c-muted); }
.doc-date-d { font-size: calc(26px * var(--font-scale)); font-weight: 800; }
.doc-date-w { font-size: calc(13px * var(--font-scale)); font-weight: 700; color: var(--c-muted); }
.doc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-title { font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); color: var(--c-muted); font-size: var(--fs-sm); font-weight: 600; }
.doc-meta-item { display: inline-flex; align-items: center; gap: var(--space-1); }
.doc-meta .mi { font-size: 1.15em; }
.doc-chevron { color: var(--c-muted); }
.load-more-wrap { margin-top: var(--space-4); }

/* ───────── 단계형 폼 ───────── */
.stepper { position: sticky; top: var(--topbar-h); z-index: 6; margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) var(--space-4); padding: var(--space-2) var(--space-2); background: var(--c-bg); }
@media (min-width: 960px) { .stepper { margin: 0 0 var(--space-4); padding: 0; } }
.stepper ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.stepper button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 100%; min-height: var(--touch);
  padding: 6px 2px 4px;
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--c-muted);
  font-size: calc(13px * var(--font-scale)); font-weight: 700;
  cursor: pointer;
  position: relative;
}
.stepper button::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 0; height: 4px; border-radius: 2px;
  background: var(--c-border);
}
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 14px; line-height: 1;
}
/* 진행 막대는 노랑(지나온 단계와 지금 단계), 지금 단계 번호는 먹색 원 */
.stepper button.is-done { color: var(--c-text); }
.stepper button.is-done::after { background: var(--c-accent); }
.stepper button.is-done .step-no { background: var(--c-surface-3); border-color: transparent; }
.stepper button[aria-current="step"] { color: var(--c-text); }
.stepper button[aria-current="step"]::after { background: var(--c-accent); }
.stepper button[aria-current="step"] .step-no { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-contrast); }
.stepper button.has-error { color: var(--c-danger); }
.stepper button.has-error .step-no { border-color: var(--c-danger); }

fieldset.step {
  margin: 0 0 var(--space-5);
  padding: 0;
  border: 0;
  min-width: 0;
}
.wizard-on fieldset.step { display: none; margin: 0; }
.wizard-on fieldset.step.is-active { display: block; animation: step-in .18s ease-out; }
@keyframes step-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.step-q {
  display: block; float: left; width: 100%;
  padding: 0;
  margin-bottom: var(--space-5);
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.3;
}
.step-q + * { clear: both; }

.last-entry-btn {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%;
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--c-accent-soft);
  color: var(--c-text);
  text-align: left;
  cursor: pointer;
}
.last-entry-btn:active { filter: brightness(.97); }
.last-entry-btn > .mi { color: var(--c-accent-ink); font-size: 32px; }
.last-entry-btn strong { display: block; font-size: var(--fs-base); }

.quick-chips, .recent-chips { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.quick-chips .chip, .recent-chips .chip { min-height: 44px; }
.recent-chips .chip { max-width: 100%; }
.recent-chips .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-label { width: 100%; color: var(--c-muted); font-size: var(--fs-sm); font-weight: 700; }

.total-box {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  font-weight: 700;
}
.total-box .mi { color: var(--c-muted); }
.total-box strong { margin-left: auto; font-size: var(--fs-lg); }
.total-box.is-bad { background: var(--c-warning-soft); }
.total-box.is-bad .mi, .total-box.is-bad strong { color: var(--c-warning); }

/* 확인 단계 요약: 문서 표처럼 줄마다 항목과 값, 누르면 그 단계로 */
.review-list {
  margin: 0 0 var(--space-5);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-lg);
  background: var(--c-surface);
  overflow: hidden;
}
.review-row {
  display: grid; grid-template-columns: 6.5em minmax(0, 1fr) auto; align-items: center;
  width: 100%;
  min-height: var(--touch);
  padding: 0;
  border: 0; border-top: 1px solid var(--c-border);
  background: none; color: inherit; text-align: left;
  cursor: pointer;
}
.review-row:first-child { border-top: 0; }
.review-row:hover { background: var(--c-surface-2); }
.review-row dt, .review-row .rv-label {
  align-self: stretch; display: flex; align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--c-surface-2);
  border-right: 1px solid var(--c-border);
  color: var(--c-muted); font-weight: 700; font-size: var(--fs-sm);
}
.review-row .rv-value { padding: var(--space-2) var(--space-3); font-weight: 700; white-space: pre-line; }
.review-row .rv-value.is-empty { color: var(--c-muted); font-weight: 400; }
.review-row .rv-value.is-missing { color: var(--c-danger); }
.review-row .mi { color: var(--c-muted); padding-right: var(--space-2); }
.private-box { margin-bottom: var(--space-4); }

.geo-field { margin: 0; }
#geo-status.is-ok { color: var(--c-success); font-weight: 700; }
#geo-status.is-bad { color: var(--c-danger); font-weight: 700; }

.wizard-bar .wizard-prev { flex: none; }
.wizard-bar .wizard-next, .wizard-bar .wizard-save { flex: 1; }
.wizard-bar .wizard-next { justify-content: space-between; }
.wizard-on .wizard-bar .wizard-save { display: none; }
.wizard-on.on-review .wizard-bar .wizard-save { display: inline-flex; }
.wizard-on.on-review .wizard-bar .wizard-next { display: none; }
.entry-form.is-saving fieldset { opacity: .6; pointer-events: none; }

/* 자동완성 목록 */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 40;
  margin: 0; padding: var(--space-1) 0;
  list-style: none;
  max-height: min(50vh, 420px);
  overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
}
.ac-item {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
}
.ac-item[aria-selected="true"], .ac-item:hover { background: var(--c-surface-2); }
.ac-item .ac-value { flex: 1; font-weight: 700; }
.ac-item .ac-value mark { background: var(--c-accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.ac-item .ac-count { flex: none; color: var(--c-muted); font-size: var(--fs-sm); }
.ac-head { padding: var(--space-1) var(--space-4) var(--space-2); color: var(--c-muted); font-size: var(--fs-sm); font-weight: 700; }

/* ───────── 문서 상세 ───────── */
.doc-view { display: grid; gap: var(--space-4); }
.doc-hero { padding: 0 var(--space-1); }
.detail-date { color: var(--c-accent-ink); font-weight: 800; }
.detail-title { font-size: var(--fs-xl); margin: var(--space-1) 0 var(--space-2); letter-spacing: -0.01em; }
.detail-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-weight: 600; color: var(--c-muted); }
.detail-facts li { display: inline-flex; align-items: center; gap: var(--space-1); }

.doc-paper { margin: 0 calc(-1 * var(--space-2)); }
.preview-btn {
  position: relative; display: block; width: 100%;
  padding: 0; border: 0; background: none; cursor: zoom-in;
}
.preview-btn img {
  width: 100%; height: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 30px rgba(16, 24, 40, .16);
}
.preview-hint {
  position: absolute; right: var(--space-3); bottom: var(--space-3);
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 17, 22, .8);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
}
.doc-side { display: grid; gap: var(--space-4); align-content: start; }
/* 나만 보는 메모: 경고가 아니라 메모지이므로 노랑 옅은 면 */
.memo-card {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--c-accent-soft);
}
.memo-card h3 { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; font-size: var(--fs-base); margin-bottom: var(--space-2); }
.memo-card h3 .mi { color: var(--c-accent-ink); align-self: center; }
.doc-fields { padding: 0; }
.doc-fields summary {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 60px; padding: 0 var(--space-4);
  font-weight: 800; cursor: pointer; list-style: none;
}
.doc-fields summary::-webkit-details-marker { display: none; }
.doc-fields summary .mi:first-child { color: var(--c-muted); }
.summary-chevron { margin-left: auto; color: var(--c-muted); transition: transform .15s; }
.doc-fields[open] .summary-chevron { transform: rotate(180deg); }
.doc-fields[open] > :not(summary) { margin-left: var(--space-4); margin-right: var(--space-4); }
.doc-fields[open] > :last-child { margin-bottom: var(--space-4); }
.detail-kv { grid-template-columns: 6.2em 1fr; }
.detail-sub { font-size: var(--fs-base); margin: var(--space-4) 0 var(--space-2); }
.work-content { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--c-surface-2); }
.doc-side-actions { display: none; }

@media (min-width: 960px) {
  .doc-view {
    grid-template-columns: minmax(0, 5fr) minmax(320px, 4fr);
    grid-template-areas: "paper hero" "paper side";
    grid-template-rows: auto 1fr;
    align-items: start;
    column-gap: var(--space-6);
  }
  .doc-hero { grid-area: hero; padding: 0; }
  .doc-paper { grid-area: paper; margin: 0; }
  .doc-side { grid-area: side; }
  .doc-side-actions { display: grid; gap: var(--space-2); }
}

.doc-bar .doc-bar-share { flex: 1.4; }
.doc-bar .doc-bar-save { flex: 1; }
.doc-bar .doc-bar-more { flex: none; padding: 0 var(--space-3); }
.doc-bar.no-share .doc-bar-save { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-contrast); }
.doc-bar.no-share .doc-bar-save:hover { background: var(--c-primary-hover); }

.file-rows { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.file-rows form { margin: 0; }
.file-row {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%;
  min-height: 72px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.file-row:active { background: var(--c-surface-2); }
.file-row > .mi:last-child { color: var(--c-muted); }
.file-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; flex: none;
  border-radius: 12px;
  background: var(--c-surface-2);
  font-size: 28px; color: var(--c-text);
}
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.file-text strong { font-size: var(--fs-base); }
.file-text span { color: var(--c-muted); font-size: var(--fs-sm); }
.file-row-danger { border-color: var(--c-danger-soft); }
.file-row-danger .file-icon { background: var(--c-danger-soft); }
.file-row-danger .file-icon, .file-row-danger strong { color: var(--c-danger); }

/* 전체 화면 미리보기 */
dialog.lightbox {
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #0d0f13;
  color: #fff;
  overflow: hidden;
}
dialog.lightbox::backdrop { background: #0d0f13; }
.lightbox-stage {
  position: absolute; inset: 0 0 76px 0;
  overflow: hidden;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-stage img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  background: #fff;
}
.lightbox-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 76px;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: rgba(13, 15, 19, .92);
}
.lightbox-help { font-size: var(--fs-sm); color: #c9ced8; min-width: 0; }
.lightbox-bar .btn { flex: none; white-space: nowrap; }

/* 내려받기 전 서버에 파일이 있는지 묻는 동안(HEAD 확인) 줄을 흐리게 하고 다시 누르지 못하게 함 */
.file-row.is-busy, a.is-busy { opacity: .55; pointer-events: none; cursor: progress; }
