/* Statistics and its drill-down grid (screens/stats.js).
   Values from Statistics/StatisticsView.swift, StatisticsCharts.swift,
   StatisticsStrip.swift and app/39-44: grouped page (Surface.page, cards
   Surface.card, radius 12, padding 16), sections 24 apart with a caption-caps
   header 16 in, cards 16 apart; near-monochrome (bars primary at 85%, tracks
   at 6%, hairlines at 12%), the accent only on See All. Press = opacity 0.55. */
[data-screen="stats"] {
  --bg: #000; --card: #1c1c1e;
  --st-ink: 255, 255, 255;
  --st-tile: #000;                                  /* TileSurface.garment: Page */
  --seg-bg: rgba(118, 118, 128, 0.24); --seg-on: #636366;
}
@media (prefers-color-scheme: light) {
  [data-screen="stats"] {
    --bg: #f2f2f7; --card: #fff;
    --st-ink: 0, 0, 0;
    --st-tile: #fff;
    --seg-bg: rgba(118, 118, 128, 0.12); --seg-on: #fff;
  }
}
[data-screen="stats"] .page-body { padding-top: calc(var(--safe-top) + var(--bar-h) + 16px); }
[data-screen="stats"] .is-pressed:not(.seg-item) { opacity: 0.55 !important; transform: none !important; }
[data-screen="stats"] a, [data-screen="stats"] button { transition: opacity var(--press); }
.st-in, .st-fade { animation: st-in 0.2s cubic-bezier(0.42, 0, 0.58, 1); }
@keyframes st-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .st-in, .st-fade { animation: none; } }
.st-empty { padding-top: 120px; text-align: center; color: var(--sub); }

.st-sec { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.st-sec-head { padding-left: 16px; font: 500 12.5px/16px var(--text); letter-spacing: 0.05em; text-transform: uppercase; color: var(--sub); }
.st-line { color: var(--sub); font-size: var(--t-sub); }

/* Figures: the head's three, Worn This Month, Value + Per Wear. */
.st-head { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.st-cost { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.app .st-fig { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: 12px; border-radius: var(--r-card); background: var(--card); text-align: left; }
.st-cap { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; font: 500 11.5px/16px var(--text); letter-spacing: 0.03em; text-transform: uppercase; color: var(--sub); white-space: nowrap; }
.st-cap > span { overflow: visible; }
.st-sym { flex: none; width: 17px; height: 17px; stroke-width: 1.6; }
.st-big { max-width: 100%; font: 600 var(--t-large)/34px var(--serif); font-variant-numeric: tabular-nums lining-nums; letter-spacing: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Card anatomy: headline title, optional count, See All. */
.st-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; border-radius: var(--r-card); background: var(--card); }
.st-card-head { display: flex; align-items: baseline; gap: 8px; min-height: 22px; }
.st-card-head h3 { font: 600 var(--t-body)/22px var(--text); letter-spacing: -0.02em; }
.st-count { font: 600 var(--t-body)/22px var(--text); color: var(--sub); font-variant-numeric: tabular-nums; }
.app .st-all { margin-left: auto; padding: 4px 0 4px 12px; margin-top: -4px; margin-bottom: -4px; color: var(--acc-ink); font-size: var(--t-sub); white-space: nowrap; }

/* Colors: the palette bar (28 tall, radius 8, hairline) and its legend chips. */
.st-palette { display: flex; gap: 1px; height: 28px; overflow: hidden; border-radius: var(--r-badge); box-shadow: inset 0 0 0 1px rgba(var(--st-ink), 0.12); }
.st-seg { flex: var(--g, 1) 1 0; min-width: 3px; box-shadow: inset 0 0 0 0.5px rgba(var(--st-ink), 0.12); }
.st-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.st-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: rgba(var(--st-ink), 0.06); font-size: var(--t-foot); line-height: 16px; }
.st-n { color: var(--sub); font-variant-numeric: tabular-nums; }
.st-dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(var(--st-ink), 0.2); }

/* Count bars (Categories, Materials, Brands): label 96 · track 10 · count. */
.st-bars { display: flex; flex-direction: column; }
.st-bar { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: var(--t-sub); }
.st-bar-l { flex: none; width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-track { position: relative; flex: 1; height: 10px; border-radius: 5px; background: rgba(var(--st-ink), 0.06); }
.st-track i { position: absolute; left: 0; top: 0; bottom: 0; width: max(10px, calc(var(--f) * 100%)); border-radius: 5px; background: rgba(var(--st-ink), 0.85); }
.st-bar-n { flex: none; min-width: 24px; text-align: right; color: var(--sub); font-variant-numeric: tabular-nums; }

/* Strips: 84pt tiles on the tile surface, radius 10, 8 apart, bleeding to the card's edges. */
.st-strip { display: flex; gap: 8px; margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.st-strip::-webkit-scrollbar { display: none; }
.st-tile, .st-otile { position: relative; flex: none; display: block; width: 84px; height: 84px; }
.st-tpic.tile-pic { position: absolute; inset: 0; width: 84px; height: 84px; aspect-ratio: auto; border-radius: var(--r-thumb); background: var(--st-tile); overflow: hidden; }
.st-otile { height: 112px; }
.st-opic { position: absolute; inset: 0; overflow: hidden; border-radius: var(--r-card); }
.st-opic.has-tryon img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; display: block; }
.st-badge { position: absolute; right: 4px; bottom: 4px; padding: 2px 8px; border-radius: 999px; background: var(--mat-regular); -webkit-backdrop-filter: blur(12px) saturate(1.6); backdrop-filter: blur(12px) saturate(1.6);
  color: var(--ink); font: 600 var(--t-cap2)/14px var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: 0.01em; }

/* Month charts: plot 122 + labels 18 = the app's 140; y labels trailing; bars primary 85%, radius 3, 70% of a month. */
.st-chart { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 122px 18px; column-gap: 6px; }
.st-plot { position: relative; grid-column: 1; grid-row: 1; }
.st-grid { position: absolute; left: 0; right: 0; bottom: calc(var(--y) * 100%); height: 1px; background: rgba(var(--st-ink), 0.06); }
.st-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); align-items: end; }
.st-col { position: relative; display: flex; justify-content: center; align-items: flex-end; height: 100%; }
.st-col b { display: block; width: 70%; min-height: 1px; border-radius: 3px; background: rgba(var(--st-ink), 0.85); }
.st-y { position: relative; grid-column: 2; grid-row: 1; min-width: 22px; }
.st-y span { position: absolute; right: 0; bottom: calc(var(--y) * 100%); transform: translateY(50%); color: var(--sub); font-size: var(--t-cap); line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-x { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); align-items: end; }
.st-x span { overflow: hidden; text-align: center; color: var(--sub); font-size: var(--t-cap); line-height: 14px; white-space: nowrap; letter-spacing: -0.01em; }
.st-years .st-x span { font-size: 11px; }
/* 100% stacked months: a backing column at 68%, slices at 60%, the first key at the bottom. */
.st-stack { grid-template-columns: minmax(0, 1fr); }
.st-back { position: absolute; left: 16%; right: 16%; top: 0; bottom: 0; border-radius: 2px; background: rgba(var(--st-ink), 0.12); }
.st-slices { position: absolute; left: 20%; right: 20%; top: 1px; bottom: 1px; display: flex; flex-direction: column-reverse; gap: 1px; }
.st-slice { flex: var(--s) 1 0; min-height: 1px; border-radius: 1px; }
.st-key { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: -4px; }
.st-key span { display: inline-flex; align-items: center; gap: 4px; color: var(--sub); font-size: var(--t-cap); }
.st-key .st-dot { width: 10px; height: 10px; box-shadow: inset 0 0 0 1px rgba(var(--st-ink), 0.12); }
[data-screen="stats"] .seg { margin: 0; }
[data-screen="stats"] .demo-line { margin-top: 32px !important; }

/* Drill-down grid: the closet's tile, badge top-leading; outfits three across, 150 tall. */
.sg-grid .badge { left: 4px; right: auto; top: 4px; bottom: auto; }
.sg-outfits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sg-otile { position: relative; display: block; height: 150px; }
.sg-badge { right: auto; bottom: auto; left: 4px; top: 4px; }
.sg-grid .badge { padding: 2px 8px; background: var(--mat-regular); color: var(--ink); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-variant-numeric: tabular-nums; }
/* A 375pt phone: the head's captions shrink to stay on one line (the app's single-line caption scales down). */
@media (max-width: 389px) { .st-head .st-cap { font-size: 10.5px; letter-spacing: 0; gap: 3px; } .st-head .st-sym { width: 15px; height: 15px; } }
.st-otile .ofall, .sg-otile .ofall { right: auto; left: 4px; }
