/* Account features: signed-in devices, "Your data" and the usage history on Plan and billing.
   Colours only through the app's variables, so light and dark both work. */

/* ---------- Account settings cards ---------- */
.acc-card { display: flex; flex-direction: column; gap: 14px; }
.acc-card .note { margin: 0; font-size: 13px; color: var(--ink-muted); }
.acc-card h2 { margin: 0; }
.acc-ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.acc-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.acc-actions .btn { border-radius: 999px; }
.acc-actions .btn .acc-ico { margin-left: -2px; }
.btn[aria-busy="true"] { cursor: progress; }

.acc-data-top { display: flex; gap: 14px; align-items: flex-start; }
.acc-data-top > .acc-ico { width: 42px; height: 42px; border-radius: 14px; color: var(--accent-text);
  background: color-mix(in srgb, var(--select) 12%, transparent); border: 1px solid color-mix(in srgb, var(--select) 22%, transparent); }
.acc-data-top > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.dev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--card); }
.dev-list:empty { display: none; }
.dev { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; border-top: 1px solid var(--line); }
.dev:first-child { border-top: 0; }
.dev > .acc-ico { width: 36px; height: 36px; border-radius: 50%; background: var(--chip-bg); color: var(--ink-muted); }
.dev.is-current > .acc-ico { color: var(--accent-text); background: color-mix(in srgb, var(--select) 12%, var(--chip-bg)); }
.dev-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dev-body b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-body span { font-size: 12.5px; color: var(--ink-faint); }
.dev-pill { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: var(--accent-text);
  background: color-mix(in srgb, var(--select) 12%, transparent); border: 1px solid color-mix(in srgb, var(--select) 25%, transparent); }
.dev .btn-ghost { border-radius: 999px; flex-shrink: 0; }
.dev .btn-ghost:hover { color: var(--danger); }

/* ---------- Recent usage (Plan and billing) ---------- */
.usage-card { display: flex; flex-direction: column; gap: 16px; transition: opacity .2s ease; }
.usage-card.loading { opacity: .6; }
.usage-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.usage-stats:empty { display: none; }
.ustat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 16px; background: var(--chip-bg); border: 1px solid var(--line); min-width: 0; }
.ustat b { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ustat span { font-size: 12.5px; color: var(--ink-muted); }
.ustat:first-child b { background: linear-gradient(135deg, var(--cta-a), var(--cta-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.usage-wrap { border-radius: 16px; }
.usage-table td { vertical-align: middle; }
.usage-table .u-date { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.usage-table .u-proj a { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: var(--ink); font-weight: 500; text-decoration: none; border-radius: 6px; }
.usage-table .u-proj a:hover { color: var(--accent-text); text-decoration: underline; }
.usage-table .u-proj a:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.usage-table .u-asked { white-space: normal; min-width: 220px; }
.u-q { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink); max-width: 380px; }
.u-tag { display: inline-block; margin: 4px 6px 0 0; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--chip-bg); color: var(--ink-muted); border: 1px solid var(--line); }
.usage-table th.num, .usage-table td.num { text-align: right; }
.u-cred b { font-weight: 600; font-variant-numeric: tabular-nums; }
.u-unit { color: var(--ink-faint); font-size: 12px; }
.tier-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-muted); }
.tier-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.tier-bars i { display: block; width: 3px; border-radius: 2px; background: var(--line); }
.tier-bars i:nth-child(1) { height: 4px; } .tier-bars i:nth-child(2) { height: 7px; } .tier-bars i:nth-child(3) { height: 10px; } .tier-bars i:nth-child(4) { height: 12px; }
.tier-bars i.on { background: var(--accent-text); }
.usage-empty { margin: 0; text-align: center; padding: 18px 8px; }
.usage-more { display: flex; justify-content: center; }
.usage-more:has(> [hidden]) { display: none; }
.usage-more .btn { border-radius: 999px; min-width: 140px; }

/* Rows lift in when "Show more" adds them */
@media (prefers-reduced-motion: no-preference) {
  .usage-table tbody tr { animation: acc-row-in .32s cubic-bezier(.2, .8, .2, 1) both; }
  .dev { animation: acc-row-in .32s cubic-bezier(.2, .8, .2, 1) both; }
}
@keyframes acc-row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Phones: each request becomes a small stacked row instead of a wide table */
@media (max-width: 640px) {
  .usage-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ustat { padding: 10px 11px; }
  .ustat b { font-size: 21px; }
  .ustat span { font-size: 11.5px; line-height: 1.3; }
  .usage-wrap { overflow: visible; }
  .usage-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .usage-table, .usage-table tbody { display: block; }
  /* first line: the question and its credits; second line: date · project · level */
  .usage-table tr { display: flex; flex-wrap: wrap; align-items: baseline; row-gap: 5px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .usage-table tr:last-child { border-bottom: 0; }
  .usage-table td { display: block; padding: 0; border: 0; white-space: nowrap; }
  .usage-table .u-asked { order: 1; flex: 0 0 calc(100% - 84px); min-width: 0; padding-right: 12px; white-space: normal; }
  .usage-table .u-cred { order: 2; flex: 0 0 84px; text-align: right; }
  .usage-table .u-date { order: 3; }
  .usage-table .u-proj { order: 4; flex: 1 1 0; min-width: 0; display: flex; }
  .usage-table .u-tier { order: 5; }
  .usage-table .u-date, .usage-table .u-proj, .usage-table .u-tier, .usage-table .tier-pill { font-size: 12px; color: var(--ink-faint); }
  .usage-table .u-proj::before, .usage-table .u-tier::before { content: "\00B7"; margin: 0 7px; color: var(--ink-faint); }
  .usage-table .u-proj a { flex: 1 1 auto; min-width: 0; max-width: none; white-space: nowrap; font-weight: 500; color: var(--ink-muted); }
  .usage-table .u-proj::before { flex-shrink: 0; }
  .usage-table .u-tier .tier-pill { gap: 5px; }
  .u-q { max-width: none; }
  .dev { padding: 11px 12px; gap: 10px; }
  .acc-data-top > .acc-ico { display: none; }
}
