/* 구독핀 — 디자인 토큰과 컴포넌트. 외부 글꼴·이미지 없음.
   규칙(테스트로 검사): 토큰 블록 밖에서는 색 리터럴(#, rgb, hsl)을 쓰지 않고, 글자 크기·굵기는 토큰만,
   px 리터럴은 0·1px·2px(선·광학 보정)만 쓴다. @media 조건의 폭은 예외다. */

:root {
  color-scheme: light;
  /* 간격 (4/8 배수). --hair는 선 두께·1~2px 광학 보정 전용 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --hair: 2px;
  /* 크기 */
  --tap: 44px; --icon: 20px; --icon-sm: 16px; --icon-lg: 28px; --dot: 8px; --mark: 30px; --tile: 52px;
  --avatar: 44px; --avatar-sm: 32px; --avatar-xs: 24px;
  --switch-w: 40px; --switch-h: 24px; --knob: 18px; --ring-w: 2px; --halo: 3px; --stripe: 6px; --glow: 260px;
  --blur: 14px; --blur-sm: 3px;
  --page-max: 1080px; --sheet-w: 640px; --sheet-sm: 480px; --sheet-xs: 400px; --sheet-gap: 24px; --sheet-max-h: 900px;
  --countdown-w: 150px; --when-w: 104px; --stat-min: 220px; --chart-min: 300px; --search-min: 220px; --donut-max: 220px; --chart-h: 220px;
  /* 반지름 */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;
  /* 글자: 7단계 위계 */
  --font: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "D2Coding", monospace; --doc-max: 72ch;
  --fs-2xs: 0.6875rem; --fs-xs: 0.75rem; --fs-sm: 0.8125rem; --fs-md: 0.9375rem; --fs-lg: 1.0625rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;
  --fs-hero: clamp(2.75rem, 9vw, 4.5rem); --fs-hero-sm: clamp(2.25rem, 12vw, 3rem);
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh: 1.5; --lh-tight: 1.2;
  /* 모션 */
  --t-fast: 150ms; --t-med: 200ms; --ease: cubic-bezier(.2, .7, .2, 1);

  /* 색: 중립 */
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f0efec; --surface-3: #e7e6e1;
  --ink: #0b0b0b; --ink-2: #4a4945; --muted: #5f5e59;
  --line: rgba(11, 11, 11, .09); --line-strong: rgba(11, 11, 11, .16); --field-border: #868580;
  --shadow-sm: 0 1px 2px rgba(20, 20, 15, .06), 0 1px 1px rgba(20, 20, 15, .04);
  --shadow-md: 0 6px 20px -8px rgba(20, 20, 15, .18), 0 2px 6px rgba(20, 20, 15, .05);
  --shadow-lg: 0 24px 60px -20px rgba(20, 20, 15, .35);
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, .25); --knob-color: #ffffff;
  --scrim: rgba(10, 10, 8, .45);
  /* 강조 1계열 */
  --accent: #2a5bd7; --accent-ink: #ffffff; --accent-soft: #e8eefc; --accent-text: #1f48b0;
  /* 의미색 (상태 전용, 차트 계열에 쓰지 않는다). *-text는 배경 위 글자, on-*는 진한 바탕 위 글자 */
  --critical: #c42f2f; --critical-soft: #fdeceb; --critical-ink: #9e1f1f; --critical-text: #b42727; --on-critical: #ffffff;
  --warning: #b86a00; --warning-soft: #fff4dc; --warning-ink: #7a4600;
  --good: #0f7a2e; --good-soft: #e6f5ea;
  /* 카테고리 (dataviz 기본 범주형 팔레트 순서, 0은 기타 회색) + 그 위 글자색 */
  --c0: #898781; --c1: #2670cc; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #6250d6;
  --on-c0: #0b0b0b; --on-c1: #ffffff; --on-c2: #0b0b0b; --on-c3: #0b0b0b; --on-c4: #0b0b0b; --on-c5: #0b0b0b; --on-c6: #ffffff; --on-c7: #ffffff;
  --grid: #e1e0d9; --axis: #c3c2b7;
  /* 토스트는 두 테마 모두 어두운 바탕 */
  --toast-bg: #1c1c1a; --toast-ink: #f0efec; --toast-line: rgba(255, 255, 255, .35); --toast-hover: rgba(255, 255, 255, .12);
}

/* 다크: 아래 두 블록은 값이 같아야 한다(테스트로 검사). 기기 설정 다크 + 직접 고른 다크. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
    --ink: #f0efec; --ink-2: #c9c8c0; --muted: #a3a29a;
    --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .16); --field-border: #7a7972;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    --scrim: rgba(0, 0, 0, .6);
    --accent: #7a9dff; --accent-ink: #0b1430; --accent-soft: #1f2a48; --accent-text: #a9c0ff;
    --critical: #ff6b6b; --critical-soft: #3a1a1a; --critical-ink: #ffb3b0; --critical-text: #ff8f8a; --on-critical: #1f0606;
    --warning: #f0ad3c; --warning-soft: #36280f; --warning-ink: #ffd590;
    --good: #3cc463; --good-soft: #12301c;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9;
    --on-c1: #0b0b0b; --on-c2: #0b0b0b; --on-c3: #0b0b0b; --on-c4: #0b0b0b; --on-c5: #0b0b0b; --on-c6: #ffffff; --on-c7: #0b0b0b;
    --grid: #2c2c2a; --axis: #383835;
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
    --ink: #f0efec; --ink-2: #c9c8c0; --muted: #a3a29a;
    --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .16); --field-border: #7a7972;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
    --scrim: rgba(0, 0, 0, .6);
    --accent: #7a9dff; --accent-ink: #0b1430; --accent-soft: #1f2a48; --accent-text: #a9c0ff;
    --critical: #ff6b6b; --critical-soft: #3a1a1a; --critical-ink: #ffb3b0; --critical-text: #ff8f8a; --on-critical: #1f0606;
    --warning: #f0ad3c; --warning-soft: #36280f; --warning-ink: #ffd590;
    --good: #3cc463; --good-soft: #12301c;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9;
    --on-c1: #0b0b0b; --on-c2: #0b0b0b; --on-c3: #0b0b0b; --on-c4: #0b0b0b; --on-c5: #0b0b0b; --on-c6: #ffffff; --on-c7: #0b0b0b;
    --grid: #2c2c2a; --axis: #383835;
}

/* ---------- 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fw-regular) var(--fs-md)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: var(--ring-w) solid var(--accent); outline-offset: var(--hair); border-radius: var(--r-xs); }
h1, h2, h3, h4, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.sprite { display: none; }
.skip { position: absolute; left: var(--s4); top: var(--s2); transform: translateY(-300%); z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s4); border-radius: var(--r-sm); }
.skip:focus { transform: none; }

.ico { width: var(--icon); height: var(--icon); flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }
.ico-lg { width: var(--icon-lg); height: var(--icon-lg); }

.h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -.01em; display: flex; align-items: center; gap: var(--s2); }
.h4 { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.hint { color: var(--muted); font-size: var(--fs-sm); }
.num, .money { font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: var(--avatar-xs); height: var(--avatar-xs); padding: 0 var(--s2); border-radius: var(--r-pill); background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }

/* ---------- 버튼 (모든 누름 대상은 --tap 이상) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: var(--fw-semibold); font-size: var(--fs-md); cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--critical); color: var(--on-critical); border-color: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 85%, var(--ink)); }
.btn-danger-ghost { background: transparent; color: var(--critical-text); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--critical-soft); }
/* 작은 버튼: 글자와 좌우 여백만 줄이고 높이는 터치 대상 기준을 지킨다 */
.btn-sm { padding: 0 var(--s3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-on-dark { background: transparent; color: inherit; border-color: var(--toast-line); }
.btn-on-dark:hover { background: var(--toast-hover); }
.icon-only { width: var(--tap); padding: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- 상단 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(var(--blur)); -webkit-backdrop-filter: saturate(1.6) blur(var(--blur)); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: var(--page-max); margin: 0 auto; padding: var(--s2) var(--s4); padding-top: max(var(--s2), env(safe-area-inset-top)); display: flex; align-items: center; gap: var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s2); color: inherit; text-decoration: none; margin-right: auto; min-height: var(--tap); min-width: 0; }
.brand-mark { width: var(--mark); height: var(--mark); flex: none; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: var(--accent-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.03em; }.topbar-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }

/* ---------- 페이지 ---------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: var(--s6) var(--s4) var(--s12); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: var(--s5); }

/* ---------- 히어로: 가장 급한 일정 ---------- */
.hero { --tone: var(--accent); --tone-soft: var(--accent-soft); --tone-ink: var(--accent-text);
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-md);
  padding: var(--s6); display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--stripe); background: var(--tone); }
.hero::after { content: ""; position: absolute; right: calc(var(--glow) * -0.3); top: calc(var(--glow) * -0.3); width: var(--glow); height: var(--glow); border-radius: 50%; background: radial-gradient(closest-side, var(--tone-soft), transparent); pointer-events: none; }
.hero[data-level="critical"] { --tone: var(--critical); --tone-soft: var(--critical-soft); --tone-ink: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 45%, var(--line)); }
.hero[data-level="warning"] { --tone: var(--warning); --tone-soft: var(--warning-soft); --tone-ink: var(--warning-ink); }
.hero-eyebrow { justify-self: start; display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--tone-ink); background: var(--tone-soft); padding: var(--s1) var(--s3); border-radius: var(--r-pill); }
.hero-main { position: relative; z-index: 1; display: grid; gap: var(--s3); min-width: 0; }
.hero-title { display: flex; align-items: center; gap: var(--s3); font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: var(--lh-tight); min-width: 0; }
.hero-title span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-meta { color: var(--ink-2); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.countdown { position: relative; z-index: 1; text-align: center; min-width: var(--countdown-w); padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--tone-soft); color: var(--tone-ink); }
.countdown-num { display: block; font-size: var(--fs-hero); font-weight: var(--fw-bold); line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.countdown-unit { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-top: var(--s2); }
.hero[data-level="critical"] .countdown { background: var(--critical); color: var(--on-critical); }
.hero[data-level="critical"] .countdown-num { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: .72; } }
.hero-next { position: relative; z-index: 1; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s2); padding-top: var(--s4); border-top: 1px dashed var(--line-strong); }
.hero-next .hint { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3) var(--s1) var(--s1); border-radius: var(--r-pill); background: var(--surface-2); font-size: var(--fs-sm); max-width: 100%; }
.chip .avatar { width: var(--avatar-xs); height: var(--avatar-xs); font-size: var(--fs-xs); border-radius: 50%; }
.chip b { font-weight: var(--fw-semibold); }

/* 빈 상태 */
.empty { text-align: center; padding: var(--s10) var(--s6); display: grid; justify-items: center; gap: var(--s3); grid-template-columns: minmax(0, 1fr); }
.empty::before, .empty::after { display: none; }
.empty-art { width: calc(var(--s12) * 2.5); height: calc(var(--s12) * 2); }
.empty-art .a { fill: var(--accent-soft); }
.empty-art .b { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.empty-art .c { fill: var(--accent); }
.empty-art .d { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.empty h2 { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.02em; }
.empty p { color: var(--ink-2); max-width: 36ch; }
.quick-presets { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); margin-top: var(--s2); }
.empty-points { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2) var(--s5); color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s2); }
.empty-points li { display: flex; align-items: center; gap: var(--s1); }
.empty-points .ico { color: var(--good); width: var(--icon-sm); height: var(--icon-sm); vertical-align: 0; }

/* ---------- 알림 띠 ---------- */
.due { background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); border-radius: var(--r-lg); padding: var(--s4) var(--s5); display: grid; gap: var(--s3); }
.due-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.due-head .h3 { color: var(--warning-ink); }
.due-list { display: grid; gap: var(--s2); }
.due-list li { display: flex; align-items: flex-start; gap: var(--s2); }
.due-list li .ico { width: var(--icon-sm); height: var(--icon-sm); margin-top: var(--hair); color: var(--warning-ink); }
.due-list li.is-critical .ico { color: var(--critical-text); }

/* ---------- 합계 ---------- */
.stat-grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(var(--stat-min), 100%), 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s5); display: grid; gap: var(--s1); box-shadow: var(--shadow-sm); min-width: 0; }
.stat-label { color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); display: flex; justify-content: space-between; gap: var(--s2); }
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: var(--lh-tight); overflow-wrap: anywhere; }
.stat-sub { color: var(--ink-2); font-size: var(--fs-sm); }
.stat-sub b { font-weight: var(--fw-semibold); color: var(--ink); }

/* ---------- 탭 ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.tabs { display: inline-flex; gap: var(--s1); padding: var(--s1); background: var(--surface-2); border-radius: var(--r-md); justify-self: start; }
.tabs [role="tab"] { min-height: var(--tap); min-width: calc(var(--s10) * 2); padding: 0 var(--s4); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-weight: var(--fw-semibold); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); animation: fade var(--t-med) var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(var(--s1)); } }

/* 도구 막대 */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.search { position: relative; flex: 1 1 var(--search-min); display: flex; min-width: 0; }
.search .ico { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); color: var(--muted); width: var(--icon-sm); height: var(--icon-sm); pointer-events: none; }
.search input { width: 100%; padding-left: var(--s10); }
input, select, textarea {
  min-height: var(--tap); padding: var(--s2) var(--s3); border-radius: var(--r-md); max-width: 100%;
  border: 1px solid var(--field-border); background: var(--surface); color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea { resize: vertical; line-height: var(--lh); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 var(--halo) color-mix(in srgb, var(--accent) 30%, transparent); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--critical); box-shadow: 0 0 0 1px var(--critical); }
select { appearance: none; padding-right: var(--s10); background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 1.25em) 50%, calc(100% - 0.9375em) 50%; background-size: 0.3125em 0.3125em; background-repeat: no-repeat; }
.select-wrap { display: inline-flex; align-items: center; gap: var(--s2); max-width: 100%; }
.field-label-inline { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- 구독 목록 ---------- */
.sub-list { display: grid; gap: var(--s2); }
.sub {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  animation: rise var(--t-med) var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(var(--s2)); } }
.sub:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.sub[data-level="critical"] { border-color: color-mix(in srgb, var(--critical) 50%, var(--line)); background: linear-gradient(90deg, var(--critical-soft), var(--surface) 55%); }
.sub[data-level="warning"] { background: linear-gradient(90deg, var(--warning-soft), var(--surface) 55%); }
.avatar { --cat: var(--c0); --on-cat: var(--on-c0); width: var(--avatar); height: var(--avatar); border-radius: var(--r-md); display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-lg); color: var(--on-cat); background: var(--cat); flex: none; letter-spacing: -.02em; }
[data-slot="0"] { --cat: var(--c0); --on-cat: var(--on-c0); } [data-slot="1"] { --cat: var(--c1); --on-cat: var(--on-c1); }
[data-slot="2"] { --cat: var(--c2); --on-cat: var(--on-c2); } [data-slot="3"] { --cat: var(--c3); --on-cat: var(--on-c3); }
[data-slot="4"] { --cat: var(--c4); --on-cat: var(--on-c4); } [data-slot="5"] { --cat: var(--c5); --on-cat: var(--on-c5); }
[data-slot="6"] { --cat: var(--c6); --on-cat: var(--on-c6); } [data-slot="7"] { --cat: var(--c7); --on-cat: var(--on-c7); }
.sub-main { min-width: 0; display: grid; gap: var(--hair); }
.sub-name { font-weight: var(--fw-semibold); font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.sub-meta { color: var(--muted); font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 0 var(--s2); min-width: 0; }
.sub-meta > * { overflow-wrap: anywhere; }
.sub-meta > * + *::before { content: "·"; margin-right: var(--s2); color: var(--muted); }
.sub-money { text-align: right; display: grid; gap: var(--hair); }
.sub-amount { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub-share { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub-when { text-align: right; display: grid; justify-items: end; gap: var(--hair); min-width: var(--when-w); }
.dday { display: inline-flex; align-items: center; gap: var(--s1); padding: var(--hair) var(--s2); border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: var(--fw-semibold); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.dday .ico { width: var(--icon-sm); height: var(--icon-sm); vertical-align: 0; }
.dday[data-level="warning"] { background: var(--warning-soft); color: var(--warning-ink); }
.dday[data-level="critical"] { background: var(--critical); color: var(--on-critical); }
.tag-trial { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--accent-text); white-space: nowrap; }
.sub-date { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
button.sub { width: 100%; min-height: var(--tap); text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.sub:active { transform: scale(.995); }
button.sub:focus-visible { outline: var(--ring-w) solid var(--accent); outline-offset: var(--hair); border-radius: var(--r-lg); }
.sub-list-muted .sub { grid-template-columns: auto minmax(0, 1fr) auto; background: var(--surface-2); }
.sub-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.sub-list-muted .avatar { filter: grayscale(.7); opacity: .8; }
.empty-inline { text-align: center; color: var(--muted); padding: var(--s8) var(--s4); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.cancelled { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s1) var(--s4); }
.cancelled summary { cursor: pointer; font-weight: var(--fw-semibold); min-height: var(--tap); display: flex; align-items: center; gap: var(--s2); }
.cancelled[open] { padding-bottom: var(--s3); }
.cancelled .hint { margin-bottom: var(--s3); }

/* ---------- 달력 ---------- */
.cal-head { display: flex; align-items: center; gap: var(--s2); }
.cal-head h2 { min-width: 9.5em; justify-content: center; font-variant-numeric: tabular-nums; }
.cal-head #cal-today { margin-left: auto; }
.cal { width: 100%; border-collapse: separate; border-spacing: var(--s1); table-layout: fixed; }
.cal th { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--muted); padding-bottom: var(--s1); }
.cal th:first-child { color: var(--critical-text); } .cal th:last-child { color: var(--accent-text); }
.cal td { padding: 0; }
.day {
  width: 100%; aspect-ratio: 1 / .92; min-height: var(--tap); border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: var(--s1) var(--s2); cursor: pointer;
  font-variant-numeric: tabular-nums; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.day:hover { border-color: var(--line-strong); }
/* 다른 달의 날짜: 투명도 대신 흐린 글자색(대비 4.5:1 유지) */
.day.out { background: transparent; border-style: dashed; }
.day.out .day-num { color: var(--muted); font-weight: var(--fw-regular); }
.day.today .day-num { background: var(--accent); color: var(--accent-ink); }
.day[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 var(--ring-w) color-mix(in srgb, var(--accent) 30%, transparent); }
.day-num { font-size: var(--fs-sm); font-weight: var(--fw-semibold); min-width: var(--avatar-xs); height: var(--avatar-xs); display: grid; place-items: center; border-radius: var(--r-pill); }
.day-dots { display: flex; flex-wrap: wrap; gap: var(--hair); }
.dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--cat, var(--accent)); display: inline-block; flex: none; }
.dot-trial, .day-dots .dot-trial { background: transparent; border: var(--hair) solid var(--critical); }
.dot-renewal { background: var(--ink-2); }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.cal-legend .dot { margin-left: var(--s2); }
.day-total { font-size: var(--fs-2xs); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-list { display: grid; gap: var(--s2); }
.day-list li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.day-list .avatar { width: var(--avatar-sm); height: var(--avatar-sm); border-radius: var(--r-sm); font-size: var(--fs-sm); }
.day-list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- 분석 ---------- */
.insight-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(var(--chart-min), 100%), 1fr)); }
.chart-card { display: grid; gap: var(--s3); align-content: start; min-width: 0; }
.donut-wrap { position: relative; width: min(var(--donut-max), 70%); margin: var(--s2) auto; }
.donut { width: 100%; display: block; }
.donut-track { stroke: var(--surface-2); }
.donut path { stroke: none; transition: opacity var(--t-fast) var(--ease); }
.donut path.seg { fill: var(--cat); }
.donut:hover path.seg:not(:hover) { opacity: .55; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-value { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.legend { display: grid; gap: var(--s1); }
.legend li { display: grid; grid-template-columns: var(--s3) minmax(0, 1fr) auto auto; gap: var(--s2); align-items: center; font-size: var(--fs-sm); padding: var(--s1) 0; border-bottom: 1px solid var(--line); }
.legend li:last-child { border-bottom: 0; }
.legend .sw { width: var(--s3); height: var(--s3); border-radius: var(--r-xs); background: var(--cat); }
.legend .pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.legend .amt { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; text-align: right; }
.bars-wrap { position: relative; }
.bars { width: 100%; height: var(--chart-h); display: block; overflow: visible; }
.bars .grid { stroke: var(--grid); stroke-width: 1; }
.bars .base { stroke: var(--axis); stroke-width: 1; }
.bars .bar { fill: var(--c1); transition: opacity var(--t-fast) var(--ease); }
.bars .bar.now { fill: var(--accent); }
.bars:hover .bar:not(.hot) { opacity: .55; }
.bars g:focus { outline: none; }
.bars g:focus-visible .hit { stroke: var(--accent); stroke-width: 2; }
.bars .hit { fill: transparent; cursor: default; }
.bars text { fill: var(--muted); font-size: var(--fs-2xs); font-family: var(--font); font-variant-numeric: tabular-nums; }
.bars text.val { fill: var(--ink-2); font-weight: var(--fw-semibold); }
/* 말풍선: 위치는 app.js가 상자 안으로 맞춰 넣는다(가로 넘침 없음) */
.tip { position: absolute; transform: translateY(-100%); background: var(--ink); color: var(--bg); padding: var(--s1) var(--s2); border-radius: var(--r-sm); font-size: var(--fs-xs); pointer-events: none; white-space: nowrap; box-shadow: var(--shadow-md); font-variant-numeric: tabular-nums; }
.table-view summary { cursor: pointer; font-size: var(--fs-sm); color: var(--accent-text); min-height: var(--tap); display: flex; align-items: center; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin-top: var(--s2); }
.data-table th, .data-table td { text-align: left; padding: var(--s2); border-bottom: 1px solid var(--line); }
.data-table .num { text-align: right; }
.switch { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; min-height: var(--tap); font-size: var(--fs-md); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: var(--switch-w); height: var(--switch-h); border-radius: var(--r-pill); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--field-border); position: relative; transition: background var(--t-fast) var(--ease); flex: none; }
.switch-ui::after { content: ""; position: absolute; top: calc((var(--switch-h) - var(--knob)) / 2); left: calc((var(--switch-h) - var(--knob)) / 2); width: var(--knob); height: var(--knob); border-radius: 50%; background: var(--knob-color); box-shadow: var(--shadow-knob); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .switch-ui { background: var(--accent); box-shadow: none; }
.switch input:checked + .switch-ui::after { transform: translateX(calc(var(--switch-w) - var(--switch-h))); }
.switch input:focus-visible + .switch-ui { outline: var(--ring-w) solid var(--accent); outline-offset: var(--hair); }

/* ---------- 내보내기 카드 ---------- */
.export-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s4); align-items: center; background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%); }
.export-icon { width: var(--tile); height: var(--tile); border-radius: var(--r-lg); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; align-self: start; }
.export-body { display: grid; gap: var(--s2); max-width: 68ch; }
.export-body p { color: var(--ink-2); }
.export-notes { list-style: disc; padding-left: 1.1em; display: grid; gap: var(--hair); }

/* ---------- 바닥글 ---------- */
.footer { max-width: var(--page-max); margin: 0 auto; padding: var(--s6) var(--s4) max(var(--s10), env(safe-area-inset-bottom)); color: var(--ink-2); font-size: var(--fs-sm); display: grid; gap: var(--s1); text-align: center; }
.footer .ico { width: var(--icon-sm); height: var(--icon-sm); vertical-align: -0.2em; color: var(--good); }
.footer a, .doc-body a { color: var(--accent-text); text-decoration: underline; text-underline-offset: .2em; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--s2); }
.empty .empty-mail { color: var(--muted); font-size: var(--fs-sm); max-width: none; }
.empty-mail a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); border-radius: var(--r-xs); color: var(--accent-text); text-decoration: underline; text-underline-offset: .2em; font-weight: var(--fw-semibold); }
.footer a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); border-radius: var(--r-xs); font-weight: var(--fw-semibold); }
.footer a:hover { text-decoration-thickness: var(--hair); }
a.btn { text-decoration: none; }

/* ---------- 처리방침 페이지 (privacy.html, PRIVACY.md에서 생성) ---------- */
.doc > * { width: 100%; max-width: var(--doc-max); justify-self: center; }
.doc-body { display: grid; gap: var(--s4); }
.doc-body h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -.02em; }
.doc-body h2 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin-top: var(--s4); }
.doc-body ul { list-style: disc; padding-left: 1.2em; display: grid; gap: var(--s2); }
.doc-body code { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--surface-2); padding: 0 var(--s1); border-radius: var(--r-xs); overflow-wrap: anywhere; }
.blank { display: inline-block; background: var(--warning-soft); color: var(--warning-ink); border: 1px dashed var(--warning); border-radius: var(--r-xs); padding: 0 var(--s1); font-weight: var(--fw-semibold); }
.note { color: var(--muted); font-size: var(--fs-sm); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.table-wrap .data-table { margin: 0; }
.table-wrap th[scope="row"] { font-weight: var(--fw-semibold); white-space: nowrap; }
.draft-banner { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); padding: var(--s4) var(--s5); background: var(--warning-soft); color: var(--warning-ink); border: 1px solid var(--warning); border-radius: var(--r-lg); }
.draft-banner > div { display: grid; gap: var(--s2); }
.draft-banner .ico { color: var(--warning-ink); }

/* ---------- 대화상자 ---------- */
.sheet { width: min(var(--sheet-w), calc(100% - var(--sheet-gap))); max-height: min(92vh, var(--sheet-max-h)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
.sheet[open] { animation: pop var(--t-med) var(--ease); }
.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(var(--blur-sm)); }
@keyframes pop { from { opacity: 0; transform: translateY(var(--s3)) scale(.98); } }
.sheet > form { display: flex; flex-direction: column; max-height: inherit; }
.sheet-sm { width: min(var(--sheet-sm), calc(100% - var(--sheet-gap))); }
.sheet-xs { width: min(var(--sheet-xs), calc(100% - var(--sheet-gap))); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s6); border-bottom: 1px solid var(--line); }
.sheet-body { padding: var(--s5) var(--s6); overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.sheet-foot { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) var(--s6); border-top: 1px solid var(--line); background: var(--surface); }
.spacer { flex: 1; }
.preset-grid { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s1) var(--hair) var(--s2); scroll-snap-type: x proximity; margin-top: var(--s3); scrollbar-width: thin; overscroll-behavior-x: contain; }
.preset { display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3) var(--s1) var(--s1); border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; white-space: nowrap; min-height: var(--tap); scroll-snap-align: start; font-weight: var(--fw-medium); transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.preset:hover { background: var(--surface-2); }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.preset .avatar { width: var(--avatar-sm); height: var(--avatar-sm); border-radius: 50%; font-size: var(--fs-sm); }
#preset-area .hint { margin-top: var(--s1); }
.field-grid { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field { display: grid; gap: var(--s2); align-content: start; border: 0; padding: 0; margin: 0; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field > label, .field legend { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--ink-2); padding: 0; }
.field legend { margin-bottom: var(--s2); }
.field input, .field select, .field textarea { width: 100%; }
.field-error { color: var(--critical-text); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.field-error:empty { display: none; }
.form-error { color: var(--critical-text); font-weight: var(--fw-semibold); }
.form-error:empty { display: none; }
.switch-field { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--ink-2); }
#trial-wrap { display: grid; gap: var(--s2); }
#trial-wrap label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: var(--fw-semibold); }
.segmented { display: flex; background: var(--surface-2); border-radius: var(--r-md); padding: var(--s1); gap: var(--s1); }
.segmented label { flex: 1; position: relative; min-width: 0; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-height: var(--tap); padding: 0 var(--s2); border-radius: var(--r-sm); font-weight: var(--fw-semibold); color: var(--ink-2); text-align: center; transition: background var(--t-fast) var(--ease); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: var(--ring-w) solid var(--accent); outline-offset: 1px; }
.more { border-top: 1px solid var(--line); padding-top: var(--s3); }
.more summary { cursor: pointer; font-weight: var(--fw-semibold); color: var(--accent-text); min-height: var(--tap); display: flex; align-items: center; }
.more[open] summary { margin-bottom: var(--s3); }
.settings-status { font-weight: var(--fw-semibold); color: var(--ink-2); }
.settings-status:empty { display: none; }
.settings-block { display: grid; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); }

/* ---------- 토스트 ---------- */
.toast { position: fixed; left: 50%; bottom: max(var(--s6), env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: var(--s4); padding: var(--s2) var(--s2) var(--s2) var(--s5); min-height: calc(var(--tap) + var(--s2)); width: max-content; max-width: calc(100% - var(--s8)); background: var(--toast-bg); color: var(--toast-ink); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: rise var(--t-med) var(--ease); }
.toast:not(:has(#toast-action:not([hidden]))) { padding-right: var(--s5); }
.toast .btn:focus-visible { outline-color: var(--toast-ink); }

/* ---------- 반응형: 720px 이하(휴대폰·작은 태블릿), 400px 이하(좁은 휴대폰) ---------- */
@media (max-width: 720px) {
  .page { padding-top: var(--s4); gap: var(--s4); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: var(--s5); }
  .countdown { order: -1; justify-self: start; display: flex; align-items: baseline; gap: var(--s2); padding: var(--s2) var(--s4); min-width: 0; }
  .countdown-num { font-size: var(--fs-hero-sm); }
  .countdown-unit { margin: 0; }
  .hero-title { font-size: var(--fs-xl); }
  .sub { grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); }
  .sub-money { grid-column: 2; grid-row: 2; text-align: left; display: flex; flex-wrap: wrap; gap: 0 var(--s2); align-items: baseline; }
  .sub-when { grid-column: 3; grid-row: 1 / span 2; min-width: 0; }
  .sub-list-muted .sub { grid-template-columns: auto minmax(0, 1fr); }
  .sub-actions { grid-column: 2; }
  .export-card { grid-template-columns: minmax(0, 1fr); }
  .export-card .btn { width: 100%; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .icon-only-sm span { display: none; }
  .icon-only-sm { width: var(--tap); padding: 0; }
  .sheet { width: 100%; max-width: 100%; max-height: 94vh; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .sheet-xs { margin: auto; border-radius: var(--r-xl); width: calc(100% - var(--sheet-gap)); }
  .sheet-body { padding: var(--s4); }
  .sheet-head { padding-left: var(--s4); }
  .sheet-foot { padding: var(--s3) var(--s4) max(var(--s3), env(safe-area-inset-bottom)); }
  .cal-head h2 { min-width: 0; flex: 1; }
  .cal-head #cal-today { margin-left: 0; }
  .day { aspect-ratio: auto; height: calc(var(--tap) + var(--s2)); padding: var(--s1); }
  .day-total { display: none; }
  .cal { border-spacing: var(--hair); }
}
/* 상단 바 폭 계산(2026-11-28 이름 변경 후): 표지 30+8 + 이름 '구독핀' 약 65 + 간격 12 + 버튼 44+4+44+4+약 120 ≈ 331px [추정, 글꼴에 따라 다름].
   이전 배지(약 78px)는 지웠다. 400px 이하에서는 아래 규칙이 '구독 추가' 글자를 숨긴다. */
@media (max-width: 400px) {
  .topbar-inner { gap: var(--s2); }
  .topbar-actions .btn-primary span { display: none; }
  .topbar-actions .btn-primary { width: var(--tap); padding: 0; }
  .tabs { justify-self: stretch; }
  .tabs [role="tab"] { flex: 1; min-width: 0; }
}

/* 움직임 줄이기 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* 고대비(강제 색) */
@media (forced-colors: active) {
  .avatar, .dot, .legend .sw, .dday { forced-color-adjust: none; }
  .hero::before { background: CanvasText; }
  .switch-ui { border: 1px solid CanvasText; }
}
@media print {
  .topbar, .tabs, .toolbar, .export-card .btn, .footer, .toast { display: none !important; }
  body { background: Canvas; color: CanvasText; }
}
