/* =========================================================
   쑥쑥위크 컴포넌트 v1.0  —  tokens.css 다음에 불러온다.
   명명: .ds-{block}__{element}--{modifier}
   문서: docs/디자인시스템.md 4장
   ========================================================= */

/* ---------- 0. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.ds-num { font-variant-numeric: tabular-nums; }
.ds-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;
}

/* 타이포 헬퍼 */
.ds-title    { font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); letter-spacing: var(--letter-spacing-tight); margin: 0; }
.ds-section-title { font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); line-height: var(--line-height-snug); margin: 0; }
.ds-body     { font-size: var(--font-size-md); }
.ds-caption  { font-size: var(--font-size-sm); color: var(--color-text-sub); line-height: var(--line-height-snug); }
.ds-display  { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }
.ds-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.ds-link { color: var(--color-primary-text); font-weight: var(--font-weight-semibold); font-size: var(--font-size-sm); text-decoration: none; min-height: var(--touch-min); display: inline-flex; align-items: center; background: none; border: 0; padding: 0 var(--space-1); }

/* ---------- 1. App frame & screen skeleton ---------- */
.ds-app {
  position: relative;
  width: 100%;
  max-width: var(--app-max-width);
  min-width: var(--app-min-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}
.ds-app__body {
  flex: 1;
  padding: var(--space-4) var(--page-x) calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-6));
  overscroll-behavior: contain;
}
.ds-app__body > * + * { margin-top: var(--section-gap); }
@media (min-width: 768px) {
  body { background: var(--color-bg-desktop); }
  .ds-app {
    margin: var(--space-8) auto;
    min-height: calc(100dvh - var(--space-16));
    border-radius: 32px;
    box-shadow: var(--shadow-3);
    overflow: clip;
  }
}

/* ---------- 2. Top bar ---------- */
.ds-topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--space-2);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--space-2) 0 var(--page-x);
  background: var(--color-bg);
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.ds-topbar__title { flex: 1; min-width: 0; font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-topbar__actions { display: flex; align-items: center; gap: var(--space-1); }
.ds-topbar--back { padding-left: var(--space-1); }

.ds-points {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 32px; padding: 0 var(--space-3) 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--badge-point-bg); color: var(--color-text);
  font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums;
  font-size: var(--font-size-md); border: 0; text-decoration: none;
}
.ds-points__coin { width: 24px; height: 24px; flex: none; }
.ds-points__unit { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); color: var(--badge-point-fg); }

/* ---------- 3. Bottom tab bar (6 tabs) ---------- */
.ds-tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: var(--z-tabbar);
  width: 100%; max-width: var(--app-max-width);
  display: grid; grid-template-columns: repeat(6, minmax(60px, 1fr));
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: var(--border);
  box-shadow: 0 -2px 12px rgba(58, 53, 48, 0.05);
}
.ds-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--touch-min);
  color: var(--color-text-sub); text-decoration: none; background: none; border: 0;
  font-size: var(--font-size-2xs); font-weight: var(--font-weight-medium); line-height: 1.2;
}
.ds-tab svg { width: 24px; height: 24px; }
.ds-tab[aria-current="page"] { color: var(--color-primary-text); font-weight: var(--font-weight-bold); }
.ds-tab[aria-current="page"] svg { stroke-width: 2.25; }
.ds-tab[aria-current="page"] .ds-tab__icon { background: var(--color-primary-soft); }
.ds-tab__icon { display: grid; place-items: center; width: 44px; height: 28px; border-radius: var(--radius-pill); transition: background var(--duration-fast) var(--ease-out); }
.ds-tab:active .ds-tab__icon { transform: scale(0.92); }

/* ---------- 4. Buttons ---------- */
.ds-btn {
  --btn-h: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--btn-h); padding: 0 var(--space-5);
  border-radius: var(--radius-pill); border: var(--border-width-strong) solid transparent;
  font-size: var(--font-size-md); font-weight: var(--font-weight-bold); line-height: 1;
  white-space: nowrap; text-decoration: none; user-select: none;
  transition: transform var(--duration-instant) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}
.ds-btn:active { transform: scale(0.97); }
.ds-btn--sm { --btn-h: 36px; padding: 0 var(--space-3); font-size: var(--font-size-sm); }
.ds-btn--sm::after { content: ""; position: absolute; inset: -4px 0; } /* 터치 영역 44px 보정 */
.ds-btn--sm { position: relative; }
.ds-btn--lg { --btn-h: 56px; font-size: var(--font-size-lg); }
.ds-btn--block { display: flex; width: 100%; }

.ds-btn--primary   { background: var(--color-primary-strong); color: var(--color-on-primary); }
.ds-btn--primary:active { background: var(--color-primary-press); }
.ds-btn--secondary { background: var(--color-surface); color: var(--color-primary-text); border-color: var(--color-primary); }
.ds-btn--secondary:active { background: var(--color-primary-soft); }
.ds-btn--ghost     { background: transparent; color: var(--color-text-sub); }
.ds-btn--ghost:active { background: var(--color-surface-sunken); }
.ds-btn--danger    { background: var(--color-danger-strong); color: var(--color-text-inverse); }
.ds-btn--danger:active { background: var(--red-700); }
.ds-btn--danger-ghost { background: transparent; color: var(--color-danger-text); }

.ds-btn:disabled, .ds-btn[aria-disabled="true"] {
  background: var(--color-surface-sunken); color: var(--color-text-disabled);
  border-color: transparent; transform: none; cursor: not-allowed;
}
.ds-btn-row { display: flex; gap: var(--space-2); }
.ds-btn-row > .ds-btn:last-child { flex: 1; }

/* ---------- 5. Icon button ---------- */
.ds-icon-btn {
  display: inline-grid; place-items: center;
  width: var(--touch-min); height: var(--touch-min);
  border-radius: var(--radius-pill); border: 0; background: transparent; color: var(--color-text);
  transition: background var(--duration-fast) var(--ease-out);
}
.ds-icon-btn svg { width: 24px; height: 24px; }
.ds-icon-btn:active { background: var(--color-surface-sunken); }
.ds-icon-btn--filled { background: var(--color-surface); box-shadow: var(--shadow-1); }
.ds-icon-btn:disabled { color: var(--color-text-disabled); }

/* ---------- 6. FAB ---------- */
.ds-fab {
  position: fixed; z-index: var(--z-fab);
  right: max(var(--page-x), calc((100vw - var(--app-max-width)) / 2 + var(--page-x)));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-4));
  display: grid; place-items: center;
  width: var(--fab-size); height: var(--fab-size); border-radius: var(--radius-pill); border: 0;
  background: var(--color-primary-strong); color: var(--color-on-primary); box-shadow: var(--shadow-2);
  transition: transform var(--duration-instant) var(--ease-out);
}
.ds-fab svg { width: 28px; height: 28px; }
.ds-fab:active { transform: scale(0.94); background: var(--color-primary-press); }
.ds-fab--extended { width: auto; padding: 0 var(--space-5) 0 var(--space-4); gap: var(--space-2); display: inline-flex; align-items: center; font-weight: var(--font-weight-bold); }
.ds-fab--static { position: static; }

/* ---------- 7. Checkbox (할 일) : 시각 22px / 터치 44px ---------- */
.ds-check { position: relative; display: inline-grid; place-items: center; width: var(--touch-min); height: var(--touch-min); flex: none; cursor: pointer; }
.ds-check input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: inherit; }
.ds-check__box {
  width: 22px; height: 22px; border-radius: var(--radius-xs);
  border: var(--border-width-strong) solid var(--color-border-control); background: var(--color-surface);
  display: grid; place-items: center;
  transition: background var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-pop);
}
.ds-check__box::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid var(--color-on-primary); border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0); transition: transform var(--duration-base) var(--ease-pop);
}
.ds-check input:checked + .ds-check__box { background: var(--color-check); border-color: var(--color-check); transform: scale(1.08); }
.ds-check input:checked + .ds-check__box::after { transform: rotate(45deg) scale(1); }
.ds-check input:active + .ds-check__box { transform: scale(0.9); }
.ds-check input:focus-visible + .ds-check__box { box-shadow: var(--shadow-focus); }
.ds-check input:disabled + .ds-check__box { background: var(--color-surface-sunken); border-color: var(--color-border); }
.ds-check input:disabled:checked + .ds-check__box { background: var(--neutral-400); border-color: var(--neutral-400); }

/* ---------- 8. Routine tracker (루틴 × 월~일) ---------- */
.ds-tracker { width: 100%; border-collapse: separate; border-spacing: 0 var(--space-1); table-layout: fixed; }
.ds-tracker col.ds-tracker__title-col { width: 110px; }
.ds-tracker th { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); color: var(--color-text-sub); text-align: center; padding: 0 0 var(--space-1); }
.ds-tracker th.is-today { color: var(--color-primary-text); }
.ds-tracker__title { text-align: left; padding-right: var(--space-2); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-tracker__meta { display: block; font-size: var(--font-size-2xs); color: var(--color-text-sub); font-weight: var(--font-weight-medium); font-variant-numeric: tabular-nums; }
.ds-tracker td { text-align: center; padding: 0; }

.ds-routine-cell {
  position: relative; width: 100%; max-width: 40px; height: var(--touch-min);
  display: inline-grid; place-items: center; border: 0; background: transparent; padding: 0;
}
.ds-routine-cell input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.ds-routine-cell__dot {
  width: 30px; height: 30px; border-radius: var(--radius-pill);
  border: var(--border-width-strong) solid var(--color-border-control); background: var(--color-surface);
  display: grid; place-items: center; color: var(--color-on-primary);
  transition: background var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-pop);
}
.ds-routine-cell__dot svg { width: 16px; height: 16px; opacity: 0; }
/* 체크 */
.ds-routine-cell input:checked + .ds-routine-cell__dot,
.ds-routine-cell--done .ds-routine-cell__dot { background: var(--color-check); border-color: var(--color-check); }
.ds-routine-cell input:checked + .ds-routine-cell__dot svg,
.ds-routine-cell--done .ds-routine-cell__dot svg { opacity: 1; }
.ds-routine-cell input:active + .ds-routine-cell__dot { transform: scale(0.88); }
.ds-routine-cell input:focus-visible + .ds-routine-cell__dot { box-shadow: var(--shadow-focus); }
/* 오늘: 진한 테두리 링 */
.ds-routine-cell--today .ds-routine-cell__dot { border-color: var(--color-primary-text); border-width: 2.5px; }
/* 비수행일: 점선 + 연한 배경 (체크는 허용 — 계약서 2장) */
.ds-routine-cell--off .ds-routine-cell__dot { border-style: dashed; background: var(--color-surface-sunken); }
/* 미래: 체크 불가 */
.ds-routine-cell--future .ds-routine-cell__dot { border-color: var(--color-border); background: transparent; }
.ds-routine-cell--future input { cursor: not-allowed; }

/* ---------- 9. Chips & segment ---------- */
.ds-chip-row {
  display: flex; gap: var(--space-2); overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; margin: 0 calc(var(--page-x) * -1); padding: 2px var(--page-x);
}
.ds-chip-row::-webkit-scrollbar { display: none; }
.ds-chip-row--wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.ds-chip {
  position: relative; flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 36px; min-width: 44px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill); border: var(--border-width) solid var(--color-border-strong);
  background: var(--color-surface); color: var(--color-text);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); white-space: nowrap;
}
.ds-chip::after { content: ""; position: absolute; inset: -4px 0; }
.ds-chip:active { transform: scale(0.96); }
.ds-chip[aria-pressed="true"], .ds-chip[aria-checked="true"], .ds-chip.is-selected {
  background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary-text);
}
.ds-chip--day { width: 40px; min-width: 40px; padding: 0; }
.ds-chip--routine.is-done { background: var(--color-primary-soft); border-color: transparent; color: var(--color-primary-text); text-decoration: line-through; }

.ds-segment {
  display: flex; gap: var(--space-1); padding: var(--space-1);
  background: var(--color-surface-sunken); border-radius: var(--radius-pill);
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.ds-segment::-webkit-scrollbar { display: none; }
.ds-segment__item {
  flex: 1 0 auto; scroll-snap-align: start;
  min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 0;
  background: transparent; color: var(--color-text-sub);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); white-space: nowrap;
  position: relative;
}
.ds-segment__item::after { content: ""; position: absolute; inset: -4px 0; }
.ds-segment__item[aria-selected="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); font-weight: var(--font-weight-bold); }

/* ---------- 10. Badges ---------- */
.ds-badge {
  display: inline-flex; align-items: center; gap: 2px; flex: none;
  height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-pill);
  font-size: var(--font-size-2xs); font-weight: var(--font-weight-bold); line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--badge-carry1-bg); color: var(--badge-carry1-fg);
}
.ds-badge--done    { background: var(--badge-done-bg);    color: var(--badge-done-fg); }
.ds-badge--late    { background: var(--badge-late-bg);    color: var(--badge-late-fg); }
.ds-badge--carry1  { background: var(--badge-carry1-bg);  color: var(--badge-carry1-fg); }
.ds-badge--carry3  { background: var(--badge-carry3-bg);  color: var(--badge-carry3-fg); }
.ds-badge--carry5  { background: var(--badge-carry5-bg);  color: var(--badge-carry5-fg); }
.ds-badge--dropped { background: var(--badge-dropped-bg); color: var(--badge-dropped-fg); text-decoration: line-through; }
.ds-badge--info    { background: var(--badge-info-bg);    color: var(--badge-info-fg); }
.ds-badge--point   { background: var(--badge-point-bg);   color: var(--badge-point-fg); }
.ds-badge--count   { min-width: 22px; justify-content: center; padding: 0 6px; background: var(--color-text); color: var(--color-text-inverse); }

/* ---------- 11. Card ---------- */
.ds-card {
  background: var(--color-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); padding: var(--space-4);
}
.ds-card--flat { box-shadow: none; border: var(--border); }
.ds-card--tint { background: var(--color-primary-soft); box-shadow: none; }
.ds-card--interactive { display: block; width: 100%; text-align: left; border: 0; color: inherit; text-decoration: none; transition: transform var(--duration-instant) var(--ease-out); }
.ds-card--interactive:active { transform: scale(0.98); }
.ds-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-3); }
.ds-card__stat { font-size: var(--font-size-2xl); font-weight: var(--font-weight-heavy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ds-card__stat small { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); color: var(--color-text-sub); margin-left: 2px; }
.ds-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }

/* ---------- 12. List & task row ---------- */
.ds-list { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.ds-list > li + li { border-top: var(--border-width) solid var(--color-divider); }
.ds-group-head { display: flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-1); font-size: var(--font-size-sm); font-weight: var(--font-weight-bold); color: var(--color-text-sub); }
.ds-group-head.is-today { color: var(--color-primary-text); }
.ds-group--today { background: var(--color-primary-soft); border-radius: var(--radius-lg); padding: var(--space-1) var(--space-2) var(--space-2); }

.ds-task-row {
  display: flex; align-items: center; gap: var(--space-1);
  min-height: 56px; padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  background: var(--color-surface);
}
.ds-task-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) 0; background: none; border: 0; text-align: left; color: inherit; }
.ds-task-row__title { font-size: var(--font-size-md); font-weight: var(--font-weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color var(--duration-base); }
.ds-task-row__meta { font-size: var(--font-size-xs); color: var(--color-text-sub); }
.ds-task-row__trail { display: flex; align-items: center; gap: var(--space-1); flex: none; }
.ds-task-row--done .ds-task-row__title { color: var(--color-text-sub); text-decoration: line-through; text-decoration-color: var(--neutral-400); }
.ds-task-row--readonly { opacity: 0.6; }
.ds-task-row--carried-out .ds-task-row__title { color: var(--color-text-sub); }
.ds-task-row:active { background: var(--color-surface-sunken); }

/* ---------- 13. Progress ---------- */
.ds-progress { display: grid; gap: var(--space-1); }
.ds-progress__label { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); }
.ds-progress__value { font-variant-numeric: tabular-nums; color: var(--color-text-sub); font-weight: var(--font-weight-medium); }
.ds-progress__track { height: 10px; border-radius: var(--radius-pill); background: var(--color-surface-sunken); overflow: hidden; }
.ds-progress__fill { height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--color-primary); transition: width var(--duration-slow) var(--ease-out); }
.ds-progress--exp .ds-progress__fill { background: var(--butter-400); }
.ds-progress--exp .ds-progress__track { height: 12px; }
.ds-progress--sm .ds-progress__track { height: 6px; }
.ds-progress--stack .ds-progress__fill + .ds-progress__fill { background: var(--color-late); }
.ds-progress--stack .ds-progress__track { display: flex; }

/* ---------- 14. Bottom sheet (<dialog class="ds-sheet">) ---------- */
.ds-sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; padding: 0;
  width: 100%; max-width: var(--app-max-width); max-height: var(--sheet-max-h);
  border: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden;
}
.ds-sheet:not([open]) { display: none; }
.ds-sheet::backdrop { background: var(--color-overlay); }
.ds-sheet[open] { animation: ds-sheet-in var(--duration-slow) var(--ease-out); }
@keyframes ds-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.ds-sheet__handle { width: 40px; height: 4px; border-radius: var(--radius-pill); background: var(--color-border-strong); margin: var(--space-2) auto 0; flex: none; }
.ds-sheet__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5); flex: none; }
.ds-sheet__title { flex: 1; font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); margin: 0; }
.ds-sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-2) var(--space-5) var(--space-4); display: grid; gap: var(--space-5); align-content: start; }
.ds-sheet__foot { flex: none; padding: var(--space-3) var(--space-5) calc(var(--space-3) + var(--safe-bottom)); border-top: var(--border-width) solid var(--color-divider); background: var(--color-surface); }
.ds-sheet--auto { max-height: var(--sheet-max-h); }      /* 내용 높이 */
.ds-sheet--half { height: 50dvh; }                       /* 먹이·확인 */
.ds-sheet--full { height: var(--sheet-max-h); }          /* 편집 폼 */
.ds-demo-static.ds-sheet { position: relative; display: flex; inset: auto; box-shadow: var(--shadow-2); }

/* ---------- 15. Modal (<dialog class="ds-modal">) ---------- */
.ds-modal {
  width: calc(100% - var(--space-8)); max-width: 360px; padding: var(--space-6) var(--space-5) var(--space-5);
  border: 0; border-radius: var(--radius-xl); background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-3); text-align: center;
}
.ds-modal::backdrop { background: var(--color-overlay); }
.ds-modal[open] { animation: ds-pop-in var(--duration-slow) var(--ease-pop); }
@keyframes ds-pop-in { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.ds-modal__title { font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); margin: 0 0 var(--space-2); }
.ds-modal__body { color: var(--color-text-sub); margin-bottom: var(--space-5); }
.ds-modal__actions { display: grid; gap: var(--space-2); }
.ds-demo-static.ds-modal { position: relative; display: block; margin: 0 auto; }

/* ---------- 16. Toast ---------- */
.ds-toast-region {
  position: fixed; z-index: var(--z-toast); left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-4));
  width: calc(100% - var(--page-x) * 2); max-width: calc(var(--app-max-width) - var(--page-x) * 2);
  display: grid; gap: var(--space-2); pointer-events: none;
}
.ds-toast {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 48px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--neutral-900); color: var(--color-text-inverse); box-shadow: var(--shadow-2);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); pointer-events: auto;
  animation: ds-toast-in var(--duration-base) var(--ease-out);
}
.ds-toast__action { margin-left: auto; background: none; border: 0; color: var(--butter-300); font-weight: var(--font-weight-bold); min-height: var(--touch-min); padding: 0 var(--space-1); }
.ds-toast--error { background: var(--red-700); }
@keyframes ds-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 플로팅 보상 (+10P) */
.ds-float-point {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px var(--space-2);
  border-radius: var(--radius-pill); background: var(--color-accent); color: var(--neutral-900);
  font-family: var(--font-display); font-size: var(--font-size-lg); font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-1);
  animation: ds-float-up 900ms var(--ease-out) forwards;
}
@keyframes ds-float-up { 0% { transform: translateY(8px) scale(0.8); opacity: 0; } 20% { opacity: 1; transform: translateY(0) scale(1.05); } 100% { transform: translateY(-36px); opacity: 0; } }

/* ---------- 17. Speech bubble ---------- */
.ds-bubble {
  position: relative; display: inline-block; max-width: 240px;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1);
  border: var(--border-width-strong) solid var(--neutral-900);
  font-family: var(--font-display); font-size: var(--font-size-lg); line-height: var(--line-height-snug);
  animation: ds-pop-in var(--duration-base) var(--ease-pop);
}
.ds-bubble::after {
  content: ""; position: absolute; left: var(--tail-x, 50%); bottom: -9px; width: 14px; height: 14px;
  background: inherit; border: inherit; border-width: 0 2px 2px 0; transform: translateX(-50%) rotate(45deg);
}
[data-art="pixel"] .ds-bubble, .ds-bubble--pixel {
  font-family: var(--font-pixel-body); font-size: 15px; border-radius: 0; line-height: 1.6;
  box-shadow: 4px 4px 0 rgba(58, 53, 48, 0.2);
  clip-path: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
  padding-bottom: var(--space-3);
}
[data-art="pixel"] .ds-bubble::after, .ds-bubble--pixel::after { display: none; }

/* ---------- 18. Fields ---------- */
.ds-field { display: grid; gap: var(--space-2); }
.ds-field__label { font-size: var(--font-size-sm); font-weight: var(--font-weight-bold); }
.ds-field__label .req { color: var(--color-danger-text); margin-left: 2px; }
.ds-input, .ds-textarea, .ds-select {
  width: 100%; min-height: 48px; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); border: var(--border-width-strong) solid transparent;
  background: var(--color-surface-sunken); color: var(--color-text);
  font-size: var(--font-size-input); line-height: var(--line-height-snug);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--color-placeholder); }
.ds-input:focus, .ds-textarea:focus, .ds-select:focus { outline: none; border-color: var(--color-primary); background: var(--color-surface); box-shadow: none; }
.ds-textarea { min-height: 120px; resize: vertical; }
.ds-textarea--diary { min-height: 240px; line-height: var(--line-height-body); }
.ds-input:disabled, .ds-textarea:disabled { color: var(--color-text-disabled); }
.ds-field__foot { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--font-size-xs); color: var(--color-text-sub); font-variant-numeric: tabular-nums; }
.ds-field--error .ds-input, .ds-field--error .ds-textarea { border-color: var(--color-danger); background: var(--red-50); }
.ds-field__error { color: var(--color-danger-text); font-weight: var(--font-weight-semibold); }
.ds-saved { color: var(--color-primary-text); font-weight: var(--font-weight-semibold); }

/* ---------- 19. Empty state ---------- */
.ds-empty { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-4); text-align: center; }
.ds-empty__art { width: 96px; height: 96px; display: grid; place-items: center; font-size: 48px; border-radius: var(--radius-pill); background: var(--color-primary-soft); }
.ds-empty__title { font-size: var(--font-size-md); font-weight: var(--font-weight-bold); margin: 0; }
.ds-empty__desc { font-size: var(--font-size-sm); color: var(--color-text-sub); margin: 0; }
.ds-empty--inline { padding: var(--space-3); grid-auto-flow: column; justify-content: start; justify-items: start; text-align: left; }

/* ---------- 20. Banner ---------- */
.ds-banner {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--font-size-sm); line-height: var(--line-height-snug);
  background: var(--badge-info-bg); color: var(--badge-info-fg);
}
.ds-banner__icon { flex: none; font-size: 16px; line-height: 1.3; }
.ds-banner__text { flex: 1; }
.ds-banner__text b { display: block; }
.ds-banner--error { background: var(--red-100); color: var(--red-800); }
.ds-banner--warn  { background: var(--orange-100); color: var(--orange-800); }
.ds-banner--success { background: var(--green-100); color: var(--green-800); }
.ds-banner--sticky { position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: var(--z-banner); border-radius: 0; margin: 0 calc(var(--page-x) * -1); }

/* ---------- 21. Shop item card ---------- */
.ds-shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.ds-shop-card {
  --cat: var(--shop-food); --cat-bg: var(--shop-food-bg); --cat-fg: var(--shop-food-fg);
  position: relative; display: grid; grid-template-rows: auto auto auto; gap: var(--space-1);
  padding: var(--space-3); border-radius: var(--radius-lg); border: var(--border-width-strong) solid transparent;
  background: var(--color-surface); box-shadow: var(--shadow-1); text-align: left; color: inherit;
  transition: transform var(--duration-instant) var(--ease-out);
}
.ds-shop-card:active { transform: scale(0.97); }
.ds-shop-card[data-cat="food"]  { --cat: var(--shop-food);  --cat-bg: var(--shop-food-bg);  --cat-fg: var(--shop-food-fg); }
.ds-shop-card[data-cat="frame"] { --cat: var(--shop-frame); --cat-bg: var(--shop-frame-bg); --cat-fg: var(--shop-frame-fg); }
.ds-shop-card[data-cat="deco"]  { --cat: var(--shop-deco);  --cat-bg: var(--shop-deco-bg);  --cat-fg: var(--shop-deco-fg); }
.ds-shop-card[data-cat="bg"]    { --cat: var(--shop-bg);    --cat-bg: var(--shop-bg-bg);    --cat-fg: var(--shop-bg-fg); }
.ds-shop-card[data-cat="equip"] { --cat: var(--shop-equip); --cat-bg: var(--shop-equip-bg); --cat-fg: var(--shop-equip-fg); }
.ds-shop-card__thumb { aspect-ratio: 1; border-radius: var(--radius-md); background: var(--cat-bg); display: grid; place-items: center; margin-bottom: var(--space-1); overflow: hidden; }
.ds-shop-card__thumb img, .ds-shop-card__thumb svg { width: 64px; height: 64px; }
.ds-shop-card__thumb--wide img { width: 100%; height: 100%; object-fit: cover; } /* 배경·테두리 */
.ds-shop-card__name { font-size: var(--font-size-sm); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-shop-card__effect { font-size: var(--font-size-xs); color: var(--cat-fg); font-weight: var(--font-weight-semibold); min-height: 1.4em; }
.ds-shop-card__price { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--font-weight-heavy); font-variant-numeric: tabular-nums; font-size: var(--font-size-md); }
.ds-shop-card__price img, .ds-shop-card__price svg { width: 18px; height: 18px; }
.ds-shop-card__tag { position: absolute; top: var(--space-2); right: var(--space-2); }
/* 상태 */
.ds-shop-card--owned .ds-shop-card__price { color: var(--color-text-sub); font-weight: var(--font-weight-semibold); font-size: var(--font-size-sm); }
.ds-shop-card--equipped { border-color: var(--color-primary); }
.ds-shop-card--unaffordable .ds-shop-card__price { color: var(--color-text-sub); }
.ds-shop-card--unaffordable .ds-shop-card__thumb > * { opacity: 0.55; }
.ds-shop-card--locked { background: var(--color-surface-sunken); box-shadow: none; }
.ds-shop-card--locked .ds-shop-card__thumb > * { filter: grayscale(1); opacity: 0.5; }

/* ---------- 22. Saju ---------- */
.ds-saju-hero {
  border-radius: var(--radius-lg); padding: var(--space-5) var(--space-4);
  background: var(--saju-brand-bg); color: var(--saju-brand-fg);
}
.ds-saju-hero__summary { font-family: var(--font-display); font-size: var(--font-size-xl); line-height: var(--line-height-snug); color: var(--color-text); margin: var(--space-1) 0 0; }
.ds-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.ds-pillar { background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-2); text-align: center; }
.ds-pillar__hanja { font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); line-height: 1.2; }
.ds-pillar__label { font-size: var(--font-size-xs); color: var(--color-text-sub); }
.ds-ohaeng { display: grid; gap: var(--space-2); }
.ds-ohaeng__row { display: grid; grid-template-columns: 40px 1fr 24px; align-items: center; gap: var(--space-2); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); }
.ds-ohaeng__bar { height: 10px; border-radius: var(--radius-pill); background: var(--color-surface-sunken); overflow: hidden; }
.ds-ohaeng__bar i { display: block; height: 100%; width: var(--value, 0%); background: var(--c); border-radius: inherit; }
.ds-ohaeng__row--wood  { --c: var(--ohaeng-wood); }
.ds-ohaeng__row--fire  { --c: var(--ohaeng-fire); }
.ds-ohaeng__row--earth { --c: var(--ohaeng-earth); }
.ds-ohaeng__row--metal { --c: var(--ohaeng-metal); }
.ds-ohaeng__row--water { --c: var(--ohaeng-water); }

.ds-saju-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.ds-saju-tab {
  --c: var(--saju-wealth); --c-bg: var(--saju-wealth-bg); --c-fg: var(--saju-wealth-fg);
  display: grid; justify-items: center; gap: 2px; min-height: 64px; padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-md); border: var(--border-width-strong) solid transparent;
  background: var(--color-surface); box-shadow: var(--shadow-1); font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); color: var(--color-text-sub);
}
.ds-saju-tab__emoji { font-size: 22px; line-height: 1.2; }
.ds-saju-tab__score { font-variant-numeric: tabular-nums; font-weight: var(--font-weight-bold); color: var(--color-text); font-size: var(--font-size-sm); }
.ds-saju-tab[aria-selected="true"] { background: var(--c-bg); border-color: var(--c); color: var(--c-fg); }
[data-cat="wealth"] { --c: var(--saju-wealth); --c-bg: var(--saju-wealth-bg); --c-fg: var(--saju-wealth-fg); }
[data-cat="love"]   { --c: var(--saju-love);   --c-bg: var(--saju-love-bg);   --c-fg: var(--saju-love-fg); }
[data-cat="career"] { --c: var(--saju-career); --c-bg: var(--saju-career-bg); --c-fg: var(--saju-career-fg); }
[data-cat="health"] { --c: var(--saju-health); --c-bg: var(--saju-health-bg); --c-fg: var(--saju-health-fg); }

.ds-saju-card { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: var(--space-5) var(--space-4); border-top: 6px solid var(--c, var(--saju-brand)); }
.ds-saju-score { display: flex; align-items: baseline; gap: var(--space-1); }
.ds-saju-score__num { font-size: var(--font-size-3xl); font-weight: var(--font-weight-heavy); font-variant-numeric: tabular-nums; line-height: 1; color: var(--c-fg, var(--color-text)); }
.ds-saju-score__max { font-size: var(--font-size-sm); color: var(--color-text-sub); font-weight: var(--font-weight-semibold); }
.ds-saju-card__bar { height: 8px; border-radius: var(--radius-pill); background: var(--color-surface-sunken); margin: var(--space-3) 0 var(--space-4); overflow: hidden; }
.ds-saju-card__bar i { display: block; height: 100%; width: var(--value, 0%); background: var(--c, var(--saju-brand)); border-radius: inherit; }
.ds-saju-card__headline { font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); margin: 0 0 var(--space-2); }
.ds-saju-card__body { font-size: var(--font-size-md); line-height: 1.7; margin: 0 0 var(--space-4); }
.ds-saju-tips { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); counter-reset: tip; }
.ds-saju-tips li { display: flex; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--c-bg, var(--saju-brand-bg)); font-size: var(--font-size-sm); counter-increment: tip; }
.ds-saju-tips li::before { content: counter(tip); flex: none; width: 20px; height: 20px; border-radius: var(--radius-pill); display: grid; place-items: center; background: var(--color-surface); color: var(--c-fg, var(--color-text)); font-weight: var(--font-weight-bold); font-size: var(--font-size-xs); }
.ds-disclaimer { font-size: var(--font-size-xs); color: var(--color-text-sub); text-align: center; }

/* ---------- 23. Skeleton ---------- */
.ds-skeleton {
  display: block; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--color-surface-sunken) 0%, var(--neutral-50) 50%, var(--color-surface-sunken) 100%);
  background-size: 200% 100%; animation: ds-shimmer 1.4s var(--ease-linear) infinite;
}
.ds-skeleton--text { height: 14px; margin: 6px 0; }
.ds-skeleton--title { height: 22px; width: 60%; }
.ds-skeleton--circle { border-radius: var(--radius-pill); }
@keyframes ds-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ds-skeleton { animation: none; } }

/* ---------- 24. Character stage & wrapper ---------- */
.ds-stage {
  position: relative; height: var(--stage-h); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--green-50); margin: 0 calc(var(--page-x) * -1);
}
.ds-stage__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ds-stage__char { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); width: var(--char-size-main); height: var(--char-size-main); }
.ds-stage__bubble { position: absolute; top: var(--space-4); right: var(--space-4); }
.ds-equip-badge { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-pill); background: var(--shop-equip-bg); }
.ds-equip-badge img { width: 18px; height: 18px; }

/* 캐릭터 표정 전환 (계약서 4장 레이어) */
.ds-char .face, .ds-char .fx { display: none; }
.ds-char[data-mood="best"] .face--best, .ds-char[data-mood="best"] .fx--best,
.ds-char[data-mood="good"] .face--good,
.ds-char[data-mood="normal"] .face--normal,
.ds-char[data-mood="sad"] .face--sad, .ds-char[data-mood="sad"] .fx--sad,
.ds-char[data-mood="tired"] .face--tired, .ds-char[data-mood="tired"] .fx--tired { display: inline; }
.ds-char[data-species="plant"][data-mood="tired"] .layer-body { filter: saturate(0.5); }
.ds-char svg { width: 100%; height: 100%; display: block; }
.ds-char--idle svg { animation: ds-idle 2.4s ease-in-out infinite; }
[data-art="pixel"] .ds-char--idle svg { animation-timing-function: steps(2); }
.ds-char--tap svg { animation: ds-tap 400ms var(--ease-pop); }
@keyframes ds-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes ds-tap { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .ds-char svg { animation: none !important; } }
