/* ─────────────────────────────────────────────────────────────
   로드맵 독서실 학습 관리 — 공통 스타일
   빌드 과정이 없으므로 이 한 파일에 토큰 + 레이아웃 + 컴포넌트를 둔다.
   클래스 명명: [page]-[section]--[role]

   시각 언어 원칙 (플렉스 계열 실무용 SaaS)
   1) 그림자를 거의 쓰지 않는다. 카드는 흰 면 + 1px 헤어라인으로 구분한다.
      그림자는 진짜로 떠야 하는 것(모달·토스트)에만.
   2) 색 역할을 둘로 가른다.
      초록(--brand) = 주요 액션 · 완료 · 성공.
      파랑(--sel)   = 선택 · 활성 상태(필터 칩, 정보 배너).
      그 외 UI 는 전부 무채색이고, 위계는 굵기와 회색 단계로 만든다.
   3) 모서리를 크게 굴리지 않는다(10 / 8 / 6px).
      알약(999px)은 아바타 · 카운트 배지 · 필터 칩 · 진행 바에만.
   4) 채움형 입력/보조 버튼 — 회색 면 + 무테두리가 기본이고, 테두리는 예외다.
   ───────────────────────────────────────────────────────────── */

:root {
  /* 액센트 — 초록. 주요 액션·완료·성공에만 쓴다. */
  --brand:        #16b364;
  --brand-strong: #0e9553;
  --brand-ink:    #067a48;   /* 밝은 면 위의 초록 글자 (--brand 는 글자로 쓰기엔 옅다) */
  --brand-weak:   #e8f6ee;   /* 선택된 목록 행 등 연한 초록 틴트 면 */

  /* 선택·활성 — 파랑. 초록과 경쟁하지 않게 분리한다. */
  --sel:      #2e6be6;
  --sel-weak: #eaf1fd;
  --sel-ink:  #1d55c4;

  --bg:         #f1f2f4;
  --surface:    #ffffff;
  --surface-2:  #f2f3f5;   /* 채움형 입력 · 보조 버튼 · 표 머리 */
  --surface-3:  #e8eaec;   /* 그 위의 hover */
  --line:       #e5e6e9;
  --line-soft:  #f0f1f2;   /* 목록 행 구분선 */
  --line-strong:#d4d6da;   /* 체크박스 테두리처럼 보여야 하는 선 */

  --text:   #1a1b1e;
  --text-2: #4f5155;
  --text-3: #65686d;

  --ok:   #16b364;  --ok-weak:   #e8f6ee;  --ok-ink:   #067a48;
  --warn: #e0983a;  --warn-weak: #fbf2e3;  --warn-ink: #925a10;
  --dang: #d92d20;  --dang-weak: #fdeceb;  --dang-ink: #b42318;
  --info: #2e6be6;  --info-weak: #eaf1fd;  --info-ink: #1d55c4;
  --dang-strong: #b42318;

  --radius:      10px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --radius-pill: 999px;

  --shadow:     0 1px 2px rgba(18, 20, 24, .06);
  --shadow-pop: 0 12px 32px rgba(18, 20, 24, .16);

  --gutter:    20px;
  --container: 1120px;

  /*
   * 굵기는 400 / 600 / 700 / 800 네 가지만 쓴다.
   * dynamic-subset 은 (굵기 × 유니코드 범위) 단위로 파일을 받아서, 굵기를 하나 늘릴 때마다
   * 새 글자가 나올 때 요청이 그만큼 늘어난다(실측: 5굵기 254건 → 4굵기 200건 안팎).
   * 500 은 600 과 육안 차이가 거의 없어 뺐다. 새 스타일에서도 500 을 쓰지 않는다.
   */
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Malgun Gothic", system-ui, sans-serif;
}

/*
 * 라이트 전용이다. 레퍼런스(flex)에 다크 테마가 없어서,
 * prefers-color-scheme 로 갈라두면 사용자 OS 설정에 따라 참고 디자인과 전혀 다른 화면이 나온다.
 * 다크가 필요해지면 :root 아래에 별도 테마 블록을 두고 토글로 붙인다(미디어쿼리 자동 전환은 쓰지 않는다).
 */
:root { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -.005em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ── 스크롤바 ─────────────────────────────────────── */
/*
 * OS 기본 스크롤바는 굵고 회색이라 톤이 안 맞는다.
 * 표준 속성(scrollbar-*)과 WebKit 의사요소를 함께 준다.
 *   - 페이지 전체(html/body)는 건드리지 않는다. macOS 는 오버레이라 이미 얇고,
 *     전역으로 바꾸면 사용자의 OS 설정을 덮게 된다.
 *   - 앱 안에서 스크롤되는 영역에만 적용한다.
 */
.sc--list,
.table-wrap,
dialog.modal,
textarea.field--control,
.textarea,
[data-scroll] {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sc--list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
dialog.modal::-webkit-scrollbar,
textarea.field--control::-webkit-scrollbar,
.textarea::-webkit-scrollbar,
[data-scroll]::-webkit-scrollbar { width: 10px; height: 10px; }

.sc--list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
dialog.modal::-webkit-scrollbar-track,
textarea.field--control::-webkit-scrollbar-track,
.textarea::-webkit-scrollbar-track,
[data-scroll]::-webkit-scrollbar-track { background: transparent; }

.sc--list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
dialog.modal::-webkit-scrollbar-thumb,
textarea.field--control::-webkit-scrollbar-thumb,
.textarea::-webkit-scrollbar-thumb,
[data-scroll]::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  /* 투명 테두리로 여백을 만들어 얇아 보이게 한다 */
  border: 3px solid transparent;
  background-clip: content-box;
}
.sc--list::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
dialog.modal::-webkit-scrollbar-thumb:hover,
textarea.field--control::-webkit-scrollbar-thumb:hover,
.textarea::-webkit-scrollbar-thumb:hover,
[data-scroll]::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── 헤더 ─────────────────────────────────────────── */

.global-header {
  position: sticky;
  top: 0;
  z-index: 80;
  /*
   * 불투명 배경을 쓴다. 예전에는 반투명 + backdrop-filter 였는데,
   * backdrop-filter 는 그 뒤 영역을 매 프레임 다시 합성해서 상호작용이 눌린다
   * (헤더는 sticky 라 항상 살아 있고, 화면 폭 전체가 대상이다).
   * 레퍼런스의 헤더도 반투명이 아니라 그냥 흰 면이다.
   */
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.global-header--inner {
  width: min(var(--container), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.global-header--logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.global-header--logo img {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  flex-shrink: 0;
}

.global-header--nav {
  display: flex; gap: 2px; margin-left: 8px;
  overflow-x: auto;
  /* min-width:0 이 없으면 flex 자식이 안 줄어들어 오른쪽 버튼들을 밀어낸다 */
  min-width: 0;
  scrollbar-width: none;
}
.global-header--nav::-webkit-scrollbar { display: none; }

/* 현재 위치는 색이 아니라 굵기와 회색 단계로 표시한다(액센트 절약) */
.global-header--link {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.global-header--link:hover { background: var(--surface-2); color: var(--text-2); }
.global-header--link.is-active { background: var(--surface-2); color: var(--text); font-weight: 700; }

.global-header--right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.global-header--bell {
  position: relative;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--text-3);
}
.global-header--bell:hover { background: var(--surface-2); color: var(--text-2); }
.global-header--bell[data-count]:not([data-count="0"])::after {
  content: attr(data-count);
  position: absolute; top: 0; right: -1px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--dang); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  display: grid; place-items: center;
}

.global-header--user {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
}
.global-header--user:hover { background: var(--surface-3); color: var(--text); }
.global-header--avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}

/* ── 레이아웃 ─────────────────────────────────────── */

main { flex: 1 0 auto; }

.page {
  width: min(var(--container), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
  padding: 26px 0 60px;
}

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head--title { font-size: 26px; font-weight: 800; letter-spacing: -.035em; line-height: 1.25; }
.page-head--sub { color: var(--text-3); font-size: 13px; }
/*
 * 액션 줄은 한 줄에 여러 컨트롤이 서는데, 원래 높이가 30 / 38 / 44px 로 제각각이라
 * 따로 노는 느낌이 났다. 가장 큰 값(44px)에 맞춰 **올려서** 통일한다(아무것도 줄이지 않는다).
 * 이전/다음 같은 작은 버튼은 .page-head--group 으로 묶어 하나의 컨트롤처럼 보이게 한다.
 */
.page-head--actions {
  --control-h: 44px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.page-head--actions > .btn,
.page-head--actions > .page-head--group,
.page-head--actions > .date-control--wrap > .date-control { height: var(--control-h); }
.page-head--actions > .btn { padding-inline: 16px; font-size: 14px; }

/* 화살표·라벨을 한 덩어리로 묶는 껍데기 */
.page-head--group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.page-head--group > .btn { background: transparent; }
.page-head--group > .btn:hover { background: var(--surface-3); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.side { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  /* 통계 카드(cols-4)는 내용이 짧아 2열을 유지한다 — 1열이면 스크롤만 길어진다 */
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .page-head--title { font-size: 22px; }
}

/* ── 카드 ─────────────────────────────────────────── */
/* 그림자 없이 흰 면 + 헤어라인. 앱 전체가 하나의 흰 시트처럼 보이게 한다. */

/*
 * 카드에 테두리를 두르지 않는다.
 * 레퍼런스(flex)는 카드를 윤곽선으로 감싸지 않고 (a) 연회색 페이지 배경 위의 흰 면,
 * (b) 행과 행 사이 헤어라인, (c) 작은 섹션 헤더 + 여백 으로만 구분한다.
 * 그래서 --bg 와 --surface 의 대비가 이 시스템의 유일한 카드 경계다.
 */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  padding: 18px;
}
.card--head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card--title { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.card--tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat--label { font-size: 12px; color: var(--text-3); font-weight: 600; }
.stat--value { font-size: 22px; font-weight: 700; letter-spacing: -.035em; line-height: 1.3; }
.stat--unit { font-size: 13px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.stat--delta { font-size: 12px; font-weight: 600; }
.stat--delta.up { color: var(--brand-ink); }
.stat--delta.down { color: var(--dang-ink); }

/* ── 버튼 ─────────────────────────────────────────── */
/* 보조 = 연회색 채움(무테두리), 주요 = 초록 채움, 파괴 = 빨강 채움, 취소 = 텍스트 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px;
  border-radius: var(--radius);
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  letter-spacing: -.01em;
  transition: background .12s, color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary { background: var(--brand); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--brand-strong); }

.btn.danger { background: var(--dang); color: #fff; font-weight: 700; }
.btn.danger:hover { background: var(--dang-strong); }

.btn.ghost { background: transparent; color: var(--text-2); font-weight: 600; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

/* 마크업이 "ghost danger" 로 쓰는 취소 버튼은 텍스트만 빨강으로 둔다 */
.btn.ghost.danger { background: transparent; color: var(--dang-ink); font-weight: 600; }
.btn.ghost.danger:hover { background: var(--dang-weak); color: var(--dang-ink); }

.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-sm); }
.btn.block { width: 100%; height: 48px; font-size: 15px; }
.btn.sm.block { height: 34px; font-size: 13px; }

/*
 * 포커스 링을 한 곳에서 정의한다.
 * 정의하지 않으면 브라우저 기본 파란 링이 그대로 나와 팔레트와 따로 논다
 * (모달을 열면 첫 버튼에 포커스가 가서 특히 눈에 띈다).
 * :focus-visible 만 쓰므로 마우스 클릭에는 링이 안 생기고 키보드 이동에만 보인다.
 */
:where(button, a, [tabindex], summary):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/*
 * 다이얼로그 안에서는 링을 안쪽으로 그린다.
 * 바깥으로 그리면 항목을 감싼 "테두리"처럼 보여서, 선택 표시(연한 초록 면)와 헷갈린다.
 */
dialog .sc--option:focus-visible,
dialog .dp--day:focus-visible { outline-offset: -2px; }
.modal--foot > .btn:focus-visible { outline-offset: -2px; }

/* ── 폼 ───────────────────────────────────────────── */
/*
 * 레퍼런스 구조: 회색으로 채운 박스 안에 [작은 라벨 / 값] 이 세로로 들어가고,
 * 박스 밖 아래에 [도움말(왼쪽) · 글자수(오른쪽)] 이 붙는다.
 * 라벨이 박스 밖 위에 있던 예전 구조와 다르다.
 */

.field { display: flex; flex-direction: column; gap: 6px; }

.field--box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  /* 링을 안쪽에 그려서 포커스 때 폭이 안 바뀐다 = 레이아웃이 안 흔들린다 */
  outline: 1.5px solid transparent;
  outline-offset: -1.5px;
  transition: background-color .12s, outline-color .12s;
  cursor: text;
}
.field--box:hover { background: var(--surface-3); }

.field--label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: -.01em;
  line-height: 1.4;
  transition: color .12s;
}
/* 필수 표시 — 별표가 아니라 작은 원 */
.field--req {
  display: inline-block;
  width: 3.5px; height: 3.5px;
  margin-left: 3px;
  vertical-align: 3px;
  border-radius: 50%;
  background: var(--brand);
}

.field--control {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  /* iOS 자동 줌 방지 — 16px 미만이면 포커스 시 화면이 확대된다 */
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
}
.field--control::placeholder { color: var(--text-3); font-weight: 400; }
.field--control:focus { outline: none; }
/*
 * 사용자가 직접 늘리지 못하게 막는다(resize: none).
 * 레퍼런스도 높이는 고정이고 내용이 넘치면 안에서 스크롤된다.
 */
textarea.field--control { height: 96px; resize: none; overflow-y: auto; }

/* select 의 네이티브 화살표를 지우고 아이콘 세트와 같은 굵기의 셰브론을 얹는다 */
.field--select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2365686d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  background-size: 16px 16px;
  cursor: pointer;
}
.field--select::-ms-expand { display: none; }

/*
 * <input type="number"> 의 위아래 스피너도 브라우저가 그리는 것이라 톤을 못 맞춘다.
 * 값은 키보드로 넣는 게 대부분이고 모바일은 숫자 키패드가 뜨므로 그냥 감춘다.
 * (inputmode 는 JS 에서 붙인다 — 모바일 키패드가 숫자로 뜨게)
 */
.field--control[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.field--control[type="number"]::-webkit-outer-spin-button,
.field--control[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 색상 선택 input 도 네이티브 테두리를 지운다 */
.field--control[type="color"] {
  height: 34px; padding: 0; border: 0; background: transparent; cursor: pointer;
}
.field--control[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field--control[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }

/* 포커스 — 박스에 초록 링, 라벨도 초록 */
.field--box:has(:focus-visible) { background: var(--surface); outline-color: var(--brand); }
.field--box:has(:focus-visible) .field--label { color: var(--brand-ink); }

/* 에러 — 빨간 링 + 빨간 라벨 + 경고 아이콘이 붙은 빨간 도움말 */
.field[data-state="error"] .field--box { background: var(--surface); outline-color: var(--dang); }
.field[data-state="error"] .field--label { color: var(--dang-ink); }
.field[data-state="error"] .field--hint { color: var(--dang-ink); font-weight: 600; }
.field[data-state="error"] .field--hint::before {
  content: "";
  display: inline-block;
  width: 13px; height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3 2 20h20L12 3Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M12 10v4' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17' r='1' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
}

.field--foot {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 4px;
  font-size: 12px;
  line-height: 1.5;
}
.field--hint { flex: 1; color: var(--text-3); }
.field--count {
  margin-left: auto; flex-shrink: 0;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 160px; }

/* 박스 구조가 필요 없는 단독 입력(검색창 등) */
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius);
  background-color: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  transition: background-color .12s;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2365686d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  cursor: pointer;
}
.select::-ms-expand { display: none; }
.textarea { min-height: 96px; resize: none; overflow-y: auto; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: 1.5px solid var(--brand);
  outline-offset: -1.5px;
  background-color: var(--surface);
}

/* ── 배지 ─────────────────────────────────────────── */
/* 같은 색 계열의 연한 채움 + 진한 글자. 작고 옅게. */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 7px;
  border-radius: var(--radius-xs);
  font-size: 11.5px; font-weight: 700; line-height: 1;
  letter-spacing: -.01em;
  background: var(--surface-2); color: var(--text-2);
}
.badge.ok    { background: var(--ok-weak);    color: var(--ok-ink); }
.badge.warn  { background: var(--warn-weak);  color: var(--warn-ink); }
.badge.dang  { background: var(--dang-weak);  color: var(--dang-ink); }
.badge.info  { background: var(--info-weak);  color: var(--info-ink); }
.badge.brand { background: var(--brand-weak); color: var(--brand-ink); }

/* ── 필터 칩 ──────────────────────────────────────── */
/* 알약 유지. 비활성 = 흰 면 + 1px 테두리, 활성 = 연한 파랑 채움 + 파란 글자.
   활성에 초록을 쓰면 주요 버튼과 경쟁해 화면이 초록으로 덮인다. */

.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0; white-space: nowrap;
  height: 32px; padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  letter-spacing: -.01em;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-active {
  background: var(--sel-weak);
  border-color: color-mix(in srgb, var(--sel) 26%, transparent);
  color: var(--sel-ink);
  font-weight: 700;
}
.chip.is-active:hover { background: var(--sel-weak); color: var(--sel-ink); }

/* ── 세그먼트 컨트롤 ──────────────────────────────── */
/*
 * 배타적 선택(하나만 고르는 것)에 쓴다. 여러 개를 켜고 끄는 필터에는 .chip 을 쓴다.
 * 레퍼런스: 회색 트랙 위에 선택된 것만 흰 알약 + 옅은 그림자.
 */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }

.segmented--item {
  flex: 1 0 auto;
  height: 32px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
  letter-spacing: -.01em;
  transition: background .12s, color .12s;
}
.segmented--item:hover { color: var(--text-2); }
.segmented--item.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow);
}
.segmented--item.is-active:hover { color: var(--text); }

/* ── 진행 바 ──────────────────────────────────────── */
/* 진척·완료는 초록. 파랑(--sel)은 선택 상태 전용이라 데이터 표현에는 쓰지 않는다. */

.bar { height: 6px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--brand); transition: width .3s; }
.bar.ok > i { background: var(--brand); }

/* ── 리스트(플래너 항목 등) ───────────────────────── */
/* 항목마다 상자를 그리지 않는다. 리스트 전체가 하나의 면이고 행은 헤어라인으로만 나뉜다. */

.item {
  display: flex; align-items: flex-start; gap: 11px;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.item + .item { margin-top: 0; border-top: 1px solid var(--line-soft); }
button.item { cursor: pointer; }
button.item:hover { background: var(--surface-2); }
.item.is-done { background: transparent; }
.item.is-done .item--main { opacity: .62; }
.item.is-done .item--title { text-decoration: line-through; color: var(--text-3); }
.item--main { flex: 1; min-width: 0; }
.item--title { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.item--meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 5px; font-size: 12px; color: var(--text-3); }
.item--actions { display: flex; gap: 2px; flex-shrink: 0; }

/* 상태 표시는 사각형이 아니라 원 */
.check {
  flex-shrink: 0;
  width: 20px; height: 20px; margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  display: grid; place-items: center;
  color: transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.check:hover { border-color: var(--brand); }
.check.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── 테이블 ───────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
table.data th, table.data td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); }
table.data th {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  background: transparent;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  letter-spacing: -.01em;
}
table.data td { color: var(--text); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── 빈 상태 / 로딩 ───────────────────────────────── */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.7;
}
.empty strong { display: block; color: var(--text); font-size: 15px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.015em; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
  border-radius: var(--radius-sm);
  height: 56px;
}
.skeleton + .skeleton { margin-top: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── 토스트 ───────────────────────────────────────── */

.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(420px, calc(100% - 32px));
}
.toast {
  pointer-events: auto;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--text); color: #fff;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: toast-in .2s ease;
}
.toast.err { background: var(--dang); }
.toast.ok  { background: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── 모달 ─────────────────────────────────────────── */
/* 진짜로 떠야 하는 것 — 여기서만 그림자를 쓴다 */

dialog.modal {
  border: none; padding: 0;
  border-radius: 12px;
  background: var(--surface); color: var(--text);
  width: min(520px, calc(100% - 32px));
  box-shadow: var(--shadow-pop);
  /*
   * ★ margin: auto 를 반드시 되살린다.
   *   전역 리셋의 `* { margin: 0 }` 이 <dialog> 의 UA 기본값(margin:auto)을 덮어써서
   *   showModal() 이 가운데가 아니라 좌상단에 붙는다. 리셋을 쓰는 프로젝트의 단골 함정.
   */
  margin: auto;
  max-height: calc(100dvh - 48px);
  overflow: auto;
}
/* showModal() 이 다이얼로그에 포커스를 주면서 브라우저 기본 파란 링이 그려진다. 내부 요소 포커스는 그대로 둔다. */
dialog.modal:focus,
dialog.modal:focus-visible { outline: none; }
/* 딤만 준다. blur 를 걸면 뷰포트 전체를 다시 합성해야 해서 모달 안 입력이 눌린다. */
dialog.modal::backdrop { background: rgba(12, 14, 18, .42); }
.modal--head { padding: 20px 20px 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.modal--body { padding: 14px 20px; display: flex; flex-direction: column; gap: 12px; }
/*
 * 레퍼런스(flex)의 모달 액션 배치.
 * 오른쪽 정렬 작은 버튼 두 개가 아니라, 주요 버튼이 전체 폭으로 위에 오고
 * 취소는 그 아래 가운데 텍스트 버튼이다.
 * 마크업은 [취소, 확인] 순서라 column-reverse 로 뒤집어 확인을 위로 올린다.
 */
.modal--foot {
  padding: 6px 20px 18px;
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
}
.modal--foot > .btn { width: 100%; height: 48px; font-size: 15px; }
/* 취소(= primary/danger 가 아닌 것)는 배경 없는 텍스트 버튼으로 */
.modal--foot > .btn:not(.primary):not(.danger) {
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
}
.modal--foot > .btn:not(.primary):not(.danger):hover { background: var(--surface-2); }

/* ── 선택(드롭다운) 컨트롤 ────────────────────────── */
/* 네이티브 <select> 팝업을 대체한 컴포넌트. 목록은 모달로 띄운다. */

.sc { display: flex; width: 100%; }
.sc--trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  min-height: 22px;
  padding-right: 22px;
  text-align: left;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2365686d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
  background-size: 16px 16px;
}
.sc--trigger.is-empty .sc--text { color: var(--text-3); }
.sc--text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/*
 * 목록 시트는 .sc-sheet 로 따로 둔다.
 * 인라인 래퍼와 같은 .sc 를 쓰면 `.sc { display: flex }` 가 다이얼로그에도 걸려
 * 제목과 목록이 가로로 나란히 배치된다(실제로 그렇게 나왔다).
 */
dialog.modal.sc-sheet { width: min(320px, calc(100% - 32px)); padding: 8px; }
dialog.modal.sc-sheet .sc--list { width: 100%; }
.sc--option { width: 100%; }
.sc--head {
  padding: 10px 12px 8px;
  font-size: 13px; font-weight: 700; color: var(--text-3);
}
.sc--list { display: flex; flex-direction: column; max-height: min(60dvh, 420px); overflow-y: auto; }
.sc--option {
  display: flex; align-items: center; gap: 8px;
  min-height: 46px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; color: var(--text);
  text-align: left;
}
.sc--option:hover { background: var(--surface-2); }
.sc--option.is-sel { background: var(--brand-weak); color: var(--brand-ink); font-weight: 700; }
.sc--option-label { flex: 1; }
.sc--check { display: inline-flex; color: var(--brand); flex-shrink: 0; }

/* 날짜 선택기의 시/분도 이 컨트롤을 쓴다 */
.dp--time .sc { flex: 1; }
.dp--time .sc--trigger {
  min-height: 36px;
  padding: 0 22px 0 10px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  background-position: right 8px center;
  font-size: 14px;
}
.dp--time .sc--trigger:hover { background-color: var(--surface-3); }

/* ── 날짜 선택기 ──────────────────────────────────── */
/* 네이티브 달력을 대체한 컴포넌트. 레퍼런스대로 오늘은 초록 글자, 선택은 초록 원. */

.date-control--wrap { display: flex; }
.date-control {
  display: inline-flex; align-items: center; gap: 8px;
  justify-content: space-between;
  width: 100%; min-width: 170px;
  text-align: left;
  cursor: pointer;
}
.date-control.is-empty .date-control--text { color: var(--text-3); }
.date-control--text { font-size: 14px; font-weight: 600; }
.date-control--icon { display: inline-flex; color: var(--text-3); flex-shrink: 0; }
.date-control:hover { background: var(--surface-3); }

dialog.modal.dp { width: min(340px, calc(100% - 32px)); padding: 16px; }

.dp--head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.dp--title {
  flex: 1; text-align: center;
  font-size: 15px; font-weight: 700; letter-spacing: -.02em;
  height: 32px; border-radius: var(--radius-sm);
}
.dp--title:hover { background: var(--surface-2); }
.dp--nav {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  font-size: 18px; line-height: 1; color: var(--text-2);
}
.dp--nav:hover { background: var(--surface-2); }

.dp--grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp--dow {
  height: 28px; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--text-3);
}
.dp--dow[data-end] { color: var(--text-3); }
.dp--day {
  height: 38px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dp--day:hover { background: var(--surface-2); }
.dp--day.is-today { color: var(--brand-ink); font-weight: 700; }
.dp--day.is-sel {
  background: var(--brand); color: #fff; font-weight: 700;
}
.dp--day.is-sel:hover { background: var(--brand-strong); }

.dp--time {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.dp--ampm { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; }
.dp--seg {
  height: 30px; padding: 0 12px;
  border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-3);
}
.dp--seg.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dp--select { flex: 1; min-height: 36px; height: 36px; padding: 0 10px; }

.dp--foot { display: flex; gap: 8px; margin-top: 14px; }
.dp--foot > .btn { flex: 1; height: 44px; }

/* ── 유틸 ─────────────────────────────────────────── */

.row   { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col   { display: flex; flex-direction: column; gap: 8px; }
.spacer{ margin-left: auto; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.strong{ font-weight: 700; }
.nums  { font-variant-numeric: tabular-nums; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.hidden{ display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── 푸터 ─────────────────────────────────────────── */

.global-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 18px 0;
  color: var(--text-3);
  font-size: 12px;
}
/* 좁은 화면에서는 이름을 감추고 아바타만 남긴다 — 메뉴가 눌리지 않게 */
@media (max-width: 720px) {
  .global-header--user { padding: 4px; background: transparent; }
  .global-header--name { display: none; }
  .global-header--inner { gap: 6px; }
}

.global-footer--inner {
  width: min(var(--container), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
