:root {
  --canvas: #0e1512;
  --surface-1: #151e1a;
  --surface-2: #1b2721;
  --surface-3: #24322b;
  --felt: #184234;
  --felt-deep: #123328;
  --wood: #5b4030;
  --wood-hi: #806048;
  --line: #35483e;
  --line-strong: #53695d;
  --text: #f1eee6;
  --text-2: #c2c8c2;
  --text-3: #98a49d;
  --text-disabled: #a5ada8;
  --accent: #c99b52;
  --accent-hover: #d7aa63;
  --accent-ink: #19150e;
  --focus: #8fb8c6;
  --success: #7db58a;
  --info: #79afc2;
  --warning: #d2a45a;
  --danger: #d77870;
  --danger-surface: #3a211f;
  --shadow-1: 0 5px 16px rgb(0 0 0 / 0.22);
  --shadow-2: 0 18px 44px rgb(0 0 0 / 0.42);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --fast: 140ms;
  --normal: 220ms;
  --slow: 320ms;
  --ease: cubic-bezier(.2,.75,.3,1);
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .32;
  background-image:
    linear-gradient(90deg, rgb(255 255 255 / .012) 1px, transparent 1px),
    linear-gradient(rgb(255 255 255 / .01) 1px, transparent 1px);
  background-size: 48px 48px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
[hidden] { display: none !important; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 1440px);
  min-height: 100dvh;
  margin: 0 auto;
}

.topbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: max(var(--s2), env(safe-area-inset-top)) var(--s4) var(--s2);
  border-bottom: 1px solid var(--line);
  background: rgb(21 30 26 / .94);
}
.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  text-decoration: none;
}
.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 62%, var(--line));
  border-radius: 8px;
  font-family: Georgia, serif;
  font-size: 17px;
  line-height: 1;
}
.brand-copy { display: grid; min-width: 0; line-height: 1.1; }
.brand-name { font-weight: 720; letter-spacing: .04em; }
.brand-sub { margin-top: 3px; color: var(--text-3); font-size: 11px; white-space: nowrap; }
.topbar-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--s2); min-width: 0; }
.account-chip {
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.account-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
}
.account-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip .chip-label { flex: 0 0 auto; color: var(--text-3); font-size: 11px; }
.input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button, .input[type="number"]::-webkit-inner-spin-button { margin: 0; appearance: none; }

.icon-btn, .text-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  color: var(--text-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.icon-btn:hover, .text-btn:hover { color: var(--text); border-color: var(--line); background: var(--surface-2); }
.icon-btn { font-size: 18px; }
.text-btn.danger { color: var(--danger); }

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 650;
  line-height: 1;
  transition: transform 80ms var(--ease), background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--text-3); background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.99); }
.btn:disabled { color: var(--text-disabled); border-color: var(--line); background: #202a25; opacity: 1; }
.btn-primary { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
.btn-primary:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 68%, var(--line)); background: var(--danger-surface); }
.btn-danger:hover:not(:disabled) { color: #fff4f1; border-color: var(--danger); background: #542b27; }
.btn-quiet { color: var(--text-2); border-color: transparent; background: transparent; }
.btn-quiet:hover:not(:disabled) { border-color: var(--line); background: var(--surface-2); }
.btn-block { width: 100%; }

.field { display: grid; gap: 7px; }
.field > label, .field-label { color: var(--text-2); font-size: 12px; font-weight: 650; letter-spacing: .02em; }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101914;
  outline: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input { font-size: 16px; }
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgb(143 184 198 / .18); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-help { min-height: 18px; color: var(--text-3); font-size: 12px; }
.field-error { color: #f0aaa3; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-1);
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}
.panel-heading h2, .panel-heading h3 { margin: 0; font-size: 14px; font-weight: 700; }
.panel-body { padding: var(--s4); }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.notice::before { content: ""; width: 8px; height: 8px; flex: 0 0 auto; margin-top: 6px; border-radius: 50%; background: var(--info); }
.notice[data-kind="success"]::before { background: var(--success); }
.notice[data-kind="warning"]::before { background: var(--warning); }
.notice[data-kind="danger"] { border-color: color-mix(in srgb, var(--danger) 56%, var(--line)); background: var(--danger-surface); }
.notice[data-kind="danger"]::before { background: var(--danger); }

.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--text-3); }
.status-dot.online { background: var(--success); }
.status-dot.reconnecting { background: var(--warning); }
.status-dot.offline { background: var(--danger); }
.mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--text-3); }

.modal-layer, .drawer-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: rgb(0 0 0 / .55);
  animation: layer-in var(--normal) var(--ease);
}
.modal {
  width: min(100%, 460px);
  max-height: min(720px, calc(100dvh - 32px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
  animation: modal-in var(--normal) var(--ease);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { display: grid; gap: var(--s4); padding: var(--s5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); }

.toast-stack { position: fixed; z-index: 100; right: var(--s4); bottom: calc(var(--s4) + env(safe-area-inset-bottom)); display: grid; gap: var(--s2); width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 11px 12px; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); box-shadow: var(--shadow-2); animation: toast-in var(--normal) var(--ease); }
.toast[data-kind="danger"] { border-color: var(--danger); }
.toast[data-kind="success"] { border-color: var(--success); }

.loading-block { position: relative; overflow: hidden; min-height: 14px; border-radius: 4px; background: var(--surface-3); }
.loading-block::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .06), transparent); transform: translateX(-100%); animation: skeleton 1.4s infinite; }

@keyframes layer-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes skeleton { to { transform: translateX(100%); } }

@media (max-width: 640px) {
  .topbar { min-height: 48px; padding-right: var(--s3); padding-left: var(--s3); }
  .brand-sub { display: none; }
  .account-chip { max-width: 130px; }
  .text-btn { min-width: 40px; padding: 8px; }
  .modal-layer { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: min(84dvh, 720px); border-right: 0; border-bottom: 0; border-left: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-footer { padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
