/* ============================================================
   뷰티 제품 런칭 상황판 — 스타일
   색은 역할 이름으로만 쓴다. 밝게/어둡게 값은 :root 한 곳에서만 바뀐다.
   ============================================================ */

:root {
  color-scheme: light;

  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f2ef;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --line: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.05);

  /* 데이터 강조색 — 진행률 막대와 가격 막대가 함께 쓴다 */
  --accent: #2a78d6;
  --accent-strong: #256abf;
  --accent-track: #cde2fb;
  --accent-context: #86b6ef;
  --accent-ink: #ffffff;

  /* 상태색 — 기호 + 글자와 항상 함께 쓰고, 다른 용도로 돌려쓰지 않는다 */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  /* 카테고리(제형) 식별 점 */
  --cat-ampoule: #eb6834;
  --cat-cleanser: #1baf7a;
  --cat-cream: #eda100;
  --cat-toner: #e87ba4;
  --cat-mask: #4a3aa7;
  --cat-body: #008300;
  --cat-etc: #898781;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  /* 보드를 한 줄에 3개 놓으려면 본문이 이만큼 넓어야 한다 */
  --maxw: 1460px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --line: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);

    --accent: #3987e5;
    --accent-strong: #5598e7;
    --accent-track: #0d366b;
    --accent-context: #184f95;
    --accent-ink: #ffffff;

    --cat-ampoule: #d95926;
    --cat-cleanser: #199e70;
    --cat-cream: #c98500;
    --cat-toner: #d55181;
    --cat-mask: #9085e9;
    --cat-body: #008300;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --line: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);

  --accent: #3987e5;
  --accent-strong: #5598e7;
  --accent-track: #0d366b;
  --accent-context: #184f95;
  --accent-ink: #ffffff;

  --cat-ampoule: #d95926;
  --cat-cleanser: #199e70;
  --cat-cream: #c98500;
  --cat-toner: #d55181;
  --cat-mask: #9085e9;
  --cat-body: #008300;
}

/* ---------- 기본 ---------- */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 650; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); }

.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 상단 바 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px var(--gutter) 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), var(--cat-body));
  flex: none;
}

.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text strong { font-size: 1rem; }
.brand__text span { font-size: 0.75rem; color: var(--muted); }

.topbar__actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  font: inherit;
  font-weight: 600;
  color: var(--text-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab--on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 레이아웃 ---------- */

.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px var(--gutter) 64px;
}

.view__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.view__head h2 { font-size: 1.5rem; margin-top: 4px; }
.view__sub { color: var(--text-2); font-size: 0.9rem; max-width: 60ch; margin-top: 4px; }
.view__actions { display: flex; gap: 6px; }

.sitefoot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter) 40px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- 버튼 ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn--sm { padding: 6px 10px; font-size: 0.8125rem; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn--ghost:hover { color: var(--text); border-color: var(--line); }
.btn--danger { background: var(--critical); color: #fff; }
.btn--danger:hover { filter: brightness(0.93); }

.icon-btn {
  font: inherit;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn--quiet { opacity: 0; }
.task:hover .icon-btn--quiet, .icon-btn--quiet:focus-visible { opacity: 1; }

/* ---------- 도구 모음 ---------- */

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.seg--on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.select, .input {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.input { min-width: 220px; flex: 1 1 220px; max-width: 360px; }

.context-line {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 16px;
}

/* ---------- 카드 ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card__head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card__title { font-size: 1.0625rem; }
.card__block p { font-size: 0.875rem; color: var(--text-2); white-space: pre-wrap; }
.card__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.card__block--memo p { color: var(--muted); font-style: italic; }
.card__foot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid var(--grid);
}
.card__foot .btn { margin-top: 8px; }

.ref-list li { font-size: 0.875rem; color: var(--text-2); padding: 2px 0; }
.ref-list a { text-decoration: none; }
.ref-list a:hover { text-decoration: underline; }
.link-arrow { font-size: 0.75rem; }

/* ---------- 배지 · 칩 ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip--sample { color: var(--muted); }
.chip--late { color: var(--critical); }

.chip--cat::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat-etc);
  flex: none;
}
.chip--cat-ampoule::before { background: var(--cat-ampoule); }
.chip--cat-cleanser::before { background: var(--cat-cleanser); }
.chip--cat-cream::before { background: var(--cat-cream); }
.chip--cat-toner::before { background: var(--cat-toner); }
.chip--cat-mask::before { background: var(--cat-mask); }
.chip--cat-body::before { background: var(--cat-body); }

/* 피부효능 칩 — 카테고리 칩과 생김새로 구분되게 테두리형으로 둔다 */
.chip--eff {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

/* 진행 상태 — 색만으로 읽지 않도록 글자가 항상 함께 간다 */
.chip--status-develop { color: var(--good); }
.chip--status-hold { color: var(--muted); }

.mono {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  font-size: 0.8125rem;
}

.kind {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.kind--ref { background: transparent; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}
.badge__icon { font-size: 0.7rem; line-height: 1; }
.badge--done .badge__icon { color: var(--good); }
.badge--doing .badge__icon { color: var(--warning); }
.badge--todo .badge__icon { color: var(--muted); }

.stars { letter-spacing: 1px; font-size: 0.8125rem; }
.stars .on { color: var(--warning); }
.stars .off { color: var(--grid); }

/* ---------- 진행률 막대 ----------
   채움은 강조색, 트랙은 같은 램프의 옅은 단계. 값은 항상 글자로도 읽힌다. */

.meter { display: flex; align-items: center; gap: 10px; }
.meter__track {
  flex: 1;
  height: 8px;
  background: var(--accent-track);
  border-radius: 4px;
  overflow: hidden;
}
.meter__fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  transition: width 0.18s ease-out;
}
.meter__value {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  min-width: 3.2em;
  text-align: right;
}
.meter--sm .meter__track { height: 6px; }
.meter--lg .meter__track { height: 10px; border-radius: 5px; }

/* 9단계를 한 줄로 압축한 미니 지표 — 칸 사이 2px 는 바탕색이 벌린 간격 */
.strip { display: flex; gap: 2px; height: 26px; align-items: flex-end; }
.strip__cell {
  flex: 1;
  height: 100%;
  background: var(--grid);
  border-radius: 2px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.strip__fill { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; }

/* ---------- 큰 숫자 · 타일 ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 2fr;
  gap: 16px;
  margin-bottom: 24px;
}
.hero__figure {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.hero__label { font-size: 0.8125rem; color: var(--text-2); }
.hero__value { font-size: 3rem; font-weight: 700; line-height: 1.1; margin: 2px 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tile__label { font-size: 0.8125rem; color: var(--text-2); }
.tile__value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }

/* ---------- 제품 카드 ---------- */

.product-card { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.product-card:hover { border-color: var(--line); box-shadow: var(--shadow); }
.product-card__stage { font-size: 0.8125rem; color: var(--text-2); }
.product-card__counts { font-size: 0.8125rem; color: var(--muted); }
.dot { margin: 0 6px; }

/* ---------- 제품 상세 요약 ---------- */

.summary {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 1.4fr;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.summary__label { font-size: 0.8125rem; color: var(--text-2); }
.summary__value { font-size: 2.5rem; font-weight: 700; line-height: 1.1; margin: 2px 0 10px; }
.summary__counts { font-size: 0.8125rem; color: var(--muted); margin-top: 8px; }
.summary__meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
  align-content: start;
}
.summary__meta dt { font-size: 0.75rem; color: var(--muted); }
.summary__meta dd { margin: 2px 0 0; font-size: 0.9375rem; font-weight: 600; }

/* ---------- 단계 ---------- */

/* 8단계는 긴 목록이 아니라 나란히 놓인 블록이다.
   화면 폭에 따라 3열 → 2열 → 1열로 접힌다. */
.stage-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (min-width: 900px) {
  .stage-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .stage-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--grid);
  border-radius: var(--radius);
  overflow: hidden;
  /* 화면 폭이 아니라 '이 블록의 폭'을 기준으로 안쪽 배치를 정하기 위한 것 */
  container-type: inline-size;
}

/* 블록이 좁아지면 메모를 할 일 오른쪽에 두지 않고 아래로 내린다 */
@container (max-width: 420px) {
  .task { grid-template-columns: auto minmax(0, 1fr) auto; }
  .task__grip { grid-column: 1; grid-row: 1; }
  .task__label { grid-column: 2; grid-row: 1; }
  .task .icon-btn { grid-column: 3; grid-row: 1; opacity: 1; }
  .task__memo { grid-column: 1 / -1; grid-row: 2; }
}
.stage--doing { border-left-color: var(--warning); }
.stage--done { border-left-color: var(--good); }

.stage__head {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 14px;
  padding: 16px 18px 14px;
}
.stage__status { justify-self: end; }
.stage__meter { grid-column: 2 / -1; }

.stage__no {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.stage--done .stage__no { background: var(--accent-track); color: var(--text); }

.stage__title { display: flex; flex-direction: column; min-width: 0; }
.stage__name { font-weight: 650; }
.stage__desc { font-size: 0.8125rem; color: var(--muted); }
.stage__status { display: flex; align-items: center; gap: 10px; }
.stage__count {
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage__body { padding: 4px 18px 18px; border-top: 1px solid var(--grid); }

.task-list { margin: 14px 0 10px; }

/* 손잡이 | 할 일 | 메모 | 삭제 — 메모 칸은 항상 펼쳐져 있다 */
.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--grid);
}

/* 순서 바꾸기 손잡이 */
.task__grip {
  font: inherit;
  line-height: 1;
  background: none;
  border: none;
  color: var(--grid);
  padding: 8px 2px;
  margin-top: 2px;
  cursor: grab;
  border-radius: 4px;
}
.task:hover .task__grip { color: var(--muted); }
.task__grip:hover { color: var(--text); background: var(--surface-2); }
.task__grip:active { cursor: grabbing; }

.task.is-dragging { opacity: 0.45; }
.task.is-over { background: var(--surface-2); }
.task:last-child { border-bottom: none; }

.task__label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9375rem;
  padding-top: 6px;
}
.task__label input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin-top: 3px; }
.task--done .task__label span { color: var(--muted); text-decoration: line-through; }

.task__memo {
  font: inherit;
  font-size: 0.875rem;
  width: 100%;
  min-height: 34px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
}
.task__memo::placeholder { color: var(--muted); }
.task__memo:hover { border-color: var(--line); }
.task__memo:focus { background: var(--surface); }
.task .icon-btn { margin-top: 4px; }

.task-add { display: flex; gap: 6px; margin-bottom: 16px; }
.task-add .input { flex: 1; max-width: none; }

.stage__fields { display: grid; grid-template-columns: 1fr 180px; gap: 12px; margin-bottom: 12px; }
.stage__fields .field span { font-size: 0.75rem; color: var(--muted); display: block; margin-bottom: 4px; }
.stage__fields textarea, .stage__fields input {
  font: inherit;
  font-size: 0.875rem;
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  resize: vertical;
}
.stage__actions { display: flex; gap: 6px; }

/* ---------- 패널 · 가격 비교 차트 ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel__head h3 { font-size: 1rem; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--text-2); }
.legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent-context);
  flex: none;
}
.legend__swatch--ours { background: var(--accent); }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
/* 값은 막대와 같은 칸에 두지 않는다 — 100% 막대가 라벨을 화면 밖으로 밀어낸다 */
.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 230px) 1fr auto;
  align-items: center;
  gap: 14px;
}
.bar-row__label {
  font-size: 0.8125rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row__track { display: flex; align-items: center; min-width: 0; }
.bar-row__fill {
  height: 14px;
  background: var(--accent-context);
  border-radius: 0 4px 4px 0;
  flex: none;
}
.bar-row__fill--ours { background: var(--accent); }
.bar-row__value {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- 표 ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 900px; }
.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--grid);
  vertical-align: top;
  color: var(--text-2);
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:hover td { background: var(--surface-2); }
.cell-strong { display: block; font-weight: 650; color: var(--text); }
.cell-sub { display: block; }
.cell-link { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.cell-memo { display: block; max-width: 24ch; color: var(--muted); }
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }

/* ---------- 빈 상태 ---------- */

.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty__title { font-weight: 650; color: var(--text); margin-bottom: 6px; }

/* ---------- 모달 ---------- */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(11, 11, 11, 0.45); }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
}
.modal__head h2 { font-size: 1.125rem; }
.modal__body { padding: 4px 20px 16px; max-height: 65vh; overflow-y: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--grid);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > label {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--text-2);
}
.req { color: var(--critical); }
.field input, .field textarea, .field select {
  font: inherit;
  font-size: 0.875rem;
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  resize: vertical;
}
.field__hint { font-size: 0.75rem; color: var(--muted); }

.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
}
.radio input { accent-color: var(--accent); }

.refs { display: flex; flex-direction: column; gap: 8px; }
.ref-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
.ref-row input {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
}

.confirm-text { padding: 8px 0 12px; color: var(--text-2); }

/* ---------- 이미지 ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* 카드 · 표에 보이는 썸네일 */
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.thumb {
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
  flex: none;
  display: block;
}
.thumb:hover { border-color: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumbs--sm .thumb { width: 52px; height: 52px; }

.thumb--empty {
  cursor: default;
  border-style: dashed;
  width: 52px;
  height: 52px;
}

/* 주소가 죽은 이미지 — 깨진 아이콘 대신 빗금 자리 표시 */
.thumb.is-broken,
.img-thumb.is-broken {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2),
    var(--surface-2) 6px,
    var(--grid) 6px,
    var(--grid) 12px
  );
}
.thumb.is-broken { cursor: default; }

.thumbs__more {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  align-self: center;
}

.cell-thumb { width: 64px; }

/* 크게 보기 */
.lightbox { display: flex; justify-content: center; }
.lightbox__img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-sm);
  display: block;
}

/* 폼 안의 이미지 입력칸 */
.images { display: flex; flex-direction: column; gap: 10px; }
.images__list { display: flex; gap: 8px; flex-wrap: wrap; }
.images__list:empty { display: none; }

.img-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.img-thumb__x {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(11, 11, 11, 0.62);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.img-thumb__x:hover { background: rgba(11, 11, 11, 0.82); }

.images__add { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.images__add .input { min-width: 180px; flex: 1 1 180px; }

/* ---------- 잠금 화면 ---------- */

body.is-locked { overflow: hidden; }

/* 잠금 화면이 덮고 있어도, 설정은 데이터가 올라오기 전엔 열리면 안 된다.
   밝기 버튼은 잠겨 있어도 쓸 수 있게 둔다. */
body.is-locked #settings-btn { display: none; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--page);
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.gate__box {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.gate__box h1 { font-size: 1.125rem; margin-bottom: 4px; }

.gate__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), var(--cat-toner));
  display: block;
  margin: 0 auto 16px;
}

.gate__sub { font-size: 0.875rem; color: var(--text-2); margin-bottom: 18px; }

.gate__input {
  font: inherit;
  width: 100%;
  text-align: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin-bottom: 10px;
}

.gate__submit { width: 100%; justify-content: center; }
.gate__msg { font-size: 0.8125rem; color: var(--text-2); margin-top: 12px; min-height: 1.2em; }

/* ---------- 설정 ---------- */

.settings__title {
  font-size: 0.9375rem;
  margin: 22px 0 6px;
  padding-top: 18px;
  border-top: 1px solid var(--grid);
}
.settings__title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.settings__note { font-size: 0.8125rem; color: var(--text-2); margin-bottom: 10px; }
.settings__warn { font-size: 0.8125rem; color: var(--muted); margin-top: 8px; }

.settings__row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.settings__row .input { flex: 1 1 200px; max-width: none; }

.fetchmeta { gap: 6px; }

/* ---------- 토스트 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  background: var(--text);
  color: var(--page);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  max-width: calc(100vw - 32px);
  text-align: center;
  z-index: 50;
}
.toast--visible { opacity: 1; transform: translate(-50%, 0); }
.toast--warn { background: var(--critical); color: #fff; }

/* ---------- 좁은 화면 ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .summary { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 620px) {
  .view { padding-top: 20px; }
  .card-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .hero__value { font-size: 2.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .ref-row { grid-template-columns: 1fr auto; }
  .ref-row .ref-url { grid-column: 1 / 2; }
  .stage__fields { grid-template-columns: 1fr; }
  /* 좁은 화면에서는 메모를 할 일 아래로 내린다.
     칸을 명시하지 않으면 삭제 버튼이 메모 아래 줄로 밀려난다. */
  .task { grid-template-columns: auto minmax(0, 1fr) auto; }
  .task__grip { grid-column: 1; grid-row: 1; }
  .task__label { grid-column: 2; grid-row: 1; }
  .task .icon-btn { grid-column: 3; grid-row: 1; }
  .task__memo { grid-column: 1 / -1; grid-row: 2; }
  .bar-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .bar-row__label { grid-column: 1 / -1; white-space: normal; }
  .input { max-width: none; }
  .icon-btn--quiet { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
