:root {
  color-scheme: dark;
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #e7edf6;
  background: #0d131d;
  --panel: #141e2b;
  --field: #101824;
  --line: #2a3749;
  --muted: #a6b5c8;
  --accent: #78dfc7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
label, .hint, .badge { font-size: 12px; }
.muted, .hint { color: var(--muted); }
.hint { line-height: 1.5; }
.hint:empty { display: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  color: inherit;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
}
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }
textarea { resize: vertical; min-height: 110px; font: 12px/1.55 ui-monospace, Consolas, monospace; }
code { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 33px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: inherit;
  background: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.button:hover { filter: brightness(1.12); text-decoration: none; }
.button:disabled { opacity: .48; cursor: default; }
.button.primary { background: var(--accent); color: #0e2a26; }
.button.secondary { background: #202d3e; border-color: var(--line); }
.button.quiet { color: var(--muted); }
.button.danger { background: #ad3c4b; }
.button.small { min-height: 27px; padding: 3px 7px; }
.button.wide { width: 100%; }
.card { min-width: 0; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.section-title, .page-header, .editor-hint, .editor-actions, .form-actions, .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.section-title { margin-bottom: 10px; }
.form-actions { justify-content: flex-end; flex-wrap: wrap; }
.badge {
  padding: 3px 7px;
  background: #1b293a;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.shell { display: grid; grid-template-columns: 158px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 15px 11px;
  background: #111a26;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 7px; padding-left: 4px; color: inherit; font-size: 16px; font-weight: 700; }
.brand img { width: 24px; height: 24px; }
.navigation { display: grid; gap: 3px; }
.navigation a { padding: 8px 9px; border-radius: 6px; color: var(--muted); }
.navigation a:hover { background: #192638; text-decoration: none; }
.navigation a[aria-current="page"] { background: #20343f; color: var(--accent); font-weight: 600; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 3px; margin-top: auto; font-size: 11px; }
.workspace { min-width: 0; min-height: 100dvh; display: flex; flex-direction: column; padding: 15px 18px 18px; }
.page-header { margin-bottom: 11px; }
#dashboard { display: grid; flex: 1; grid-template-rows: minmax(min-content, 1fr) auto; gap: 10px; }
.dashboard-grid, .settings-grid, .catalog-regions { display: grid; gap: 10px; }
.dashboard-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.settings-grid, .catalog-regions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-grid { align-items: start; }
.endpoint-editor, #preferredForm, .subscription { display: flex; flex-direction: column; }
#preferredForm { flex: 1; }
#preferredIps { flex: 1 0 auto; }
.settings-grid .card > * + *, #preferredForm > * + *, .subscription > * + *, .regional-catalog > .hint, [data-page].card > .hint { margin-top: 7px; }
.node-limit { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.node-limit input { width: 62px; }
.subscription-selectors, .subscription-output, .domain-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 8px;
}
.subscription-selectors select, .subscription-link input, .domain-row { margin-top: 4px; }
.subscription-output { flex: 1; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: clamp(12px, 2vw, 24px); }
.subscription-output img {
  --qr-size: clamp(136px, min(17vw, 31dvh), 256px);
  display: block;
  width: var(--qr-size);
  height: var(--qr-size);
  background: #fff;
  border-radius: 6px;
}
.subscription-link { grid-column: -2 / -1; min-width: 0; }
.subscription-link .button { margin-top: 6px; }
.domain-row { grid-template-columns: minmax(0, 1fr) auto; }
.region { min-width: 0; padding: 8px; background: var(--field); border: 1px solid var(--line); border-radius: 7px; }
.region .section-title { margin-bottom: 2px; }
.region-note { margin-bottom: 4px; }
.region-list { list-style: none; margin: 0; padding: 0 2px; max-height: clamp(110px, calc(100dvh - 545px), 310px); overflow: auto; scrollbar-gutter: stable; }
.region-entry {
  display: grid;
  grid-template-columns: 14px minmax(0, 1.05fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  padding-block: 4px;
  overflow-wrap: anywhere;
}
.region-list li + li { border-top: 1px solid var(--line); }
.included { color: var(--accent); font-size: 11px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
th { color: var(--muted); font-size: 12px; }
.link-path { color: var(--muted); overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.row-actions button { border: 0; padding: 2px 0; color: var(--accent); background: transparent; cursor: pointer; white-space: nowrap; }
.row-actions .delete { color: #f69ea7; }
.enabled { color: var(--accent); }
.disabled { color: var(--muted); }
.message { padding: 7px 9px; border-radius: 6px; white-space: pre-wrap; font-size: 12px; }
.message.error { background: #35212a; color: #ffb7be; }
.message.warning { background: #392e1f; color: #f6d7a4; }
.login-screen { display: grid; min-height: 100vh; place-items: center; padding: 16px; }
.login-card { width: min(100%, 350px); display: grid; gap: 9px; padding: 20px; }
.login-card h1 { margin-bottom: 5px; }
dialog { width: min(420px, calc(100% - 24px)); color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 16px; }
dialog::backdrop { background: #060a11bb; }
dialog > * + *, dialog form > * + * { margin-top: 8px; }
dialog label { display: block; }
.close-dialog { color: var(--muted); border: 0; background: transparent; font-size: 22px; cursor: pointer; }
.prefix-input { display: flex; align-items: center; gap: 6px; }
.toast { position: fixed; top: 12px; right: 12px; max-width: calc(100vw - 24px); padding: 9px 12px; color: #ddfaf0; background: #223e39; border: 1px solid #3c6c62; border-radius: 7px; z-index: 5; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 1440px) {
  #preferredIps { font-size: 13px; }
  .catalog-regions { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .region[data-region="sg"] .region-list { columns: 2; column-rule: 1px solid var(--line); }
  .region-list { max-height: none; }
  .region-list li { break-inside: avoid; }
}
@media (max-width: 1439px) {
  .subscription-output img { --qr-size: clamp(120px, min(14vw, calc(100dvh - 510px)), 208px); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 130px minmax(0, 1fr); }
  .workspace { padding-inline: 12px; }
  .editor-actions { flex-wrap: wrap; }
  .subscription-output img { --qr-size: 108px; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .navigation { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; }
  .navigation a { padding: 6px 7px; }
  .sidebar-footer { margin: 0; }
  .workspace { min-height: 0; padding: 12px; }
  #dashboard { grid-template-rows: auto; }
  .dashboard-grid, .settings-grid, .catalog-regions { grid-template-columns: minmax(0, 1fr); }
}
