/* Cowork iOS dark design tokens — shared by mini-app shell and cowork report HTML.
   Pages are SSR'd as standalone documents; this file is the single source of truth
   for color / typography / card / metric tokens. */

:root {
  --bg: #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --text: #fff;
  --text-2: #ebebf599;
  --text-3: #ebebf566;
  --green: #30d158;
  --yellow: #ffd60a;
  --red: #ff453a;
  --orange: #ff9f0a;
  --blue: #0a84ff;
  --cyan: #64d2ff;
  --teal: #40c8e0;
  --purple: #bf5af2;
  --indigo: #5e5ce6;
  --pink: #ff375f;
  --separator: #38383a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.container { max-width: 480px; margin: 0 auto; padding: 16px 16px 96px; }

/* Headers */
.page-header { padding: 12px 4px 16px; }
.page-header .label { color: var(--text-3); font-size: 13px; letter-spacing: 0.5px; text-transform: uppercase; }
.page-header .title { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-top: 2px; line-height: 1.15; }
.page-header .subtitle { color: var(--text-2); font-size: 13px; margin-top: 6px; line-height: 1.5; }

.section-title { font-size: 13px; color: var(--text-3); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin: 24px 4px 8px; }

/* Cards */
.card {
  background: var(--surface); border-radius: 16px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.04);
}
.card.compact { padding: 12px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header .title { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.card-header .ic { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #000; }
.card-header .ic.indigo { background: var(--indigo); color: #fff; }
.card-header .ic.green { background: var(--green); }
.card-header .ic.red { background: var(--red); }
.card-header .ic.purple { background: var(--purple); color: #fff; }
.card-header .ic.orange { background: var(--orange); }
.card-header .ic.blue { background: var(--blue); color: #fff; }

/* Badges */
.badge { font-size: 11px; padding: 3px 8px; border-radius: 8px; font-weight: 600; letter-spacing: 0.3px; }
.badge-green { background: rgba(48, 209, 88, 0.18); color: var(--green); }
.badge-yellow { background: rgba(255, 214, 10, 0.18); color: var(--yellow); }
.badge-red { background: rgba(255, 69, 58, 0.18); color: var(--red); }
.badge-blue { background: rgba(10, 132, 255, 0.18); color: var(--blue); }
.badge-purple { background: rgba(191, 90, 242, 0.18); color: var(--purple); }
.badge-gray { background: var(--surface-3); color: var(--text-2); }

/* Metric tiles */
.metrics { display: grid; gap: 10px; }
.metrics.cols-2 { grid-template-columns: 1fr 1fr; }
.metrics.cols-3 { grid-template-columns: repeat(3, 1fr); }
.metrics.cols-4 { grid-template-columns: repeat(4, 1fr); }
.metric { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.metric.tight { padding: 10px; }
.metric .label { font-size: 11px; color: var(--text-3); letter-spacing: 0.4px; text-transform: uppercase; }
.metric .value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.metric.sm .value { font-size: 17px; }
.metric .value .unit { font-size: 12px; color: var(--text-2); font-weight: 500; margin-left: 2px; }
.metric .sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.metric.green .value { color: var(--green); }
.metric.yellow .value { color: var(--yellow); }
.metric.red .value { color: var(--red); }
.metric.center { text-align: center; }

/* Hero (large stat) */
.hero { display: flex; align-items: baseline; gap: 8px; }
.hero .num { font-size: 38px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero .unit { font-size: 14px; color: var(--text-2); }
.hero .delta { margin-left: auto; font-size: 12px; font-weight: 600; }
.hero .delta.up { color: var(--red); }
.hero .delta.down { color: var(--green); }
.hero .delta.flat { color: var(--text-3); }

/* CTA buttons */
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(135deg, var(--purple), var(--indigo));
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 16px rgba(191, 90, 242, 0.25);
}
.cta.compact { padding: 10px 14px; font-size: 13px; border-radius: 10px; }
.cta.subtle {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
}
.cta .arrow { color: var(--text-3); font-size: 13px; }

/* Hint banner */
.highlight {
  background: linear-gradient(135deg, rgba(94, 92, 230, 0.22), rgba(191, 90, 242, 0.22));
  border: 1px solid rgba(191, 90, 242, 0.35);
  border-radius: 12px; padding: 12px 14px; margin-top: 12px;
}
.highlight .label { font-size: 11px; color: var(--purple); font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.highlight .text { font-size: 14px; margin-top: 4px; line-height: 1.45; }

/* Empty state */
.empty { text-align: center; color: var(--text-3); padding: 48px 16px; font-size: 13px; }

/* Bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  padding: 6px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; font-size: 10px; color: var(--text-3); font-weight: 500;
}
.tabbar a .icon { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--blue); }

/* Common helpers */
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--separator); margin: 12px 0; }
.divider-thin { height: 0.5px; background: var(--separator); }

/* Sleep stages (cowork-style stacked bars) */
.sleep-times { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.sleep-times .item { display: inline-flex; gap: 4px; align-items: baseline; font-variant-numeric: tabular-nums; }
.sleep-times .item .v { color: var(--text-2); }

.stage-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.stage {
  display: grid;
  grid-template-columns: 36px 1fr 64px 32px;
  gap: 10px; align-items: center;
}
.stage .name { font-size: 12px; color: var(--text-2); }
.stage .bar-wrap { background: var(--surface-2); height: 8px; border-radius: 4px; overflow: hidden; }
.stage .bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.stage .v { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; color: var(--text); }
.stage .pct { font-size: 11px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.stage.deep .bar { background: var(--indigo); }
.stage.core .bar { background: var(--blue); }
.stage.rem .bar  { background: var(--cyan); }
.stage.awake .bar { background: var(--orange); }

.stage .bar { min-width: 2px; }

/* Daily-report-style compact comparison row */
.compare-row {
  display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 4px;
  padding-top: 12px; margin-top: 12px;
  border-top: 0.5px solid var(--separator);
}
.compare-row .col { text-align: center; }
.compare-row .col .head { font-size: 10px; color: var(--text-3); letter-spacing: 0.3px; }
.compare-row .col .num { font-size: 14px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.compare-row .col.now .num { color: var(--green); }
.compare-row .col.warn .num { color: var(--yellow); }
.compare-row .col.bad .num { color: var(--red); }

/* Single inline flag (one line, ellipsis) */
.inline-flag {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--separator);
  font-size: 12px; color: var(--text-2);
}
.inline-flag .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.inline-flag .dot.green  { background: var(--green); }
.inline-flag .dot.yellow { background: var(--yellow); }
.inline-flag .dot.red    { background: var(--red); }
.inline-flag .text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-flag .more { color: var(--text-3); font-size: 11px; flex-shrink: 0; }

/* Compact bottom link (e.g. "→ 详情") */
.card-link {
  display: block; margin-top: 10px; padding-top: 10px;
  border-top: 0.5px solid var(--separator);
  font-size: 12px; color: var(--blue); text-align: right;
}

/* Chart container */
.chart-wrap { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; font-size: 11px; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
