@font-face {
  font-family: "Source Serif 4 Web";
  src: url("/chat/fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
  unicode-range: U+0000-024F, U+2000-206F, U+20AC, U+2122;
}

/* Same tokens as chat.css, so the home page and the chat page read as one product. */
:root {
  --bg: #FFFFFF;
  --side: #FAFAFA;
  --card: #FFFFFF;
  --line: #E6E6E6;
  --line-soft: #EBEBEB;
  --line-strong: #D4D4D4;
  --fg: #141413;
  --body: #262624;
  --dim: #5E5E5B;
  --faint: #73736F;
  --hover: #EFEFEE;
  --selected: #E1E1E1;
  --pill: #F5F5F5;
  --accent: #C6613F;
  --accent-hover: #B25535;
  --accent-soft: #F7EAE4;
  --on-accent: #FFFFFF;
  --ok: #2F7D4F;
  --warn: #A86A12;
  --danger: #B3402F;
  --track: #EDEDEC;
  --heat-ok: #2F7D4F; --heat-warn: #C98A1E; --heat-bad: #B3402F; --heat-none: #EFEFEE;
  --solid: #141413;
  --on-solid: #FFFFFF;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 20px rgba(0, 0, 0, .04);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, .05), 0 12px 32px rgba(0, 0, 0, .1);
  --serif: "Source Serif 4 Web", Georgia, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, "Microsoft YaHei", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #000000; --side: #0B0B0B; --card: #141414; --line: #262626; --line-soft: #1E1E1E; --line-strong: #3A3A3A;
    --fg: rgba(255, 255, 255, .93); --body: rgba(255, 255, 255, .93); --dim: rgba(255, 255, 255, .6); --faint: rgba(255, 255, 255, .47);
    --hover: #1C1C1C; --selected: #262626; --pill: #161616;
    --accent: #D97757; --accent-hover: #E38867; --accent-soft: #2A1A13;
    --ok: #6FC08F; --warn: #E3B160; --danger: #E07A66; --track: #262626;
    --heat-ok: #3FA868; --heat-warn: #E0A82E; --heat-bad: #E5533F; --heat-none: #1E1E1E;
    --solid: rgba(255, 255, 255, .93); --on-solid: #000000;
    --shadow-card: 0 0 0 1px #262626; --shadow-pop: 0 0 0 1px #2C2C2C, 0 12px 32px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #000000; --side: #0B0B0B; --card: #141414; --line: #262626; --line-soft: #1E1E1E; --line-strong: #3A3A3A;
  --fg: rgba(255, 255, 255, .93); --body: rgba(255, 255, 255, .93); --dim: rgba(255, 255, 255, .6); --faint: rgba(255, 255, 255, .47);
  --hover: #1C1C1C; --selected: #262626; --pill: #161616;
  --accent: #D97757; --accent-hover: #E38867; --accent-soft: #2A1A13;
  --ok: #6FC08F; --warn: #E3B160; --danger: #E07A66; --track: #262626;
    --heat-ok: #3FA868; --heat-warn: #E0A82E; --heat-bad: #E5533F; --heat-none: #1E1E1E;
  --solid: rgba(255, 255, 255, .93); --on-solid: #000000;
  --shadow-card: 0 0 0 1px #262626; --shadow-pop: 0 0 0 1px #2C2C2C, 0 12px 32px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* ---------------------------------------------------------------- sidebar */
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px; background: var(--side); border-right: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px; font: 500 25px/1 var(--serif); letter-spacing: -.015em; }
.brand .spark { width: 22px; height: 22px; stroke: none; }

.user { position: relative; margin: 14px 0 18px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left;
  transition: background .12s;
}
.user-chip:hover, .user-chip[aria-expanded=true] { background: var(--hover); }
.avatar {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--solid); color: var(--on-solid); font-size: 13px; font-weight: 600;
}
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 16px; height: 16px; color: var(--faint); flex: none; }
.login-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); transition: background .12s;
}
.login-chip[hidden], .user-chip[hidden] { display: none; }
.login-chip:hover { background: var(--hover); }
.login-chip .avatar svg { width: 16px; height: 16px; }
.anon .head-actions .btn.ghost { display: none; }

.menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  padding: 6px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-pop);
  border: 1px solid var(--line-soft);
}
.menu-card { margin: 0; padding: 8px 10px 6px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.menu-card dt { color: var(--dim); }
.menu-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line-soft); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; font-size: 14px; text-align: left;
}
.menu-item svg { width: 17px; height: 17px; color: var(--dim); }
.menu-item:hover { background: var(--hover); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }

.families { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--body);
  font-size: 14px; font-weight: 450; text-align: left; transition: background .12s;
}
.nav-item > svg { width: 18px; height: 18px; color: var(--dim); }
.nav-item:hover { background: var(--hover); }
.nav-item.on { background: var(--selected); color: var(--fg); font-weight: 500; }
.nav-item .n { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.mark {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--pill); border: 1px solid var(--line-soft); font: 600 11px/1 var(--sans); color: var(--dim);
}
.mark.claude { background: var(--accent-soft); border-color: transparent; }
.mark .spark { width: 14px; height: 14px; stroke: none; }

.sec-title { padding: 18px 10px 4px; font-size: 12px; color: var(--faint); font-weight: 500; }

.cta {
  display: flex; align-items: center; gap: 10px; margin: 16px 2px 0; padding: 12px;
  border-radius: 14px; background: var(--accent); color: var(--on-accent); transition: background .15s;
}
.cta:hover { background: var(--accent-hover); }
.cta + .cta { margin-top: 8px; }
/* Plan and credit packs sit at the bottom of the sidebar, above the footer line. */
.side-bottom { margin-top: auto; padding-top: 16px; }
.side-bottom .cta:first-child { margin-top: 0; }
.cta.ghost { background: var(--card); color: var(--fg); border: 1px solid var(--line); }
.cta.ghost:hover { background: var(--hover); }
.cta-icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .18); }
.cta.ghost .cta-icon { background: var(--accent-soft); color: var(--accent); }
.cta-icon svg { width: 17px; height: 17px; }
.cta-text { display: flex; flex-direction: column; min-width: 0; }
.cta-title { font-size: 14px; font-weight: 600; }
.cta-sub { font-size: 12px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cta.ghost .cta-sub { color: var(--dim); opacity: 1; }

.side-foot { padding: 14px 10px 0; font: 11px/1.4 var(--mono); color: var(--faint); }

/* ------------------------------------------------------------------- main */
.main { min-width: 0; padding: 28px 36px 64px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; min-height: 36px; }
.greet { margin: 0; font: 400 28px/1.25 var(--serif); letter-spacing: -.01em; }
.head-actions { margin-left: auto; display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 10px;
  font-size: 14px; font-weight: 500; border: 1px solid var(--line); background: var(--card); white-space: nowrap;
  transition: background .12s;
}
.btn:hover { background: var(--hover); }
.btn.solid { background: var(--solid); color: var(--on-solid); border-color: var(--solid); }
.btn.solid:hover { opacity: .88; background: var(--solid); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--fg); }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-toggle { display: none; }

.notice {
  display: flex; gap: 12px; margin-bottom: 24px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-card);
}
.notice-icon { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--accent); }
.notice ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; line-height: 22px; color: var(--body); }

/* Status heat map: one row per model, one cell per clock hour (validated status steps, labelled legend + tooltip). */
.heat {
  position: relative; margin-bottom: 24px; padding: 16px 18px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-card);
}
.heat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.heat-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.heat-head h2 span { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--faint); }
.heat-legend { display: flex; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--dim); }
.heat-legend li { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--heat-none); }
.heat-rows { display: grid; grid-template-columns: 76px 1fr; gap: 6px 12px; align-items: center; }
.heat-name { font-size: 13px; color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heat-cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.cell { height: 22px; border-radius: 4px; background: var(--heat-none); }
.cell.ok, .heat-legend i.ok { background: var(--heat-ok); }
.cell.warn, .heat-legend i.warn { background: var(--heat-warn); }
.cell.bad, .heat-legend i.bad { background: var(--heat-bad); }
.cell.now { box-shadow: inset 0 0 0 1.5px var(--fg); }
.cell:hover { filter: brightness(1.12); }
.heat-axis { grid-column: 2; display: flex; justify-content: space-between; font: 11px/16px var(--mono); color: var(--faint); }
.heat-tip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 150px; padding: 8px 10px;
  border-radius: 8px; background: var(--card); border: 1px solid var(--line-soft); box-shadow: var(--shadow-pop);
  font-size: 12px; line-height: 18px; color: var(--body); transform: translate(-50%, calc(-100% - 8px));
}
.heat-tip b { display: block; color: var(--fg); font-weight: 600; }
.heat-tip .st { display: inline-flex; align-items: center; gap: 5px; }
.heat-tip .st i { width: 8px; height: 8px; border-radius: 2px; background: var(--heat-none); }
.heat-tip .st i.ok { background: var(--heat-ok); }
.heat-tip .st i.warn { background: var(--heat-warn); }
.heat-tip .st i.bad { background: var(--heat-bad); }

.filters { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.chip {
  height: 34px; padding: 0 14px; border: 1px solid transparent; border-radius: 999px; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--dim); transition: background .12s, color .12s;
}
.chip:hover { background: var(--hover); color: var(--fg); }
.chip.on { background: var(--solid); color: var(--on-solid); }
.chip .count { margin-left: 4px; font-size: 12px; opacity: .65; font-variant-numeric: tabular-nums; }
.health {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 999px; background: var(--pill); font-size: 13px; color: var(--dim);
}
.health i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.health.ok i { background: var(--ok); }
.health.warn i { background: var(--warn); }
.health.bad i { background: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1700px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1366px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px 18px 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: left;
  box-shadow: var(--shadow-card); transition: border-color .15s, box-shadow .15s, transform .15s var(--ease);
  animation: rise .35s var(--ease) both;
}
.card.best { overflow: hidden; }
/* 推荐: a ribbon across the top-left corner, clear of the icon and of the plan badge on the right. */
.ribbon {
  position: absolute; top: 6px; left: -30px; width: 80px; height: 16px; transform: rotate(-45deg);
  background: var(--accent); color: var(--on-accent); font: 600 10px/16px var(--sans); letter-spacing: .12em; text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18); pointer-events: none;
}
.card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-card); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
:root[data-motion=reduce] .card { animation: none; }
@media (prefers-reduced-motion: reduce) { .card { animation: none; transition: none; } }

.card-head { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.card-head .mark { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.card-head .mark .spark { width: 17px; height: 17px; }
.card-name { flex: 1; min-width: 0; font: 500 14px/18px var(--sans); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.card-name.email { display: flex; flex-direction: column; -webkit-line-clamp: unset; }
.card-name.email > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name.email small { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--faint); }
.badge { flex: none; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 18px; background: var(--pill); color: var(--dim); border: 1px solid var(--line-soft); }
.badge.pick { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--faint); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--danger); }
.meta-right { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bar { height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--faint); }
.bar i.ok { background: var(--ok); }
.bar i.warn { background: var(--warn); }
.bar i.bad { background: var(--danger); }

.card-foot { display: flex; justify-content: space-between; font: 11px/16px var(--mono); color: var(--faint); }
.card-foot b { color: var(--fg); font-weight: 600; }

.skeleton { height: 133px; border-radius: 16px; background: var(--pill); animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .5; } }
.empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--dim); }

/* ------------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, .35); }
.modal[hidden] { display: none; }
:root[data-theme=dark] .modal { background: rgba(0, 0, 0, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .modal { background: rgba(0, 0, 0, .5); } }
.modal-card {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 26px 28px 24px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-pop); border: 1px solid var(--line-soft);
}
.modal-card h2 { margin: 0 0 14px; font: 400 24px/1.3 var(--serif); }
.modal-close { position: absolute; top: 14px; right: 14px; }
.help-list { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; line-height: 22px; color: var(--body); }
.help-list b { color: var(--fg); font-weight: 600; }

.backdrop { display: none; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1024px) {
  .app { grid-template-columns: 200px 1fr; }
  .main { padding: 24px 24px 48px; }
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 50; top: 0; left: 0; width: 272px; max-width: 82vw; height: 100dvh;
    transform: translateX(-100%); transition: transform .25s var(--ease);
  }
  .app.open .side { transform: none; box-shadow: var(--shadow-pop); }
  .backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .3); }
  .app.open .backdrop { display: block; }
  .menu-toggle { display: grid; margin-left: -8px; }
  .main { padding: 14px 18px 40px; }
  .head { margin-bottom: 18px; gap: 8px; }
  .greet { font-size: 22px; }
  .head-actions .btn.ghost { display: none; }
  .notice { padding: 14px; margin-bottom: 18px; }
  .notice ul { font-size: 13px; line-height: 20px; }
  .filters { margin-bottom: 16px; gap: 4px; }
  .heat { padding: 14px; margin-bottom: 18px; }
  .heat-rows { grid-template-columns: 66px 1fr; gap: 6px 8px; }
  .heat-cells { gap: 1.5px; }
  .cell { height: 18px; border-radius: 3px; }
  .heat-legend { gap: 10px; }
  .chip, .health { height: 32px; padding: 0 12px; font-size: 12px; }
  .card { padding: 14px 14px 12px; gap: 10px; }
}
@media (max-width: 480px) {
  .main { padding: 12px 16px 32px; }
  .health span { display: none; }
  .health { padding: 0 11px; }
}
