/* soft-ui.css: "Soft iOS" design system (DESIGN.md Part 2).
   Fonts are not @imported here: each page loads Prompt + Inter with its own <link> tag
   (an @import inside a stylesheet is a second, render-blocking round trip). */

:root {
  --bg: #f5f5f7; --surface: #ffffff; --fill: #f2f2f4; --line: #e5e5ea;
  --text: #1a1b26; --text-2: #6e6e73; --text-3: #9a9aa0;
  --ink: #1a1b26; --on-ink: #ffffff; --accent: #C65170;
  --font: 'Prompt', 'Inter', system-ui, sans-serif; --font-num: 'Inter', system-ui, sans-serif;
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-sm: 0 1px 2px rgba(26,27,38,.04), 0 4px 14px rgba(26,27,38,.04);
  --tint: 14%;      /* icon tile background strength */
  --tint-fg: 0%;    /* how much white to mix into tinted text (dark mode raises it) */
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #26263f; --surface: #303050; --fill: #40406a; --line: #50507a;
  --text: #eeeef5; --text-2: #a8a8bc; --text-3: #9898b8;
  --ink: #e4e4f2; --on-ink: #1a1b26; --accent: #e0738f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2), 0 4px 14px rgba(0,0,0,.2);
  --tint: 22%; --tint-fg: 45%; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #26263f; --surface: #303050; --fill: #40406a; --line: #50507a;
    --text: #eeeef5; --text-2: #a8a8bc; --text-3: #9898b8;
    --ink: #e4e4f2; --on-ink: #1a1b26; --accent: #e0738f;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.2), 0 4px 14px rgba(0,0,0,.2);
    --tint: 22%; --tint-fg: 45%; color-scheme: dark;
  }
}

body { background: var(--bg); color: var(--text); font-family: var(--font); margin: 0; -webkit-font-smoothing: antialiased; }

/* tinted colour helpers: set --c on the element */
.ui-ic, .ui-chip, .ui-meta { --c-fg: color-mix(in srgb, var(--c, var(--text)) calc(100% - var(--tint-fg)), #fff); }

/* ── Layout ─────────────────────────────────────────── */
.ui-label { font-size: 13px; font-weight: 800; color: var(--text); margin: 20px 2px 10px; }
.ui-label:first-child { margin-top: 4px; }
.ui-lead { font-size: 13.5px; line-height: 1.6; color: var(--text-2); margin: 0 2px 14px; }
.ui-note { font-size: 12px; line-height: 1.55; color: var(--text-3); }
.ui-card { background: var(--fill); border-radius: var(--r-lg); padding: 16px; }
.ui-card-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.ui-card-title .ui-aside { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--text-3); font-family: var(--font-num); }
.ui-stack { display: flex; flex-direction: column; gap: 10px; }

/* ── Icon tile ──────────────────────────────────────── */
.ui-ic { width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: var(--c-fg); background: color-mix(in srgb, var(--c, var(--text)) var(--tint), transparent); }
.ui-ic.sm { width: 32px; height: 32px; border-radius: var(--r-sm); }
.ui-ic.lg { width: 56px; height: 56px; border-radius: 18px; }
.ui-ic b { font: 900 13px var(--font-num); }

/* ── Grouped list (settings style) ──────────────────── */
.ui-list { background: var(--fill); border-radius: var(--r-lg); overflow: hidden; }
.ui-item { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 14px; box-sizing: border-box; position: relative;
  width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; }
.ui-item + .ui-item::before { content: ''; position: absolute; top: 0; left: 64px; right: 0; height: 1px; background: var(--line); }
button.ui-item, a.ui-item { cursor: pointer; text-decoration: none; }
button.ui-item:active, a.ui-item:active { background: color-mix(in srgb, var(--text) 5%, transparent); }
.ui-item-text { flex: 1; min-width: 0; }
.ui-item-title { font-size: 14px; font-weight: 700; color: var(--text); }
.ui-item-desc { font-size: 12px; line-height: 1.45; color: var(--text-3); margin-top: 1px; }
.ui-chev { color: var(--text-3); flex-shrink: 0; }

/* ── Separate rows (feature lists) ──────────────────── */
.ui-rows { display: flex; flex-direction: column; gap: 8px; }
.ui-row { display: flex; align-items: center; gap: 12px; background: var(--fill); border-radius: 16px; padding: 12px 14px; }
.ui-row-title { font-size: 13.5px; font-weight: 800; color: var(--text); }
.ui-row-desc { font-size: 12px; line-height: 1.5; color: var(--text-2); margin-top: 1px; }

/* ── Toggle ─────────────────────────────────────────── */
.ui-toggle { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.ui-toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.ui-toggle span { position: absolute; inset: 0; border-radius: 28px; background: var(--line); transition: background .2s var(--ease); }
.ui-toggle span::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.ui-toggle input:checked + span { background: var(--ink); }
.ui-toggle input:checked + span::before { transform: translateX(18px); background: var(--on-ink); }
.ui-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Stats, bars, chips ─────────────────────────────── */
.ui-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ui-stats.three { grid-template-columns: repeat(3, 1fr); }
.ui-stat { background: var(--fill); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-stat .ui-ic { width: 30px; height: 30px; border-radius: 9px; }
.ui-stat b { font: 900 22px/1 var(--font-num); color: var(--text); }
.ui-stat b small { font-size: 13px; font-weight: 700; color: var(--text-3); }
.ui-stat > span:not(.ui-ic) { font-size: 11.5px; line-height: 1.3; color: var(--text-3); }
.ui-stats.three .ui-stat { align-items: center; text-align: center; }

.ui-bar-row + .ui-bar-row { margin-top: 12px; }
.ui-bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.ui-bar-top span:last-child { font: 700 11.5px var(--font-num); color: var(--text-3); }
.ui-bar { height: 8px; border-radius: 8px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.ui-bar > i { display: block; height: 100%; border-radius: 8px; background: var(--c, var(--accent)); }

.ui-chip, .ui-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  color: var(--c-fg); background: color-mix(in srgb, var(--c, var(--text)) 13%, transparent); }

/* ── Buttons ────────────────────────────────────────── */
.ui-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; box-sizing: border-box; margin: 0;
  padding: 14px 18px; border: 0; border-radius: var(--r-md); font: 700 15px/1.2 var(--font); text-decoration: none; cursor: pointer;
  background: var(--ink); color: var(--on-ink); transition: transform .15s var(--ease), background-color .15s var(--ease); }
.ui-btn:hover { background: color-mix(in srgb, var(--ink) 88%, var(--surface)); }
.ui-btn:active { transform: scale(0.98); }
.ui-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.ui-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-btn.soft { background: var(--fill); color: var(--text); }
.ui-btn.soft:hover { background: color-mix(in srgb, var(--text) 8%, var(--fill)); }
.ui-btn.danger { background: var(--accent); color: #fff; }
.ui-btn.text { background: none; color: var(--text-3); font-size: 13px; font-weight: 600; padding: 8px; text-decoration: underline; }
.ui-btn.sm { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 12px; flex-shrink: 0; }
.ui-btn-row { display: flex; gap: 8px; } .ui-btn-row > .ui-btn { flex: 1; }
.ui-round { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--fill); color: var(--text-3); cursor: pointer; }
.ui-round:hover { color: var(--text); background: var(--line); }

/* ── Forms ──────────────────────────────────────────── */
.ui-field { display: flex; flex-direction: column; gap: 6px; }
.ui-field + .ui-field { margin-top: 12px; }
.ui-field > label { font-size: 12.5px; font-weight: 700; color: var(--text); margin-left: 2px; }
.ui-input { width: 100%; box-sizing: border-box; margin: 0; padding: 13px 15px; border: 1.5px solid transparent; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: 15px var(--font); outline: none; }
.ui-card .ui-input { background: var(--surface); }
.ui-input.on-surface { background: var(--fill); }
textarea.ui-input { min-height: 120px; resize: vertical; line-height: 1.55; }
.ui-input:focus { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 8%, transparent); }
.ui-input::placeholder { color: var(--text-3); }

.ui-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ui-choice { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 16px; cursor: pointer;
  background: var(--fill); border: 2px solid transparent; transition: border-color .15s, background .15s; }
.ui-choice input { position: absolute; opacity: 0; pointer-events: none; }
.ui-choice b { font-size: 14px; font-weight: 800; color: var(--text); }
.ui-choice small { font-size: 11.5px; line-height: 1.4; color: var(--text-3); }
.ui-choice:has(input:checked) { border-color: var(--c, var(--text)); background: color-mix(in srgb, var(--c, var(--text)) 8%, var(--surface)); }
.ui-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.ui-seg { display: flex; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--fill); }
.ui-seg button { flex: 1; margin: 0; padding: 9px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-3);
  font: 700 13px var(--font); cursor: pointer; }
.ui-seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Hero, ring, empty state ────────────────────────── */
.ui-hero { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r-xl); position: relative; overflow: hidden;
  background: linear-gradient(140deg, #1a1b26, #34365a); color: #fff; }
.ui-hero.warm { background: linear-gradient(140deg, #fff3df, #ffe2c2); color: #5a3a10; }
.ui-hero.rose { background: linear-gradient(140deg, #fde4ea, #f9cdd8); color: #6e1f36; }
.ui-hero.mint { background: linear-gradient(140deg, #e9f7e4, #d3efc9); color: #1f4a1a; }
:root[data-theme="dark"] .ui-hero.warm { background: linear-gradient(140deg, #4a3a32, #5a4030); color: #f5d2a8; }
:root[data-theme="dark"] .ui-hero.rose { background: linear-gradient(140deg, #4a2f3a, #5a3242); color: #f6c3d0; }
:root[data-theme="dark"] .ui-hero.mint { background: linear-gradient(140deg, #2f4a34, #2f5636); color: #cfeac8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ui-hero.warm { background: linear-gradient(140deg, #4a3a32, #5a4030); color: #f5d2a8; }
  :root:not([data-theme="light"]) .ui-hero.rose { background: linear-gradient(140deg, #4a2f3a, #5a3242); color: #f6c3d0; }
  :root:not([data-theme="light"]) .ui-hero.mint { background: linear-gradient(140deg, #2f4a34, #2f5636); color: #cfeac8; }
}
.ui-hero-k { font-size: 12px; font-weight: 700; opacity: .8; }
.ui-hero-title { font-size: 22px; font-weight: 800; line-height: 1.25; }
.ui-hero p { margin: 2px 0 0; font-size: 12.5px; line-height: 1.45; opacity: .8; }

.ui-ring { position: relative; width: 76px; height: 76px; flex-shrink: 0; color: var(--c, var(--accent)); }
.ui-ring svg { display: block; transform: rotate(-90deg); }
.ui-ring circle { fill: none; stroke-width: 8; }
.ui-ring .track { stroke: color-mix(in srgb, currentColor 18%, transparent); }
.ui-ring .value { stroke: currentColor; stroke-linecap: round; stroke-dasharray: 188.5; stroke-dashoffset: calc(188.5 * (1 - var(--p, 0))); transition: stroke-dashoffset .5s var(--ease); }
.ui-ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 11px var(--font-num); color: inherit; }
.ui-ring b { font-size: 20px; font-weight: 900; }

.ui-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 16px; }
.ui-empty b { font-size: 15px; font-weight: 800; color: var(--text); }
.ui-empty span:not(.ui-ic) { font-size: 12.5px; line-height: 1.5; color: var(--text-3); max-width: 260px; }

/* ── Sheet (bottom sheet on phones, centred dialog on computers) ── */
.ui-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: flex-end; justify-content: center;
  background: rgba(26,27,38,.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.ui-overlay.open { display: flex; }
.ui-sheet { width: 100%; max-width: 640px; max-height: 88dvh; display: flex; flex-direction: column; overflow: hidden;
  border-radius: 28px 28px 0 0; background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 -10px 40px rgba(26,27,38,.12); animation: ui-up .35s var(--ease) both; }
.ui-handle { width: 36px; height: 4px; margin: 12px auto 0; border-radius: 4px; background: var(--line); flex-shrink: 0; }
.ui-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px 10px; flex-shrink: 0; }
.ui-sheet-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ui-sheet-title { font-size: 17px; font-weight: 800; color: var(--text); }
.ui-sheet-body { overflow-y: auto; padding: 4px 24px calc(24px + env(safe-area-inset-bottom)); flex: 1; min-height: 0; }
@media (min-width: 680px) {
  .ui-overlay { align-items: center; padding: 24px; }
  .ui-sheet { border-radius: 28px; max-height: 85dvh; }
  .ui-handle { display: none; }
}
@keyframes ui-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.ui-dialog-icon { width: 56px; height: 56px; border-radius: 50%; margin: 4px auto 2px; display: flex; align-items: center; justify-content: center;
  color: var(--c, var(--text)); background: color-mix(in srgb, var(--c, var(--text)) 12%, transparent); }
.ui-dialog-title { font-size: 18px; font-weight: 800; color: var(--text); text-align: center; }
.ui-dialog-msg { font-size: 13.5px; line-height: 1.55; color: var(--text-2); text-align: center; margin-bottom: 6px; }

/* ── Tiles (home / menu grid) ───────────────────────── */
.ui-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ui-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: var(--r-lg); text-align: left;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; font: inherit; color: inherit; text-decoration: none;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.ui-tile .ui-ic { margin-bottom: 10px; }
.ui-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.ui-tile:active { transform: scale(.97); }
.ui-tile-title { font-size: 14px; font-weight: 800; color: var(--text); }
.ui-tile-sub { font-size: 11.5px; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  .ui-sheet, .ui-ring .value, .ui-btn, .ui-tile { animation: none; transition: none; }
}
