:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --ink: #17202e;
  --soft: #5d6a7e;
  --line: #dce4f0;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-ink: #ffffff;
  --brand-soft: #eaf1ff;
  --danger: #c1372b;
  --danger-soft: #fff0ee;
  --ok: #16734a;
  --radius: 18px;
  --shadow: 0 18px 48px -32px rgba(22, 40, 76, .42);
  --font: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1520;
    --surface: #182230;
    --surface-soft: #131d2b;
    --ink: #e9eef8;
    --soft: #a0aec2;
    --line: #2a374a;
    --brand: #70a7ff;
    --brand-strong: #94bdff;
    --brand-ink: #10203a;
    --brand-soft: #1d2d49;
    --danger: #ff9a8f;
    --danger-soft: #34201f;
    --ok: #7bdca8;
    --shadow: 0 18px 48px -32px rgba(0, 0, 0, .84);
  }
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 36px); line-height: 1.28; letter-spacing: -.03em; }
h2 { font-size: 21px; line-height: 1.4; }
h3 { font-size: 17px; line-height: 1.45; }

.site-header {
  width: min(1120px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.35;
  text-decoration: none;
}

.mark {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(140deg, #73aaff, var(--brand));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .5);
}

.auth-page { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

.app-shell {
  width: min(1280px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  column-gap: 44px;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  width: 240px;
  height: 100vh;
  padding: 30px 20px 24px 0;
  border-right: 1px solid var(--line);
}

.sidebar-top { min-width: 0; }

.portal-nav {
  display: grid;
  gap: 4px;
  margin-top: 38px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 10px 10px 0;
  background: transparent;
  color: var(--soft);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.is-active {
  border-left-color: var(--brand);
  background: var(--brand-soft);
  color: var(--ink);
}

.sidebar-account {
  display: grid;
  gap: 13px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.sidebar-account div { min-width: 0; }
.sidebar-account dt { color: var(--soft); font-size: 11px; font-weight: 700; }
.sidebar-account dd { margin-top: 2px; overflow-wrap: anywhere; font-size: 13px; }
.sidebar-account code { font-size: 12px; }

.portal-main {
  width: min(100%, 960px);
  min-width: 0;
  padding: 52px 0 70px;
}

.message { min-height: 24px; margin: 0 2px; color: var(--soft); }
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

.portal-page { width: 100%; }
.docs-page { max-width: 760px; }
.page-heading { margin: 13px 0 28px; }

.eyebrow {
  margin-bottom: 3px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .09em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-card {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-card > p, .dashboard-card > span {
  display: block;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-card > strong {
  display: block;
  margin: 6px 0 5px;
  font-size: 28px;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.home-usage-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 9px;
}

.home-usage-values dt { color: var(--soft); font-size: 11px; font-weight: 700; }
.home-usage-values dd { margin-top: 1px; font-size: 17px; font-weight: 750; white-space: nowrap; }

.panel {
  margin-top: 20px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.getting-started {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.getting-started > div > p:last-child {
  margin-top: 7px;
  color: var(--soft);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

label { display: block; color: var(--soft); font-size: 12px; font-weight: 700; }
input, select {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--ink);
}
input { min-width: 0; width: 100%; padding: 11px 13px; font-size: 16px; }
select { margin-top: 4px; padding: 8px 31px 8px 10px; }

.issue-form { margin-top: 0; }
.issue-controls { display: flex; gap: 10px; margin-top: 6px; }
.issue-controls input { flex: 1; }
.hint { margin-top: 6px; color: var(--soft); font-size: 12px; }

.button, .text-button {
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--brand-ink);
  background: var(--brand);
  font-weight: 700;
  line-height: 1.2;
}
.button { flex: none; padding: 12px 18px; white-space: nowrap; }
.button:hover { background: var(--brand-strong); }
.button:disabled { cursor: default; opacity: .58; }
.button.secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.button.secondary:hover { background: var(--brand-soft); }
.text-button { padding: 6px 8px; background: transparent; color: var(--brand); }
.text-button:hover { text-decoration: underline; }

.new-key {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--brand);
  border-radius: 14px;
  background: var(--brand-soft);
}
.new-key-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.secret {
  display: block;
  margin-top: 14px;
  padding: 13px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
}
.new-key-actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.new-key-actions p { color: var(--soft); font-size: 13px; }

.table-wrap {
  max-width: 100%;
  margin-top: 23px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.key-table, .usage-table, .billing-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.key-table th, .key-table td,
.usage-table th, .usage-table td,
.billing-table th, .billing-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.key-table th, .usage-table th, .billing-table th {
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}

.key-table td, .usage-table td, .billing-table td { font-size: 13px; }
.key-table td code, .usage-table td code { font-size: 12px; overflow-wrap: anywhere; }
.key-table tbody tr:last-child td, .usage-table tbody tr:last-child td, .billing-table tbody tr:last-child td { border-bottom: 0; }
.key-table tbody tr.revoked { opacity: .52; }
.status { font-size: 12px; font-weight: 700; white-space: nowrap; }
.status.active { color: var(--ok); }
.status.revoked { color: var(--soft); }
.revoke { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; }
.revoke:hover { background: var(--danger-soft); }
.empty { margin: 18px 0 2px; color: var(--soft); text-align: center; }

.usage-heading { align-items: flex-end; }
.month-select { flex: none; }
.usage-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.usage-totals div { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.usage-totals span { display: block; color: var(--soft); font-size: 12px; font-weight: 700; }
.usage-totals strong { display: block; margin-top: 3px; font-size: 25px; letter-spacing: -.03em; }

.balance-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.balance-card {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.balance-card.total { border-color: var(--brand); background: var(--brand-soft); }
.balance-card span { display: block; color: var(--soft); font-size: 12px; font-weight: 700; }
.balance-card strong { display: block; margin-top: 5px; font-size: 27px; letter-spacing: -.04em; overflow-wrap: anywhere; }
.balance-held { margin-top: 8px; }

.training-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.training-panel > div { min-width: 0; }
.training-state { margin-top: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.training-panel .hint { margin-top: 7px; }
.training-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.training-toggle:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.training-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.training-toggle:has(input:disabled) { cursor: wait; opacity: .65; }

.training-confirmation {
  width: min(520px, calc(100% - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.training-confirmation::backdrop { background: rgba(24, 35, 55, .48); }
.training-confirmation-content { padding: 24px; }
.training-confirmation h2 { margin-top: 5px; font-size: 21px; }
.training-confirmation h2 + p { margin-top: 13px; color: var(--soft); line-height: 1.7; }
.training-acknowledgement {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.training-acknowledgement input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); }
.training-confirmation-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.charge-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.charge-summary > div { min-width: 0; }
.charge-summary h2 + p { margin-top: 7px; color: var(--soft); }
.charge-expiry {
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.rate-list {
  display: grid;
  flex: 0 0 min(100%, 300px);
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}
.rate-list div { min-width: 0; padding: 9px 12px; background: var(--surface-soft); }
.rate-list dt { color: var(--soft); font-size: 11px; font-weight: 700; }
.rate-list dd { margin-top: 1px; font-size: 13px; font-weight: 700; }

.charge-form { max-width: 640px; margin-top: 25px; }
.charge-amounts { min-width: 0; margin: 0; padding: 0; border: 0; }
.charge-amounts legend { padding: 0; color: var(--soft); font-size: 12px; font-weight: 700; }
.charge-amount-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.amount-button {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.amount-button:hover, .amount-button.is-selected { border-color: var(--brand); background: var(--brand-soft); }
.charge-form > label { margin-top: 19px; }
.charge-form > input { margin-top: 5px; }
.charge-submit { margin-top: 20px; }

.docs-loading { margin: 0 0 18px; color: var(--soft); }
.markdown-content { overflow-wrap: anywhere; }
.markdown-content > h1,
.markdown-content > h2,
.markdown-content > h3,
.markdown-content > h4 {
  margin-top: 36px;
  scroll-margin-top: 24px;
}
.markdown-content > h1:first-child { margin-top: 0; }
.markdown-content > h1 { font-size: 29px; }
.markdown-content > h2 { font-size: 23px; }
.markdown-content > h3 { font-size: 19px; }
.markdown-content > h4 { font-size: 16px; }
.markdown-content p { margin-top: 14px; }
.markdown-content h1 + p,
.markdown-content h2 + p,
.markdown-content h3 + p,
.markdown-content h4 + p { margin-top: 10px; }
.markdown-content ul, .markdown-content ol { margin: 14px 0 0; padding-left: 1.55em; }
.markdown-content li + li { margin-top: 5px; }
.markdown-content li > ul, .markdown-content li > ol { margin-top: 5px; }
.markdown-content :not(pre) > code {
  padding: .1em .35em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
}
.markdown-content a { color: var(--brand); }

.code-block {
  position: relative;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.code-block pre {
  margin: 0;
  padding: 44px 16px 16px;
  overflow-x: auto;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}
.code-block code { font: inherit; }
.copy-code {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.copy-code:hover { background: var(--brand-soft); }

.markdown-table-wrap {
  max-width: 100%;
  margin-top: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.markdown-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
}
.markdown-table th, .markdown-table td {
  padding: 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.markdown-table th { background: var(--surface-soft); font-size: 12px; }
.markdown-table td { font-size: 13px; }

.auth-error { width: min(100%, 560px); margin: 90px auto; }
.auth-error h1 { font-size: 23px; }
.auth-error p { margin-top: 8px; color: var(--soft); }
.auth-error .button { margin-top: 20px; }

.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 32px, 960px);
    display: block;
  }

  .sidebar {
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    padding: 16px 0 0;
    border-right: 0;
    background: var(--bg);
  }

  .portal-nav {
    display: flex;
    gap: 3px;
    margin-top: 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 10px 10px 0 0;
    white-space: nowrap;
  }

  .nav-item.is-active { border-bottom-color: var(--brand); }

  .sidebar-account {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 20px;
    margin-top: 10px;
    padding: 10px 0;
  }

  .portal-main { width: 100%; padding-top: 32px; }
}

@media (max-width: 760px) {
  .site-header, .auth-page, .app-shell { width: min(100% - 24px, 1120px); }
  .panel { margin-top: 15px; padding: 20px 16px; border-radius: 15px; }
  .getting-started, .charge-summary, .training-panel { display: block; }
  .getting-started .button { width: 100%; margin-top: 16px; }
  .training-toggle { width: 100%; margin-top: 16px; justify-content: center; }
  .rate-list { margin-top: 18px; }
  .issue-controls { display: block; }
  .issue-controls .button { width: 100%; margin-top: 10px; }
  .new-key-actions { display: block; }
  .new-key-actions .button { width: 100%; }
  .new-key-actions p { margin-top: 9px; }
  .usage-heading { align-items: flex-start; }
  .month-select { margin-top: 12px; }
  .charge-submit { width: 100%; }
}

@media (max-width: 620px) {
  .dashboard-grid, .balance-grid, .usage-totals { grid-template-columns: 1fr; }
  .dashboard-card, .balance-card { padding: 17px; }
  .page-heading { margin-bottom: 22px; }
  .portal-main { padding-top: 25px; }
}

@media (max-width: 430px) {
  .sidebar-account { grid-template-columns: 1fr; }
  .brand { font-size: 15px; }
}
