/* Glow & Calm — components: buttons, cards, nav, dialogs, sheets, toasts, empty states, confetti. */

/* ---------- icons ---------- */
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 10px 20px;
  border: 1.5px solid transparent; border-radius: var(--r-pill);
  font-weight: 500; font-size: var(--fs-md); line-height: 1.2; text-decoration: none;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--button-bg); color: var(--on-button); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--button-bg-hover); }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-soft:hover { background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: var(--on-danger); }


.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: var(--fs-sm); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text);
  transition: background var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- cards & page bits ---------- */
.page-head { margin-bottom: var(--s-6); }
.page-head .eyebrow { display: flex; align-items: center; gap: 6px; color: var(--link); font-size: var(--fs-sm); font-weight: 500; margin-bottom: 6px; }
.page-head p { color: var(--text-muted); margin-top: 6px; }

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: var(--s-5);
  border: 1px solid var(--line);
}
.card + .card, .stack > * + * { margin-top: var(--s-4); }
.card h2 { font-size: var(--fs-lg); margin-bottom: var(--s-2); }
.card-pink { background: linear-gradient(160deg, var(--surface-2), var(--surface)); }

.section-title { font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: var(--s-8) 0 var(--s-3); }

.hint { color: var(--text-muted); font-size: var(--fs-sm); }

/* rows inside a card (settings lists) */
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-2) 0; }
.row + .row { border-top: 1px solid var(--line); }
.row-text { flex: 1; min-width: 0; }
.row-text strong { display: block; font-weight: 500; }
.row-text span { display: block; color: var(--text-muted); font-size: var(--fs-sm); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* segmented control (theme switch) */
.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: var(--r-pill); }
.segmented button {
  min-height: 38px; padding: 6px 14px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text); font-size: var(--fs-sm); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--link); box-shadow: var(--shadow-soft); }


/* storage meter */
.meter { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; margin-top: var(--s-2); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--primary)); min-width: 6px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); font-size: var(--fs-xs); font-weight: 500; }

/* ---------- demo banner ---------- */
.demo-banner {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 12px;
  padding: calc(8px + var(--safe-t)) var(--gutter) 8px;
  background: var(--button-bg); color: var(--on-button);
  font-size: var(--fs-sm); text-align: center;
}
.demo-banner a { color: inherit; font-weight: 600; }
.has-demo .main { padding-top: var(--s-5); }

/* ---------- bottom tab bar (mobile / tablet) ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: var(--surface); /* fallback for iOS < 16.2 */
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(224, 69, 127, .08);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 4px 2px;
  border: 0; border-radius: 18px; background: transparent;
  color: var(--text-muted); font-size: 11px; font-weight: 500; text-decoration: none;
}
.tab .icon { transition: transform var(--t-fast) var(--ease-bounce); }
.tab[aria-current="page"] { color: var(--link); background: var(--tab-active-bg); }
.tab[aria-current="page"] .icon { transform: translateY(-1px) scale(1.08); }


/* ---------- desktop sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  flex-direction: column; gap: var(--s-1);
  padding: var(--s-6) var(--s-4);
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-2) var(--s-5); text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow-soft); }
.brand strong { font-family: var(--font-display); font-variation-settings: 'SOFT' 100; font-weight: 500; font-size: 1.3rem; line-height: 1.1; }
.brand small { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.side-link {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--tap); padding: 8px 12px; border-radius: 14px;
  color: var(--text); text-decoration: none; font-weight: 400;
}
.side-link:hover { background: var(--surface-3); }
.side-link[aria-current="page"] { background: var(--tab-active-bg); color: var(--link); font-weight: 500; }

.side-sep { height: 1px; background: var(--line); margin: var(--s-3) var(--s-2); }

/* ---------- dialogs: modal + bottom sheet ---------- */
dialog.gc-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lift);
  overflow: auto;
}
dialog.gc-dialog::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.gc-dialog[open] { animation: pop-in var(--t-med) var(--ease-bounce); }
.dialog-body { padding: var(--s-6); }
.dialog-body h2 { margin-bottom: var(--s-2); padding-right: var(--s-8); }
.dialog-body > p { color: var(--text-muted); }
.dialog-actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-6); }
.dialog-close { position: absolute; top: 10px; right: 10px; }

dialog.gc-sheet {
  margin: auto auto 0; width: 100%; max-width: 560px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: var(--safe-b);
}
dialog.gc-sheet[open] { animation: sheet-up var(--t-med) var(--ease); }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 10px auto 0; }
@media (min-width: 900px) {
  dialog.gc-sheet { margin: auto; border-radius: var(--r-lg); }
}

@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* "More" sheet grid */
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin-top: var(--s-4); }
.more-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: var(--s-3) var(--s-2);
  border-radius: 20px; background: var(--surface-3); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; text-align: center;
}
.more-item .icon { color: var(--primary-strong); width: 26px; height: 26px; }
.more-item:hover { background: var(--surface-2); }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed; z-index: 60; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 var(--gutter); pointer-events: none;
}
@media (min-width: 900px) { .toast-wrap { bottom: 24px; } }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  max-width: 440px; padding: 12px 14px 12px 18px;
  border-radius: var(--r-pill); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lift); font-size: var(--fs-sm);
  pointer-events: auto; animation: pop-in var(--t-med) var(--ease-bounce);
}
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 600; min-height: 32px; padding: 4px 8px; border-radius: 12px; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all var(--t-fast) var(--ease); }

/* ---------- empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3);
  padding: var(--s-8) var(--s-5);
  border-radius: var(--r-card); background: var(--surface);
  border: 1.5px dashed var(--line-strong);
}
.empty-art { width: 112px; height: 112px; }
.empty p { max-width: 30ch; color: var(--text-muted); }

/* ---------- confetti (CSS only; skipped for reduced motion) ---------- */
.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 3px;
  animation: confetti-fall var(--dur, 2.4s) var(--ease) var(--delay, 0s) forwards;
}
.confetti i.heart { width: 14px; height: 14px; border-radius: 0; background: none !important; }
.confetti i.heart::before { content: '♥'; position: absolute; inset: 0; font-size: 15px; line-height: 14px; color: var(--c); }
@keyframes confetti-fall {
  0% { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0px), 105vh, 0) rotate(var(--rot, 540deg)); opacity: .9; }
}

/* ---------- forms ---------- */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* restore preview */
.count-list { list-style: none; margin: var(--s-4) 0 0; padding: var(--s-3) var(--s-4); background: var(--surface-3); border-radius: var(--r-md); }
.count-list li { display: flex; justify-content: space-between; padding: 4px 0; font-size: var(--fs-sm); }
.count-list li + li { border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---------- micro-interactions ---------- */
@keyframes tick-pop { 0% { transform: scale(.8); } 55% { transform: scale(1.18); } 100% { transform: scale(1.08); } }
@keyframes check-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
.tick.just-ticked { animation: tick-pop 320ms var(--ease-bounce); }
.tick.just-ticked .icon path { stroke-dasharray: 24; animation: check-draw 260ms var(--ease) 60ms both; }
.glass.just-ticked .glass-fill { animation: fill-up 380ms var(--ease); transform-origin: bottom; transform-box: fill-box; }
@keyframes fill-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.btn:focus-visible, .pick:focus-visible, .tick:focus-visible { outline-offset: 3px; }

/* ---------- theme picker ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); margin-top: var(--s-3); }
.theme-tile {
  display: grid; gap: 4px; padding: var(--s-3); text-align: left; min-height: 96px;
  border: 2px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
}
.theme-tile[aria-checked="true"] { border-color: var(--primary-strong); box-shadow: var(--shadow-soft); }
.theme-tile strong { font-weight: 500; font-size: var(--fs-sm); }
.theme-tile small { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.3; }
.theme-swatches { display: flex; }
.theme-swatches i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); margin-right: -6px; box-shadow: 0 0 0 1px var(--line-strong); }
