:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --text: #171717;
  --muted: #6f6f6c;
  --line: #e6e6e2;
  --line-strong: #d4d4cf;
  --focus: #4f46e5;
  --danger: #b42318;
  --success: #207a3b;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #191918;
    --surface-2: #222220;
    --text: #f0f0ed;
    --muted: #a1a19c;
    --line: #2c2c29;
    --line-strong: #3b3b37;
    --focus: #a5a1ff;
    --danger: #ff8a80;
    --success: #7bd88f;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: .55;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.shell {
  width: min(100% - 40px, 1040px);
  margin: 0 auto;
  padding: 18px 0 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar nav::-webkit-scrollbar {
  display: none;
}

.topbar nav a,
.topbar nav button {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.topbar nav a:hover,
.topbar nav button:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.topbar nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 42px 0 24px;
}

.page-head h1,
h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 620;
  letter-spacing: -.035em;
  line-height: 1.15;
}

h2 {
  margin: 34px 0 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.015em;
}

h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

p {
  margin: 0;
}

.error {
  color: var(--danger);
  font-size: 13px;
}

.hero {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 26px 2px 20px;
}

.hero strong {
  font-size: clamp(42px, 9vw, 64px);
  font-weight: 600;
  letter-spacing: -.06em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero span {
  color: var(--muted);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.hero .state {
  margin-left: auto;
  font-size: 14px;
}

.hero .state.is-online {
  color: var(--success);
}

.hero .state.is-offline {
  color: var(--danger);
}

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

.card {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card .label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.card .value {
  display: block;
  overflow-wrap: anywhere;
  font-size: 21px;
  font-weight: 570;
  letter-spacing: -.02em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 46px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
}

.row > :first-child {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.row > :last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.row-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

tr:last-child td {
  border-bottom: 0;
}

td .button {
  height: 26px;
  margin-left: 6px;
  padding: 0 8px;
  font-size: 12px;
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.form.wide {
  grid-template-columns: 1fr;
}

.form.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field.half {
  max-width: 480px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
}

.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  padding: 7px 10px;
  line-height: 1.4;
  transition: border-color .12s ease, background .12s ease;
}

.field input,
.field select {
  height: 34px;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--text);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
}

.plugin-actions {
  margin-top: 10px;
}

.plugin-key-box {
  max-width: 560px;
  margin-top: 14px;
}

.plugin-key-box input {
  font-family: var(--mono);
}

.plugin-key-box .button {
  align-self: flex-start;
}

.downloads {
  display: grid;
  gap: 8px;
}

.downloads-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.downloads-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}

.downloads-row input:hover {
  border-color: var(--text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 520;
  line-height: 1;
  text-decoration: none;
}

.button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.button.primary {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.button.primary:hover {
  opacity: .88;
}

.button.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button.quiet:hover {
  background: var(--surface-2);
  color: var(--text);
}

.button.danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button.danger:hover {
  background: var(--danger);
  color: var(--surface);
}

.button.small {
  height: 27px;
  padding: 0 9px;
  font-size: 12px;
}

.empty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 13px;
}

pre,
.code {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.55 var(--mono);
}

td.code {
  white-space: nowrap;
  overflow-wrap: normal;
}

.news {
  padding: 4px 0;
}

.news-item {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.news-item:first-child {
  border-top: 0;
}

.news-item p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.auth {
  width: min(100% - 40px, 380px);
  margin: 13vh auto 0;
}

.auth .brand {
  display: inline-block;
  margin-bottom: 28px;
}

.auth h1 {
  margin-bottom: 22px;
}

.auth .form {
  grid-template-columns: 1fr;
}

.auth .button {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 9px 13px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
  font-size: 13px;
}

.toast:empty {
  display: none;
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.dialog {
  width: min(calc(100% - 32px), 390px);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .22);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, .28);
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.dialog p {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: calc(100% - 32px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .topbar nav {
    width: 100%;
  }

  .page-head {
    margin-top: 30px;
  }

  .page-head h1,
  h1 {
    font-size: 24px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form,
  .form.three {
    grid-template-columns: 1fr;
  }
  .field.half {
    max-width: none;
  }

  .downloads-row {
    grid-template-columns: 1fr auto;
  }

  .downloads-row input:first-child {
    grid-column: 1 / -1;
  }

  #tokens-table th:nth-child(3),
  #tokens-table td:nth-child(3),
  #data-table th:nth-child(3),
  #data-table td:nth-child(3),
  #logs-table th:nth-child(2),
  #logs-table td:nth-child(2),
  #logs-table th:nth-child(6),
  #logs-table td:nth-child(6) {
    display: none;
  }

  .auth {
    width: calc(100% - 32px);
    margin-top: 8vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
