/* Twinbladez Portfolio — app styles
   Tokens live on :root; dark values are redefined under the OS media query
   (guarded so an explicit light choice wins) and under :root[data-theme="dark"]. */

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --card: #ffffff;
  --card-2: #f4f3f0;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #767570;
  --neutral: #f0efec;
  --border: #e6e5e0;
  --grid: #ebeae6;
  --accent: #2a78d6;
  --on-accent: #ffffff;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;
  /* Gain/loss figures are 13–15 px text, so these must reach 4.5:1 on the page and on a card (docs/DESIGN.md):
     the dataviz status pair #0ca30c / #d03b3b measured 3.3:1 (green on light) and 3.6:1 (red on dark). */
  --good: #006300; /* 7.4:1 on the light page, 7.5:1 on a card */
  --bad: #c43535; /* 5.2:1 on the light page, 5.4:1 on a card (#d03b3b was a bare 4.7:1) */
  --skeleton: #edece8;
  --skeleton-shine: #f9f8f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-float: 0 8px 24px rgba(42, 120, 214, 0.35);
  --backdrop: rgba(10, 10, 10, 0.42);
  --header-bg: rgba(252, 252, 251, 0.86);
  --tabbar-bg: rgba(252, 252, 251, 0.9);
  --toast-bg: #1a1a19;
  --toast-text: #ffffff;

  --gutter: 16px;
  --radius: 16px;
  --radius-sm: 12px;
  --header-h: 52px;
  --tabbar-h: 58px;
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, Roboto, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #121212;
    --card: #1a1a19;
    --card-2: #232322;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --neutral: #383835;
    --border: #272726;
    --grid: #272726;
    --accent: #3987e5;
    --on-accent: #ffffff;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
    --good: #0ca30c; /* 5.6:1 on the dark page, 5.2:1 on a card */
    --bad: #ec5f5f; /* 5.7:1 on the dark page, 5.3:1 on a card; #d03b3b was 3.6:1 */
    --skeleton: #222221;
    --skeleton-shine: #2d2d2b;
    --shadow: none;
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.45);
    --backdrop: rgba(0, 0, 0, 0.62);
    --header-bg: rgba(18, 18, 18, 0.86);
    --tabbar-bg: rgba(18, 18, 18, 0.9);
    --toast-bg: #f3f2ee;
    --toast-text: #0b0b0b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #121212;
  --card: #1a1a19;
  --card-2: #232322;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #8f8e86;
  --neutral: #383835;
  --border: #272726;
  --grid: #272726;
  --accent: #3987e5;
  --on-accent: #ffffff;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --s7: #9085e9;
  --s8: #e66767;
  --good: #0ca30c;
  --bad: #d03b3b;
  --skeleton: #222221;
  --skeleton-shine: #2d2d2b;
  --shadow: none;
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.45);
  --backdrop: rgba(0, 0, 0, 0.62);
  --header-bg: rgba(18, 18, 18, 0.86);
  --tabbar-bg: rgba(18, 18, 18, 0.9);
  --toast-bg: #f3f2ee;
  --toast-text: #0b0b0b;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
svg { display: block; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }

/* ===== Progress bar ===== */
.progress {
  position: fixed; top: var(--sa-top); left: 0; right: 0; height: 2px; z-index: 45;
  opacity: 0; transition: opacity 0.2s; pointer-events: none; overflow: hidden;
}
.progress::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: var(--accent); border-radius: 2px;
  animation: progress-slide 1.1s infinite ease-in-out;
}
.progress.active { opacity: 1; }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ===== Header ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--sa-top);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  height: var(--header-h); max-width: 1024px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 calc(8px + var(--sa-right)) 0 calc(var(--gutter) + var(--sa-left));
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; min-height: 44px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; }
.header-actions { display: flex; align-items: center; gap: 2px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 15px; line-height: 1;
  background: var(--neutral); color: var(--text); text-decoration: none; white-space: nowrap;
  transition: transform 0.12s var(--ease), opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-danger { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius-sm); border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--neutral); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.link-btn svg { width: 18px; height: 18px; }

/* ===== Layout ===== */
.view {
  max-width: 640px; margin: 0 auto;
  padding: 12px calc(var(--gutter) + var(--sa-right)) calc(var(--tabbar-h) + var(--sa-bottom) + 92px) calc(var(--gutter) + var(--sa-left));
  transition: opacity 0.2s;
}
.view.refreshing { opacity: 0.72; }
.view-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 20px 0 8px; }
.section-head h2 { font-size: 17px; font-weight: 600; }
.section-head .muted { font-size: 13px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-top: 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 17px; font-weight: 600; }
.card-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.card.flush { padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ===== Tab bar ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--sa-bottom);
}
.tabbar-inner { display: flex; max-width: 640px; margin: 0 auto; padding: 0 var(--sa-right) 0 var(--sa-left); }
.tab {
  flex: 1; min-height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; text-decoration: none;
  background: none; border: 0; padding: 6px 0; transition: color 0.15s;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ===== FAB ===== */
.fab {
  position: fixed; z-index: 34;
  right: calc(var(--gutter) + var(--sa-right));
  bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-float);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(0.94); }
.fab.hidden { display: none; }
@media (min-width: 700px) {
  .fab { right: calc(50% - 320px + 8px); }
  body[data-tab="home"] .fab { right: calc(50% - 320px + 8px); }
}
@media (min-width: 1060px) {
  body[data-tab="home"] .fab { right: calc(50% - 512px + 8px); }
}

/* ===== Pull to refresh ===== */
.ptr {
  position: fixed; left: 50%; top: calc(var(--sa-top) + var(--header-h) + 6px); z-index: 29;
  width: 40px; height: 40px; margin-left: -20px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; color: var(--text-2);
  opacity: 0; transform: translateY(-56px); transition: transform 0.2s var(--ease), opacity 0.2s;
  pointer-events: none;
}
.ptr svg { width: 20px; height: 20px; transition: transform 0.2s; }
.ptr.visible { opacity: 1; }
.ptr.ready { color: var(--accent); }
.ptr.ready svg { transform: rotate(180deg); }
.ptr.loading svg { animation: spin 0.9s linear infinite; }

/* ===== Hero ===== */
.hero { padding: 6px 0 2px; }
.hero-label { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: 0.02em; text-transform: uppercase; }
.hero-value {
  font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.08;
  font-variant-numeric: tabular-nums; margin: 4px 0 8px; word-break: break-all;
}
.hero-value.masked { font-size: 34px; letter-spacing: 0.08em; color: var(--text-2); }
@media (min-width: 400px) { .hero-value { font-size: 48px; } .hero-value.masked { font-size: 36px; } }
.hero-deltas { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.hero-deltas .delta-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-2); }
.delta-label { color: var(--text-2); font-weight: 400; }
.hero-updated {
  margin: 8px 0 0 -8px; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px;
  color: var(--text-2); font-size: 13px; background: none; border: 0; border-radius: 10px;
}
.hero-updated svg { width: 16px; height: 16px; }
.hero-updated.spinning svg { animation: spin 0.9s linear infinite; }

/* ===== KPI tiles ===== */
.kpi-row {
  display: flex; gap: 10px; overflow-x: auto; margin: 14px calc(-1 * var(--gutter)) 0; padding: 2px var(--gutter) 6px;
  scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.kpi-row::-webkit-scrollbar { display: none; }
.kpi {
  flex: 0 0 auto; min-width: 128px; scroll-snap-align: start;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.kpi-value { font-size: 17px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) {
  .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; margin: 14px 0 0; padding: 0; }
  .kpi { min-width: 0; }
}

/* ===== Dots, pills, chips ===== */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pill {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1;
  background: var(--neutral); color: var(--text-2); white-space: nowrap; flex-shrink: 0;
}
.pill-tint { color: var(--text); }
.pill-warn { background: color-mix(in srgb, var(--s4) 22%, transparent); color: var(--text); }
.pill-bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 4px 0; margin: 0; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--neutral); color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chip::after { content: ""; position: absolute; inset: -4px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }
.chip:focus-visible { outline-offset: 0; }

/* ===== Lists / rows ===== */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 0;
  border: 0; border-top: 1px solid var(--border); background: none; color: inherit; text-align: left; border-radius: 0;
}
.list > .row:first-child, .list > .row-group:first-child .row:first-child { border-top: 0; }
button.row:active { background: color-mix(in srgb, var(--text) 4%, transparent); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; min-width: 0; }
.row-title .name { font-weight: 400; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.row-right { flex-shrink: 0; text-align: right; }
.row-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-delta { font-size: 13px; margin-top: 2px; }
.row-chev { color: var(--text-3); flex-shrink: 0; }
.row-chev svg { width: 18px; height: 18px; }

/* ===== Allocation ===== */
.alloc { display: flex; align-items: center; gap: 20px; }
.alloc-donut { flex-shrink: 0; }
/* On phones the ring and the value column leave the legend names no room ("S…"), so the legend goes under the ring. */
@media (max-width: 439px) {
  .alloc { flex-direction: column; align-items: stretch; gap: 10px; }
  .alloc-donut { align-self: center; }
}
.alloc-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.legend-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; column-gap: 10px; align-items: center;
  min-height: 34px; font-size: 14px;
}
.legend-row .legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .legend-vals { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend-row .legend-pct { color: var(--text-2); font-size: 12px; display: block; }
.legend-row.dim { opacity: 0.5; }
.donut-center-value { font-size: 20px; font-weight: 700; fill: var(--text); }
.donut-center-label { font-size: 11px; font-weight: 600; fill: var(--text-2); letter-spacing: 0.04em; text-transform: uppercase; }
.donut-track { stroke: var(--neutral); }

/* ===== Line chart ===== */
.chart { position: relative; touch-action: pan-y; outline-offset: 4px; border-radius: 8px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid line { stroke: var(--grid); stroke-width: 1; }
.chart-axis text { fill: var(--text-2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-marker { fill: var(--s1); stroke: var(--card); stroke-width: 2; }
.chart-cross line { stroke: var(--text-2); stroke-width: 1; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 96px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.chart-tip strong { display: block; color: var(--text); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: 160px; color: var(--text-2); text-align: center; padding: 16px; font-size: 14px; }
.chart-table { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.chart-table summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.chart-table td { padding: 5px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.chart-table td:last-child { text-align: right; color: var(--text); }
.range-delta { font-size: 13px; margin-top: 2px; }
.chart-filters { margin: -4px 0 10px; }
.chart-filters .chips { padding: 2px 0; }

/* ===== Movers ===== */
.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.movers h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-2); margin-bottom: 4px; }
.mover { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 4px 0; border-top: 1px solid var(--border); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; text-align: left; border-radius: 0; }
.mover:first-of-type { border-top: 0; }
.mover .sym { font-weight: 600; }
.mover .vals { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.mover .vals .muted { display: block; font-size: 12px; }

/* ===== Dashboard grid on wide screens ===== */
@media (min-width: 900px) {
  .view-home { max-width: 1024px; }
  .dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .dash-grid > .card { margin-top: 0; }
  .dash-grid { margin-top: 16px; }
}

/* ===== Holdings ===== */
.toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin: 4px 0 8px; }
/* Account chips wrap onto extra lines instead of scrolling sideways, so every account is visible and tappable
   at any width (a hidden scrollbar and a clipped last chip made accounts hard to reach). */
.toolbar .chips { flex-wrap: wrap; overflow: visible; min-width: 0; row-gap: 8px; }
.toolbar .chip { max-width: 100%; min-width: 0; overflow: hidden; }
.toolbar .sort-wrap { align-self: flex-end; }
.sort-wrap { position: relative; flex-shrink: 0; }
/* 16 px so iOS does not zoom the page on focus; a transparent 4 px border keeps the 36 px pill look inside a 44 px target. */
.sort-select {
  min-height: 44px; padding: 0 28px 0 12px; border-radius: 999px; border: 4px solid transparent; background: var(--neutral); background-clip: padding-box; color: var(--text-2);
  font-size: 16px; font-weight: 600; -webkit-appearance: none; appearance: none; max-width: 168px;
}
.sort-wrap::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); color: var(--text-2); pointer-events: none;
}
.list-summary { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); padding: 6px 2px 2px; font-variant-numeric: tabular-nums; }
.group-head { display: flex; align-items: center; gap: 8px; padding: 14px 0 4px; font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }

/* ===== Accounts ===== */
.acct-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; color: inherit;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  margin-top: 12px; transition: transform 0.12s var(--ease);
}
.acct-card:active { transform: scale(0.99); }
.acct-bar { width: 5px; align-self: stretch; border-radius: 3px; flex-shrink: 0; min-height: 44px; }
.acct-main { flex: 1; min-width: 0; }
.acct-name { font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.acct-kind { font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-right { text-align: right; flex-shrink: 0; }
.acct-value { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.acct-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ===== Settings ===== */
.settings-group { margin-top: 18px; }
.settings-group h2 { font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px 4px; }
.settings-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 16px; }
.setting {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--border);
  width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; text-align: left; border-radius: 0;
}
.setting:first-child { border-top: 0; }
.setting-main { flex: 1; min-width: 0; }
.setting-title { font-weight: 500; }
.setting-desc { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.setting-right { flex-shrink: 0; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
.setting.danger .setting-title { color: var(--bad); }
.segmented { display: inline-flex; background: var(--neutral); border-radius: 10px; padding: 3px; }
/* 320 px phones: the three-way Appearance control is wider than the room left beside its title, so it drops below it. */
@media (max-width: 339px) {
  .setting:has(> .setting-right > .segmented) { flex-wrap: wrap; }
  .setting:has(> .setting-right > .segmented) > .setting-right { flex-basis: 100%; justify-content: flex-end; }
}
.segmented button {
  position: relative; min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600;
}
.segmented button::after { content: ""; position: absolute; inset: -5px 0; } /* 44 px tall target without growing the row */
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.switch {
  position: relative; width: 50px; height: 30px; border-radius: 15px; border: 0; background: var(--neutral); transition: background 0.2s; flex-shrink: 0;
}
.switch::before { content: ""; position: absolute; inset: -7px 0; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.about { font-size: 13px; color: var(--text-2); padding: 12px 0; line-height: 1.5; }
.about strong { color: var(--text); }

/* ===== Forms ===== */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field-hint { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-size: 16px;
  -webkit-appearance: none; appearance: none; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.select-wrap { position: relative; }
.select { padding-right: 40px; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(45deg); pointer-events: none;
}
.textarea { min-height: 150px; padding: 12px 14px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; line-height: 1.5; } /* 16 px: below that iOS zooms the page on focus */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 339px) { .form-row { grid-template-columns: 1fr; gap: 0; } } /* 320 px: two selects side by side clip their text */
.form-error { color: var(--bad); font-size: 14px; font-weight: 500; margin: -4px 0 12px; }
.form-ok { color: var(--good); font-size: 14px; font-weight: 500; margin: 0 0 12px; }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); justify-items: center; gap: 8px; padding: 6px 0; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; flex-shrink: 0; }
.swatch::before { content: ""; position: absolute; inset: -5px; }
.swatch[aria-pressed="true"]::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--text); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 56px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--text-2); }
.inline-actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 4px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--card-2); border-radius: 8px; padding: 10px 12px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.result-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.result-list li { padding: 6px 0; border-top: 1px solid var(--border); }
.result-list li.err { color: var(--bad); }

/* ===== Key-value detail rows ===== */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-top: 1px solid var(--border); font-size: 15px; }
.kv:first-child { border-top: 0; }
.kv dt { color: var(--text-2); font-weight: 400; }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.kv dd .sub { display: block; width: 100%; font-size: 12px; color: var(--text-2); font-weight: 400; }
.detail-hero { padding: 4px 0 12px; }
.detail-hero .sym { font-size: 24px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.detail-hero .name { color: var(--text-2); margin-top: 2px; }
.detail-hero .val { font-size: 30px; font-weight: 700; margin-top: 10px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
dl { margin: 0; }

/* ===== Search ===== */
.search { position: relative; }
.search-results {
  list-style: none; margin: 6px 0 0; padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); max-height: 260px; overflow: auto;
}
.search-results li { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--neutral); }
.search-results .sym { font-weight: 700; flex-shrink: 0; }
.search-results .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 14px; }
.search-status { font-size: 13px; color: var(--text-2); padding: 8px 2px 0; }

/* ===== Sheets ===== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in 0.2s var(--ease);
}
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100dvh - var(--sa-top) - 40px);
  background: var(--card); border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  padding-bottom: var(--sa-bottom); outline: none; box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.25);
  animation: slide-up 0.32s var(--ease);
  will-change: transform;
}
/* The grab bar is the whole strip above the title (touch-action: none, like the header, so a drag is ours, not a pan). */
.sheet-handle { display: flex; justify-content: center; width: 100%; padding: 8px 0 2px; flex-shrink: 0; touch-action: none; cursor: grab; }
.sheet-handle::after { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--neutral); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 20px; flex-shrink: 0; touch-action: none; }
.sheet-head h2 { flex: 1; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sheet-foot .btn { flex: 1; }
.sheet-backdrop.closing { animation: fade-out 0.2s forwards; }
.sheet-backdrop.closing .sheet { animation: slide-down 0.22s forwards var(--ease); }
.sheet-message { color: var(--text-2); font-size: 15px; line-height: 1.5; padding: 4px 0 8px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slide-down { from { transform: translateY(0); } to { transform: translateY(100%); } }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 480px; border-radius: 22px; max-height: calc(100dvh - 48px); animation: scale-in 0.22s var(--ease); padding-bottom: 0; }
  .sheet-backdrop.closing .sheet { animation: fade-out 0.18s forwards; }
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 14px; }
}
@keyframes scale-in { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== Toasts ===== */
.toasts {
  position: fixed; left: 16px; right: 16px; z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 480px; display: flex; align-items: center; gap: 10px;
  background: var(--toast-bg); color: var(--toast-text); padding: 12px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.25s var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.toast-success::before { background: var(--good); }
.toast-error::before { background: var(--bad); }
.toast.leaving { animation: toast-out 0.2s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ===== Empty states ===== */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--neutral); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); margin-bottom: 12px; }
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--text); font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 14px; max-width: 320px; margin: 0 auto; }
.empty .btn { margin-top: 16px; }

/* ===== Skeletons ===== */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-shine) 50%, var(--skeleton) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 8px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-label { width: 90px; height: 12px; margin-top: 12px; }
.sk-hero { width: 70%; height: 44px; margin-top: 12px; }
.sk-line { width: 55%; height: 14px; margin-top: 12px; }
.sk-row { display: flex; gap: 10px; margin-top: 20px; overflow: hidden; }
.sk-tile { flex: 0 0 128px; height: 74px; border-radius: 14px; }
.sk-card { height: 180px; border-radius: var(--radius); margin-top: 14px; }
.sk-card.tall { height: 260px; }
.sk-rowline { height: 56px; border-radius: 10px; margin-top: 10px; }

/* ===== Login page ===== */
.login-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--sa-top)) var(--gutter) calc(24px + var(--sa-bottom)); }
.login { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 88px; height: 88px; border-radius: 24px; margin: 0 auto 18px; box-shadow: var(--shadow-float); }
.login h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login .lede { color: var(--text-2); margin: 6px 0 26px; }
.login form { text-align: left; }
.login .btn { margin-top: 4px; }
.login-foot { margin-top: 22px; font-size: 12px; color: var(--text-3); }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
  .progress::after { width: 100%; }
}
