:root {
  --bg: #ffffff; --bg2: #f6f8fa; --bg3: #eaeef2; --fg: #1f2328; --muted: #59636e; --border: #d1d9e0;
  --accent: #0969da; --accent-bg: #ddf4ff; --green: #1a7f37; --danger: #d1242f;
  --h0: #ddd8cf; --h1: #fcd9a0; --h2: #f7b04a; --h3: #e9800f; --h4: #a8500a;
  --brand: #c2410c; --brand-hover: #a9380a;
  --c-input: #0969da; --c-output: #1a7f37; --c-cread: #9a6700; --c-cwrite: #8250df;
  --shadow: 0 1px 0 rgba(31,35,40,.04); --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --bg2: #151b23; --bg3: #212830; --fg: #f0f6fc; --muted: #9198a1; --border: #3d444d;
    --accent: #4493f8; --accent-bg: #121d2f; --green: #3fb950; --danger: #f85149;
    --h0: #343a45; --h1: #6b4612; --h2: #a86a14; --h3: #e08b1c; --h4: #ffc766;
    --brand: #d9520f; --brand-hover: #e8641f;
    --c-input: #4493f8; --c-output: #3fb950; --c-cread: #d29922; --c-cwrite: #ab7df8;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* top bar */
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--fg); padding: 6px 10px; border-radius: var(--radius); }
.nav a:hover { background: var(--bg3); text-decoration: none; }
.nav a.active { font-weight: 600; color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.spacer { flex: 1; }
.search input { width: 220px; }
#me-slot { display: flex; align-items: center; gap: 8px; }

/* form controls */
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { width: 100%; min-height: 140px; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 5px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg2); color: var(--fg); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg3); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 2px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: default; }

/* layout pieces */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 28px 0 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.box-head { padding: 12px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.box-head h2, .box-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.box-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: 12px; }
.two-col { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-bottom: 16px; }
@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, 1fr); } .two-col { grid-template-columns: 1fr; } .search { display: none; } }

/* tabs / segmented */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; border: 0; background: var(--bg); color: var(--fg); padding: 5px 14px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { white-space: nowrap; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg2); }
td.rank { width: 56px; font-weight: 600; font-size: 15px; color: var(--muted); }
td.rank.top { font-size: 20px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .names { display: flex; flex-direction: column; line-height: 1.25; }
.user-cell .uname { font-weight: 600; color: var(--fg); }
.user-cell .dname { color: var(--muted); font-size: 12px; }
.avatar { border-radius: 50%; border: 1px solid var(--border); background: var(--bg2); flex: none; }
.big-total { font-weight: 600; font-size: 15px; }
.table-scroll { overflow-x: auto; }

/* chips & labels */
.chip { display: inline-block; padding: 0 8px; font-size: 12px; line-height: 20px; border-radius: 2em; border: 1px solid var(--border); color: var(--muted); margin: 1px 4px 1px 0; white-space: nowrap; }
.chip.model { background: var(--accent-bg); color: var(--accent); border-color: transparent; font-weight: 500; }
.chip.tool { color: #fff; border-color: transparent; }

/* stacked share bar */
.share { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg3); min-width: 120px; }
.share > span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 80px; gap: 10px; align-items: center; padding: 6px 0; }
.bar-row .bar { height: 10px; border-radius: 5px; background: var(--bg3); overflow: hidden; }
.bar-row .bar > span { display: block; height: 100%; background: var(--h3); border-radius: 5px; }
.bar-row > .chip { justify-self: start; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* charts */
.chart svg { display: block; width: 100%; height: auto; }
.chart rect.b { fill: var(--h3); }
.chart rect.b:hover { fill: var(--h4); }
.chart text { fill: var(--muted); font-size: 10px; }
.chart line { stroke: var(--border); }

/* profile */
.profile { display: grid; grid-template-columns: 264px 1fr; gap: 24px; margin-top: 28px; }
@media (max-width: 900px) { .profile { grid-template-columns: 1fr; } }
.profile-side .avatar { width: 100%; max-width: 264px; height: auto; border-radius: 24px; }
.profile-side h1 { margin: 16px 0 0; font-size: 24px; line-height: 1.25; }
.profile-side .login { font-size: 20px; color: var(--muted); font-weight: 300; }
.side-stats { list-style: none; padding: 0; margin: 16px 0; }
.side-stats li { padding: 4px 0; display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); }
.rank-badge { display: inline-block; margin-top: 12px; padding: 4px 12px; border-radius: 2em; background: linear-gradient(90deg, #f9d65c, #f0883e); color: #3b2300; font-weight: 600; }
.heatmap-wrap { overflow-x: auto; }
.heatmap circle { transition: r .15s; }
.heatmap circle.today { fill: none; stroke: var(--brand); stroke-width: 1.4; pointer-events: none; }
.heatmap text { fill: var(--fg); font-size: 9px; }
.h0 { fill: var(--h0); } .h1 { fill: var(--h1); } .h2 { fill: var(--h2); } .h3 { fill: var(--h3); } .h4 { fill: var(--h4); }
.heat-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; margin-top: 6px; }
.heat-legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.heat-legend .lg { display: inline-flex; align-items: center; gap: 2px; }
.heat-foot { flex-wrap: wrap; gap: 8px; }
.streaks { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.streaks b { display: block; font-size: 20px; }

/* misc */
.empty { padding: 40px; text-align: center; color: var(--muted); }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.error { padding: 12px 16px; border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius); margin: 16px 0; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: #25292e; color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 6px; max-width: 320px; white-space: pre-line; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #25292e; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 100; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; padding-top: 40px; padding-bottom: 40px; border-top: 1px solid var(--border); margin-top: 48px; }
pre.code { padding-right: 72px !important; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; overflow-x: auto; margin: 8px 0 16px; position: relative; }
.copy { position: absolute; right: 8px; top: 8px; }
.steps h3 { font-size: 15px; margin: 20px 0 6px; }
.steps h3:first-child { margin-top: 0; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.stack input { width: 100%; }
.stack .btn { align-self: flex-start; }
td.nowrap { white-space: nowrap; }
.form-row label { min-width: 90px; color: var(--muted); }
.keybox { background: var(--bg2); border: 1px dashed var(--green); border-radius: var(--radius); padding: 12px; margin: 12px 0; word-break: break-all; }
.manual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.manual-grid input, .manual-grid select { width: 100%; }
.manual-grid label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
table.mini td { padding: 4px 8px 4px 0; border: 0; font-size: 13px; }
table.mini tr:hover { background: none; }

/* sign-in & settings */
img.avatar { object-fit: cover; }
.login-box { max-width: 380px; margin: 48px auto 0; }
.login-box h1 { text-align: center; font-size: 24px; font-weight: 300; margin: 12px 0 20px; }
.login-logo { text-align: center; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 16px 0 8px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent); padding: 4px 0; }
.small { font-size: 12px; }
.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.banner.success { background: color-mix(in srgb, var(--green) 10%, transparent); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.banner.error { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.section { margin-bottom: 16px; }
.method { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.method:last-of-type { border-bottom: 0; }
.method .grow { flex: 1; min-width: 0; }
.profile-link { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); }
.profile-link a { color: var(--fg); }
#me-slot .btn { margin-right: 4px; }

/* token value */
.value-usd { color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.value-usd sup { color: var(--muted); font-weight: 400; margin-left: 1px; }
.card .value .value-usd { font-size: inherit; }
.banner.info { background: var(--accent-bg); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.profile > section, .profile > aside { min-width: 0; }

/* Third-party sign-in buttons — Google "Sign in with Google" spec (light / dark theme, rectangular).
   All providers share this exact style, so no option is more prominent than Google. */
.sso-btn { position: relative; display: block; box-sizing: border-box; height: 40px; width: 100%; max-width: 400px; padding: 0 12px; overflow: hidden;
  border: 1px solid #747775; border-radius: 4px; background: #ffffff; color: #1f1f1f; cursor: pointer; text-decoration: none; white-space: nowrap;
  font-family: "Roboto", arial, sans-serif; font-size: 14px; font-weight: 500; letter-spacing: 0.25px;
  transition: background-color .218s, border-color .218s, box-shadow .218s; }
.sso-btn:hover { text-decoration: none; box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15); }
.sso-btn .sso-state { position: absolute; inset: 0; opacity: 0; transition: opacity .218s; }
.sso-btn:hover .sso-state { background: #303030; opacity: .08; }
.sso-btn:active .sso-state, .sso-btn:focus .sso-state { background: #303030; opacity: .12; }
.sso-btn .sso-wrap { position: relative; display: flex; align-items: center; height: 100%; width: 100%; }
.sso-btn .sso-icon { display: flex; align-items: center; justify-content: center; width: 20px; min-width: 20px; height: 20px; margin-right: 12px; }
.sso-btn .sso-icon img, .sso-btn .sso-icon picture, .sso-btn .sso-icon svg { display: block; }
.sso-btn .sso-text { flex-grow: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.method .sso-btn { width: auto; min-width: 220px; }
@media (prefers-color-scheme: dark) {
  .sso-btn { background: #131314; border-color: #8e918f; color: #e3e3e3; }
  .sso-btn:hover .sso-state { background: #ffffff; }
  .sso-btn:active .sso-state, .sso-btn:focus .sso-state { background: #ffffff; }
}
.footer .legal { flex-basis: 100%; font-size: 11px; opacity: .85; }
