/* Asif — instrument-panel look: sage enclosure grey, amber signal keys, scope screens. */

:root {
  color-scheme: light;
  --bg: #e3e5dc;
  --surface: #f2f3ec;
  --surface-2: #e9ebe2;
  --field: #fbfbf7;
  --ink: #1f221c;
  --ink-2: #4f554a;
  --ink-3: #737a6c;
  --line: #c8cbbe;
  --line-2: #a3a797;
  --key: #f0be2c;
  --key-edge: #c49517;
  --key-ink: #1f221c;
  --screen: #262a22;
  --screen-grid: #343a2f;
  --screen-axis: #4a5143;
  --trace: #f0be2c;
  --good: #3a6a53;
  --bad: #ad3d2b;
  --focus: #1f221c;
  --screw: #b6baab;
  --screw-slot: #8d9283;
  --shadow: 0 14px 30px -18px rgba(31, 34, 28, 0.45);

  --font: "Archivo", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --page: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #161814;
    --surface: #1f221c;
    --surface-2: #272b24;
    --field: #191b16;
    --ink: #e7e9e0;
    --ink-2: #b0b5a6;
    --ink-3: #838a7b;
    --line: #33372f;
    --line-2: #4c5146;
    --key: #f0be2c;
    --key-edge: #b0850f;
    --key-ink: #1a1c17;
    --screen: #0f110d;
    --screen-grid: #1f231b;
    --screen-axis: #2e3328;
    --trace: #f3c644;
    --good: #84b99a;
    --bad: #e57a64;
    --focus: #f0be2c;
    --screw: #3b4036;
    --screw-slot: #262a23;
    --shadow: 0 16px 32px -18px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }
p { margin: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

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

.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;
}

.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.measure { max-width: 62ch; }
.pad { padding: 24px 0; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- Type ---------- */

.title {
  font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem);
  font-weight: 700;
  font-stretch: 112.5%;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 1.125rem;
  font-weight: 650;
  margin: 32px 0 12px;
}

.display {
  font-size: clamp(2.5rem, 1.2rem + 4.4vw, 4.6rem);
  font-weight: 760;
  font-stretch: 125%;
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.display .seg { display: inline-block; }

:lang(zh-CN) .display {
  font-size: clamp(2.25rem, 1.4rem + 2.6vw, 3.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.lede {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 34em;
}

/* ---------- Buttons ---------- */

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px 13px;
  border: 1px solid var(--key-edge);
  border-radius: 10px;
  background: var(--key);
  color: var(--key-ink);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: inset 0 -3px 0 var(--key-edge), 0 1px 0 rgba(255, 255, 255, 0.35) inset;
  transition: transform 80ms ease, box-shadow 80ms ease;
  white-space: nowrap;
}
.key:hover { filter: brightness(1.03); }
.key:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -1px 0 var(--key-edge); }
.key:focus-visible { outline-offset: 3px; }
.key-sm { padding: 7px 14px 9px; font-size: 14px; border-radius: 9px; }
.key-block { width: 100%; }

.btn-quiet, .btn-outline, .btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.btn-quiet { color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-outline { border-color: var(--line-2); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink-3); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn-inline { padding-block: 10px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-stretch: 112.5%;
  font-size: 17px;
  min-width: 0;
}
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.navlink {
  padding: 8px 12px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-2);
}
.navlink:hover { color: var(--ink); background: var(--surface-2); }
.navlink[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--key-edge); border-radius: 9px 9px 2px 2px; }

.lang {
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
}
.lang:hover { border-color: var(--line-2); }

.account { position: relative; }
.account summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.account summary::-webkit-details-marker { display: none; }
.account summary:hover { background: var(--surface-2); }
.account summary .icon { color: var(--ink-3); transition: transform 120ms ease; }
.account[open] summary .icon { transform: rotate(180deg); }
.account-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--screen);
  color: var(--trace);
  font-size: 14px;
  font-weight: 700;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  text-decoration: none;
  font-size: 15px;
}
.menu-item:hover { background: var(--surface-2); }

@media (max-width: 719px) {
  .wide-only { display: none; }
}
@media (min-width: 720px) {
  .narrow-only { display: none; }
}
@media (max-width: 479px) {
  .account-name { display: none; }
  .brand { font-size: 16px; }
}

/* ---------- Main ---------- */

.main {
  flex: 1;
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) var(--gutter) calc(64px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Landing ---------- */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
  min-height: calc(100dvh - 64px - 120px);
}

.landing-copy { display: grid; gap: 24px; }

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-top: 8px;
  font-size: 14px;
}

.rack {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.rail {
  height: 16px;
  border-radius: 5px;
  background-color: var(--surface);
  background-image: radial-gradient(ellipse 6px 3px at center, var(--line-2) 0 90%, transparent 100%);
  background-size: 32px 100%;
  background-position: 16px 0;
  border: 1px solid var(--line);
}

.rack-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 10px;
}

.rack-module {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 300px;
}
.rack-module .screen { flex: 1; aspect-ratio: auto; min-height: 150px; }
.rack-module .scope path { vector-effect: non-scaling-stroke; }
.rack-module .scope .trace { stroke-width: 2.2; }

.rack-knobs { display: flex; align-items: center; gap: 12px; }
.knob {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    linear-gradient(var(--ink), var(--ink)) center 4px / 2px 9px no-repeat,
    radial-gradient(circle at 40% 35%, var(--surface) 0 40%, var(--surface-2) 70%);
  border: 1px solid var(--line-2);
  box-shadow: 0 2px 0 var(--line);
}
.knob + .knob { transform: rotate(-58deg); width: 24px; height: 24px; }
.led {
  margin-left: auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--key);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--key) 25%, transparent), 0 0 10px var(--key);
}

@media (max-width: 879px) {
  .landing { grid-template-columns: 1fr; min-height: 0; }
  .rack-module { min-height: 0; }
  .rack-module .screen { flex: none; min-height: 0; aspect-ratio: 1 / 1; }
}
@media (max-width: 479px) {
  .rack { padding: 10px; gap: 8px; }
  .rack-row { gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rack-module { padding: 12px 8px 12px; gap: 12px; }
  .knob { width: 22px; height: 22px; }
  .knob + .knob { width: 18px; height: 18px; }
}

/* ---------- Scope screens ---------- */

.screen {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--screen);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 3px 10px rgba(0, 0, 0, 0.4);
  aspect-ratio: 240 / 104;
}

.scope { display: block; width: 100%; height: 100%; }
.scope .grid { stroke: var(--screen-grid); stroke-width: 1; fill: none; }
.scope .axis { stroke: var(--screen-axis); stroke-width: 1; fill: none; }
.scope .trace {
  fill: none;
  stroke: var(--trace);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2.5px color-mix(in srgb, var(--trace) 70%, transparent));
}

@keyframes scope-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(calc(var(--period, 60) * -1px)); }
}
@keyframes draw-trace {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes led-on {
  from { opacity: 0.15; box-shadow: none; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: no-preference) {
  .module:hover .scope:not(.is-static) .trace-wrap,
  .module:focus-visible .scope:not(.is-static) .trace-wrap,
  .is-scanning .scope:not(.is-static) .trace-wrap {
    animation: scope-scroll 1.3s linear infinite;
  }

  .rack .trace {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
    animation: draw-trace 1.5s cubic-bezier(.35, .1, .25, 1) forwards;
  }
  .rack .m2 .trace { animation-delay: 0.25s; }
  .rack .m3 .trace { animation-delay: 0.5s; }
  .rack .led { animation: led-on 0.3s ease-out both; }
  .rack .m1 .led { animation-delay: 1.3s; }
  .rack .m2 .led { animation-delay: 1.55s; }
  .rack .m3 .led { animation-delay: 1.8s; }
}

/* ---------- Bench ---------- */

.bench-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px 24px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(100%, 320px);
}
.search .icon { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search-input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  font-size: 16px;
}
.search-input:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }

.selector-wrap {
  margin: 22px calc(var(--gutter) * -1) 0;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.selector-wrap::-webkit-scrollbar { display: none; }
.selector-wrap:empty { display: none; }

.selector {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.selector-btn {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.selector-btn:hover { color: var(--ink); }
.selector-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.bench-results { margin-top: 8px; }

.group { margin-top: 32px; }
.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.group-title { font-size: 1.25rem; font-weight: 650; font-stretch: 106%; }
.group-count { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 248px), 1fr));
  gap: 18px;
}
.bench-results > .grid { margin-top: 32px; }

.module {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}
.module::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 8px 8px, var(--screw-slot) 0 1px, var(--screw) 1.5px 3px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 8px) 8px, var(--screw-slot) 0 1px, var(--screw) 1.5px 3px, transparent 3.5px),
    radial-gradient(circle at 8px calc(100% - 8px), var(--screw-slot) 0 1px, var(--screw) 1.5px 3px, transparent 3.5px),
    radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--screw-slot) 0 1px, var(--screw) 1.5px 3px, transparent 3.5px);
}
a.module:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow); }
a.module:active { transform: translateY(0); }
.module:focus-visible { outline-offset: 3px; }

.module-body { flex: 1; display: grid; align-content: start; gap: 6px; }
.module-name { font-size: 1.0625rem; font-weight: 650; line-height: 1.35; }
.module-desc {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.module-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.module-id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-stretch: 87.5%;
  color: var(--ink-3);
}
.module-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-size: 14px;
  font-weight: 650;
}
a.module:hover .module-open { color: var(--ink); text-decoration: underline; text-decoration-color: var(--key-edge); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.module.is-placeholder { pointer-events: none; }
.module.is-placeholder .screen { background: var(--surface-2); box-shadow: none; }
.ph-line { height: 12px; border-radius: 6px; background: var(--surface-2); }
.ph-line.short { width: 60%; }

@media (max-width: 559px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .module { padding: 12px 12px 10px; gap: 10px; border-radius: 12px; }
  .module::before {
    background:
      radial-gradient(circle at 6px 6px, var(--screw) 0 2px, transparent 2.5px),
      radial-gradient(circle at calc(100% - 6px) 6px, var(--screw) 0 2px, transparent 2.5px);
  }
  .module-name { font-size: 15px; }
  .module-desc { font-size: 13px; }
  .module-foot { padding-top: 8px; }
  .module-id { display: none; }
  .module-open { font-size: 13px; }
  .search { width: 100%; }
}

.notice {
  display: grid;
  justify-items: start;
  gap: 10px;
  max-width: 560px;
  margin-top: 32px;
  padding: 24px;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
}
.notice-title { font-weight: 650; font-size: 1.0625rem; }
.notice .key { margin-top: 6px; }

/* ---------- Launch ---------- */

.launch { display: grid; place-items: center; min-height: 50dvh; }
.launch-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.launch-status { display: grid; gap: 8px; justify-items: start; }
.launch-status .title { font-size: 1.5rem; }
.launch-status .key { margin-top: 8px; }
.launch-id { font-stretch: 87.5%; }

/* ---------- Forms ---------- */

.auth { display: grid; place-items: center; min-height: 56dvh; }

.auth-panel {
  width: min(100%, 400px);
  display: grid;
  gap: 18px;
  padding: clamp(22px, 5vw, 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.auth-panel .key-block { margin-top: 4px; }

.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label { font-size: 14px; font-weight: 600; }
.optional { margin-left: 6px; font-weight: 400; color: var(--ink-3); }

.field input:not([type="checkbox"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  font-size: 16px;
  line-height: 1.4;
}
.field input:not([type="checkbox"]), .field select { height: 44px; }
.field textarea { resize: vertical; min-height: 84px; }
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6.5 3.5 3.5 3.5-3.5' fill='none' stroke='%23838a7b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.field input:disabled { color: var(--ink-3); background: var(--surface-2); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent);
}
.mono { font-family: var(--mono); font-size: 15px !important; }

.help { font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair-help { margin-top: -8px; }

.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.check input:disabled + span { color: var(--ink-3); }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; }

.form-error {
  padding: 10px 12px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  color: var(--bad);
  font-size: 14px;
  font-weight: 500;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.spacer { flex: 1; }

@media (max-width: 559px) {
  .pair { grid-template-columns: 1fr; gap: 16px; }
  .pair-help { margin-top: -10px; }
  .form-actions .key { flex: 1 1 100%; order: -1; }
  .form-actions .btn-outline { flex: 1 1 100%; justify-content: center; order: -1; }
}

/* ---------- Admin ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 18px calc(var(--gutter) * -1) 24px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 14px 12px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  box-shadow: inset 0 -2px 0 transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--key-edge); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 180px) auto;
  align-items: center;
  gap: 8px 20px;
  padding: 14px 12px 14px 18px;
}
.row + .row { border-top: 1px solid var(--line); }
.row-main { min-width: 0; display: grid; gap: 4px; }
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; }
.row-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-3);
}
.row-url { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 14px; color: var(--ink-2); }
.row-actions { display: flex; gap: 2px; }

.code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.badge-soft { border-color: var(--key-edge); background: color-mix(in srgb, var(--key) 22%, transparent); color: var(--ink); }

@media (max-width: 719px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; padding: 14px 8px 14px 14px; }
  .row-meta { grid-column: 1; grid-row: 2; font-size: 13px; }
  .row-actions { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; align-items: stretch; }
  .row-url { display: none; }
}

.kv { margin: 18px 0 0; display: grid; gap: 14px; }
.kv-row { display: grid; gap: 6px; }
.kv-row dt { justify-self: start; }
.kv-row dd { margin: 0; display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.kv-value {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kv-pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-x: auto;
}
.integration .kv { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.integration > .help { margin-top: 10px; }
.setup .help { margin-top: 14px; }

.status-list { margin: 0; display: grid; gap: 0; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.status-list > div { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; }
.status-list > div + div { border-top: 1px solid var(--line); }
.status-list dt { font-size: 15px; }
.status-list dd { margin: 0; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--good); }
.status.bad { color: var(--bad); }

/* ---------- Dialog ---------- */

dialog.sheet {
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 60px -20px rgba(15, 17, 13, 0.5);
}
dialog.sheet::backdrop { background: rgba(18, 20, 16, 0.5); backdrop-filter: blur(2px); }
.sheet-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 14px 22px;
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: 1.125rem; font-weight: 650; overflow-wrap: anywhere; }
.sheet-body { padding: 20px 22px 24px; overflow-y: auto; overscroll-behavior: contain; }

@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: sheet-in 160ms ease-out; }
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 559px) {
  dialog.sheet {
    width: 100vw;
    margin: auto 0 0;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
  }
  .sheet-inner { max-height: 92dvh; }
  .sheet-body { padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .sheet-head { padding-left: 16px; }
  @keyframes sheet-in {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[popover] { margin: 0; inset: auto auto calc(24px + env(safe-area-inset-bottom, 0px)) 50%; border: 0; overflow: visible; }
.toast.is-error { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
