:root {
  color-scheme: dark;
  --shell: #0b0f16;
  --panel: #111722;
  --panel-2: #17202c;
  --surface: #ffffff;
  --surface-soft: #f4f7fb;
  --ink: #111827;
  --text: #f8fafc;
  --muted: #a6b0bf;
  --muted-light: #5b6678;
  --line: #263142;
  --line-light: #d7dee8;
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --focus: #60a5fa;
  --green: #2fd477;
  --red: #dc2626;
  --yellow: #f6c445;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, .07);
  --dur-fast: 120ms;
  --dur-standard: 180ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
html { background: var(--shell); }
body {
  margin: 0;
  background: var(--shell);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--blue);
  font-weight: 750;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

button, input, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, a, input, textarea {
  outline-offset: 3px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(37, 99, 235, .16);
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
}
button:disabled { cursor: not-allowed; opacity: .58; }
button.is-busy { cursor: progress; }
button.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  flex: 0 0 auto;
  animation: spin 720ms linear infinite;
}
button.is-busy svg { display: none; }
button.is-success { color: #15803d !important; border-color: #16a34a !important; background-color: #f0fdf4 !important; }
button.is-error, .upload-button.is-error { color: #b91c1c !important; border-color: #dc2626 !important; background-color: #fef2f2 !important; }
@keyframes spin { to { transform: rotate(360deg); } }

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.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 { min-height: 100vh; background: var(--shell); }
.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: stretch;
  padding: 0 22px;
  background: var(--shell);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  min-width: 176px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--text);
  text-decoration: none;
  border-right: 1px solid var(--line);
  padding-right: 24px;
}
.brand strong { font-size: 21px; line-height: 1.1; font-weight: 800; }
.brand small { margin-top: 5px; color: var(--muted); font: 700 9px/1.2 Consolas, monospace; }

.tabs { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  min-width: 126px;
  height: 78px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #c5ccd6;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}
.tab small { color: #596271; font: 700 10px/1 Consolas, monospace; }
.tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
}
.tab:hover { color: #fff; background: #151c27; }
.tab.is-active { color: var(--focus); background: #141b26; }
.tab.is-active small { color: var(--blue); }
.tab.is-active::after { background: var(--blue); }

.connection-state {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 110px;
  margin-left: 20px;
  color: var(--green);
  font-weight: 750;
  white-space: nowrap;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.connection-state.is-offline { color: var(--red); }
.connection-state.is-loading { color: var(--yellow); }
.icon-button {
  align-self: center;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-left: 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}
.icon-button:hover { color: var(--blue); border-color: var(--blue); }
.icon-button:active { transform: scale(.94); }

.view { display: none; }
.view.is-active { display: block; animation: view-in 160ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
.remote-layout {
  min-height: calc(100vh - 78px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  background: var(--shell);
}
.remote-main { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.screen-panel { flex: 1 1 auto; min-height: 0; padding: 20px; background: var(--shell); }
.screen-stage {
  width: 100%;
  min-height: 360px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #020304;
  overflow: hidden;
}
.screen-toolbar { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }
.tool-button {
  min-height: 92px;
  padding: 10px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #c9d0da;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}
.tool-button:hover { color: var(--blue); background: #10151c; }
.tool-button:active svg { transform: scale(.86); }
.tool-button svg { transition: transform 120ms var(--ease); }
.screen-frame {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 294px);
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  contain: layout paint;
}
.screen-frame:focus-visible { outline: 3px solid var(--focus); outline-offset: -4px; }
.screen-frame:fullscreen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; background: #000; }
.screen-frame img, .screen-frame video, .screen-frame canvas { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.screen-frame video[hidden], .screen-frame img[hidden], .screen-frame canvas[hidden] { display: none; }
.screen-frame.is-fill img, .screen-frame.is-fill video, .screen-frame.is-fill canvas { object-fit: cover; }
.screen-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #e7edf6;
  background: #020304;
  text-align: center;
}
.screen-empty svg { width: 42px; height: 42px; color: var(--blue); }
.screen-empty strong { font-size: 17px; }
.screen-empty span { color: var(--muted); font-size: 13px; }
.screen-empty.is-hidden { display: none; }
.screen-retry {
  min-height: 38px;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 4px;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}
.screen-retry:hover { background: #101b2b; }
.live-label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  color: #fff;
  background: rgba(5, 6, 7, .86);
  border: 1px solid #303640;
  border-radius: 3px;
  font: 700 11px/1.2 Consolas, monospace;
  pointer-events: none;
}
.live-label span { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px var(--green); }

.control-bar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.key-actions, .inline-actions { display: flex; gap: 8px; }
.text-command {
  height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  border: 1px solid #3a424f;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #080a0d;
}
.text-command:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.text-command input { min-width: 0; border: 0; padding: 0 16px; color: var(--text); background: transparent; outline: 0; }
.text-command input::placeholder { color: #687384; }
.text-command button { border: 0; border-left: 1px solid #3a424f; background: transparent; color: var(--blue); display: grid; place-items: center; cursor: pointer; }
.text-command button:hover { background: #101b2b; }
.key-actions button, .secondary-button, .primary-button {
  min-height: 48px;
  border: 1px solid #3a424f;
  border-radius: var(--radius-sm);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), background-color 160ms var(--ease), transform 120ms var(--ease);
}
.key-actions button { min-width: 70px; padding: 6px 12px; flex-direction: column; gap: 0; background: #080a0d; }
.key-actions button:hover, .secondary-button:hover { color: var(--blue); border-color: var(--blue); background-color: #f8fafc; }
.key-actions button:active, .secondary-button:active, .primary-button:active { transform: scale(.96); }
.key-actions strong { font-size: 14px; }
.key-actions span { font-size: 10px; color: var(--muted); }
.telemetry-bar {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 600 11px/1.2 Consolas, monospace;
}
.telemetry-bar span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.telemetry-bar i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.telemetry-bar strong { color: #dbe3ee; font-weight: 700; }

.command-rail { padding: 24px 20px; background: var(--panel); }
.rail-section + .rail-section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 22px; }
.rail-section h2 { margin: 0 0 14px; font-size: 16px; line-height: 1.3; }
.rail-section h2::before { content: "//"; margin-right: 8px; color: var(--blue); font-family: Consolas, monospace; }
.status-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  color: var(--muted);
}
.status-row svg { width: 19px; height: 19px; color: var(--green); }
.status-row strong { color: var(--green); font: 700 12px/1 Consolas, monospace; }
.action-row {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}
.action-row:hover { color: var(--blue); background: #10141a; }
.action-row.danger { color: var(--red); }
.action-row svg { width: 21px; height: 21px; }
.action-row > svg, .action-row > span { transition: transform var(--dur-fast) var(--ease); }
.action-row:hover > svg, .action-row:hover > span { transform: translateX(4px); }

.content-view { width: min(1040px, calc(100% - 48px)); min-height: calc(100vh - 78px); margin: 0 auto; padding: 48px 0 80px; color: var(--ink); contain: layout style; }
.content-view.is-active { display: block; }
main:has(.content-view.is-active) { background: var(--surface-soft); }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-light);
  margin-bottom: 20px;
}
.page-heading h1 { margin: 2px 0 0; font-size: 31px; line-height: 1.15; }
.page-heading small { color: var(--blue); font: 700 10px/1.2 Consolas, monospace; }
.page-heading > span { color: var(--muted-light); font-size: 13px; }
.action-list { display: grid; grid-template-columns: 1fr 1fr; }
.action-item {
  min-height: 100px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line-light);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease), transform 160ms var(--ease);
}
.action-item:nth-child(odd) { border-right: 1px solid var(--line-light); }
.action-item:hover { color: var(--blue); background: #fff; transform: translateY(-2px); }
.action-item svg { width: 27px; height: 27px; }
.action-item span { display: flex; flex-direction: column; gap: 3px; }
.action-item strong { font-size: 16px; }
.action-item small { color: var(--muted-light); font-size: 12px; }
.field-label { display: block; margin: 24px 0 8px; font-weight: 750; }
textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid #b8c0cc;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  padding: 15px;
}
.inline-actions { justify-content: flex-end; margin-top: 14px; }
.content-view .secondary-button { color: var(--ink); border-color: #b8c0cc; background: var(--surface); }
.primary-button { background: var(--blue); border-color: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.upload-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  margin: 18px 0 14px;
  padding: 0 16px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  color: var(--blue);
  background: var(--surface);
  font-weight: 750;
  cursor: pointer;
}
.upload-button:hover { color: #fff; background: var(--blue); }
.upload-button:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.upload-button[aria-busy="true"] { pointer-events: none; }
.upload-button.is-busy > svg, .upload-button.is-busy > span { visibility: hidden; }
.upload-button.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  position: absolute;
  left: calc(50% - 42px);
  top: calc(50% - 9px);
  animation: spin 720ms linear infinite;
}
.upload-button.is-busy::after { content: "上传中…"; position: absolute; left: calc(50% - 18px); top: 50%; transform: translateY(-50%); }
.upload-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.file-list { border-top: 1px solid var(--line-light); }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; min-height: 70px; border-bottom: 1px solid var(--line-light); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.file-meta { color: var(--muted-light); font-size: 12px; white-space: nowrap; }
.file-download { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--blue); cursor: pointer; }
.file-download:hover { border-color: var(--blue); background: #fff; }
.empty-row { padding: 36px 0; color: var(--muted-light); text-align: center; }
.file-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px 16px;
  color: var(--muted-light);
  text-align: center;
  overflow-wrap: anywhere;
}
.file-state svg { width: 28px; height: 28px; color: var(--blue); }
.file-state.is-loading svg { animation: spin 720ms linear infinite; }
.file-state.is-error svg { color: var(--red); }
.file-state button { min-height: 44px; padding: 0 14px; border: 1px solid var(--blue); border-radius: var(--radius-sm); background: #fff; color: var(--blue); font-weight: 700; cursor: pointer; }
.settings-list { margin: 0; }
.settings-list > div { display: grid; grid-template-columns: 150px 1fr; gap: 20px; padding: 19px 0; border-bottom: 1px solid var(--line-light); }
.settings-list dt { color: var(--muted-light); }
.settings-list dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.logout-button { margin-top: 28px; color: var(--red) !important; }
.remote-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 1px;
  padding: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}
.remote-command-grid button {
  min-height: 44px;
  border: 0;
  background: var(--panel);
  color: #cbd3df;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.remote-command-grid button:hover { color: var(--blue); background: #10151c; }
.action-groups { display: grid; gap: 30px; padding-top: 8px; }
.action-group h2 { margin: 0; padding: 18px 0 9px; border-bottom: 1px solid var(--line-light); font-size: 18px; }
.action-group .action-list { border-bottom: 1px solid var(--line-light); }
.secure-result, .control-card {
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading small { color: var(--blue); font: 700 10px/1.2 Consolas, monospace; }
.section-heading h2 { margin: 3px 0 0; font-size: 20px; }
.section-heading > span, .section-heading > strong { color: var(--muted-light); font-size: 12px; }
.toolbar-row, .file-actions { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; }
.search-field { flex: 1 1 auto; }
.search-field input, .form-grid input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #b8c0cc;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
}
.managed-list { margin-top: 14px; border-top: 1px solid var(--line-light); }
.managed-row {
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-light);
}
.managed-copy { min-width: 0; display: grid; gap: 3px; }
.managed-copy strong { overflow-wrap: anywhere; }
.managed-copy small { color: var(--muted-light); overflow-wrap: anywhere; }
.managed-row button { min-width: 92px; }
.managed-row, .file-row, .action-item { content-visibility: auto; contain-intrinsic-size: auto 72px; }
.list-state { padding: 34px 12px; color: var(--muted-light); text-align: center; }
.file-actions .upload-button { margin: 0; }
.danger-outline-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: #b91c1c;
  font-weight: 750;
  cursor: pointer;
}
.danger-outline-button:hover { background: #fff4f3; }
.system-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.system-grid .control-card { margin-top: 0; }
.control-card.full-width { width: 100%; }
.settings-list.compact { margin-top: 12px; }
.settings-list.compact > div { grid-template-columns: 112px minmax(0, 1fr); padding: 12px 0; }
.inline-actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted-light); font-size: 12px; font-weight: 700; }
.field-help { margin: 14px 0 0; color: var(--muted-light); font-size: 12px; }
.sensitive-card { border-color: #efc3c1; }
.credential-list { display: grid; gap: 10px; margin-top: 18px; }
.credential-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line-light); background: var(--surface-soft); }
.credential-row strong { font-size: 12px; }
.credential-row code { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--ink); }
.session-actions { display: flex; justify-content: flex-end; }
.network-banner {
  position: fixed;
  top: 94px;
  right: 20px;
  z-index: 60;
  width: min(410px, calc(100% - 40px));
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #5f302f;
  border-left: 3px solid var(--red);
  border-radius: 4px;
  background: #151011;
  color: var(--text);
}
.network-banner > span { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 8px; }
.network-banner i { grid-row: 1 / 3; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.network-banner strong { font-size: 13px; }
.network-banner small { color: #b9a7a7; white-space: normal; }
.network-banner button { flex: 0 0 auto; min-height: 44px; padding: 0 12px; border: 1px solid #6f4140; border-radius: var(--radius-sm); background: transparent; color: #ffd3d1; font-weight: 700; cursor: pointer; }

.auth-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: var(--shell); }
.auth-screen.is-hidden { display: none; }
.auth-panel { width: min(470px, 100%); padding: 38px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 24px 70px rgba(0, 0, 0, .28); }
.auth-mark { width: 52px; height: 52px; display: grid; place-items: center; color: var(--focus); border: 1px solid var(--blue); border-radius: var(--radius-md); }
.auth-mark svg { width: 28px; height: 28px; }
.auth-kicker { display: block; margin-top: 24px; color: var(--blue); font: 700 10px/1.2 Consolas, monospace; }
.auth-panel h1 { margin: 4px 0 28px; font-size: 30px; }
.auth-panel label { display: block; margin-bottom: 8px; font-weight: 700; }
.auth-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.auth-input-row input { min-width: 0; height: 50px; border: 1px solid #404753; border-right: 0; border-radius: 4px 0 0 4px; padding: 0 12px; color: var(--text); background: #07090c; }
.auth-input-row button { height: 50px; border: 1px solid var(--blue); border-radius: 0 4px 4px 0; padding: 0 22px; background: var(--blue); color: #fff; font-weight: 750; cursor: pointer; }
.auth-error { min-height: 22px; margin: 10px 0 0; color: var(--red); font-size: 13px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: min(380px, calc(100vw - 40px)); padding: 12px 14px; border: 1px solid #3a424f; border-left: 3px solid var(--green); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); font-size: 13px; animation: toast-in var(--dur-standard) var(--ease); }
.toast.is-error { border-left-color: var(--red); color: #ffd9d7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.confirm-dialog {
  width: min(470px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #343b46;
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .76); }
.confirm-dialog[open] { animation: dialog-in 180ms var(--ease); }
.confirm-dialog form { padding: 28px; }
.confirm-dialog small { color: var(--red); font: 700 10px/1.2 Consolas, monospace; }
.confirm-dialog h2 { margin: 6px 0 8px; font-size: 24px; }
.confirm-dialog p { min-height: 42px; margin: 0; color: #aab4c2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.danger-button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: var(--red);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}
.danger-button:hover { background: #df322d; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

@media (max-width: 1120px) {
  .topbar { padding: 0 16px; }
  .brand { min-width: 146px; padding-right: 16px; }
  .tab { min-width: 102px; }
  .tab small { display: none; }
  .remote-layout { grid-template-columns: minmax(0, 1fr) 248px; }
  .screen-stage { grid-template-columns: 58px minmax(0, 1fr); }
  .tool-button { min-height: 78px; }
  .tool-button span { display: none; }
  .telemetry-bar { gap: 14px; }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .brand { height: 62px; min-width: 0; border: 0; padding: 0; }
  .brand strong { font-size: 19px; }
  .brand small { font-size: 8px; }
  .connection-state { margin-left: 0; min-width: auto; font-size: 13px; }
  .desktop-fullscreen { display: none; }
  .tabs { grid-column: 1 / -1; order: 3; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 -14px; border-top: 1px solid var(--line); overflow: visible; }
  .tab { height: 64px; min-width: 0; padding: 5px 2px; flex-direction: column; font-size: 11px; gap: 3px; }
  .tab svg { width: 18px; height: 18px; }
  .tab-settings { min-width: 0; }
  .network-banner { top: 132px; right: 12px; width: calc(100% - 24px); }
  .remote-layout { min-height: 0; display: block; }
  .remote-main { border: 0; }
  .screen-panel { padding: 12px; }
  .screen-stage { min-height: 0; display: flex; flex-direction: column; }
  .screen-toolbar { height: 48px; flex-direction: row; border: 0; border-bottom: 1px solid var(--line); }
  .tool-button { min-height: 48px; flex: 1; flex-direction: row; gap: 4px; border: 0; border-right: 1px solid var(--line); padding: 0 4px; }
  .tool-button span { display: none; }
  .screen-frame { max-height: none; }
  .live-label { left: 7px; bottom: 7px; padding: 4px 7px; font-size: 9px; }
  .control-bar { display: flex; flex-direction: column; align-items: stretch; min-height: 0; padding: 12px; gap: 10px; }
  .text-command { width: 100%; }
  .key-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .key-actions button { min-width: 0; }
  .telemetry-bar { min-height: 42px; padding: 8px 12px; flex-wrap: wrap; overflow: visible; }
  .telemetry-bar span { white-space: normal; }
  .telemetry-bar span:first-child { display: none; }
  .command-rail { border-top: 1px solid var(--line); padding: 22px 16px 36px; }
  .status-section { display: none; }
  .rail-section + .rail-section { border: 0; margin: 0; padding: 0; }
  .content-view { width: calc(100% - 30px); min-height: calc(100vh - 120px); padding: 28px 0 54px; }
  .page-heading h1 { font-size: 26px; }
  .action-list { grid-template-columns: 1fr; }
  .action-item:nth-child(odd) { border-right: 0; }
  .remote-command-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toolbar-row, .file-actions { align-items: stretch; flex-direction: column; }
  .toolbar-row > *, .file-actions > * { width: 100%; }
  .file-actions .upload-button { justify-content: center; }
  .system-grid, .form-grid { grid-template-columns: 1fr; }
  .control-card { padding: 18px 15px; }
  .credential-row { grid-template-columns: 1fr auto; }
  .credential-row code { grid-column: 1 / -1; grid-row: 2; }
  .managed-row { align-items: stretch; grid-template-columns: 1fr; }
  .managed-row button { width: 100%; }
  .file-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .file-meta { grid-column: 1; grid-row: 2; padding-bottom: 10px; overflow: hidden; text-overflow: ellipsis; }
  .file-download { grid-column: 2; grid-row: 1 / 3; }
  .settings-list > div { grid-template-columns: 100px minmax(0, 1fr); }
  .auth-panel { padding: 28px 22px; }
  .toast-region { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
  .tab { min-width: 0; }
  .tab span { font-size: 9px; }
  .tool-button { font-size: 10px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .auth-input-row { grid-template-columns: 1fr; }
  .auth-input-row input { border-right: 1px solid #404753; border-radius: 4px 4px 0 0; }
  .auth-input-row button { border-radius: 0 0 4px 4px; }
  .network-banner { align-items: stretch; flex-direction: column; }
  .network-banner button { width: 100%; }
  .file-name { white-space: normal; overflow-wrap: anywhere; }
}

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

@media (forced-colors: active) {
  button, input, textarea, .tab, .control-card, .managed-row, .file-row { border-color: CanvasText; }
  .tab.is-active, button:focus-visible, input:focus-visible, textarea:focus-visible, .screen-frame:focus-visible { outline: 2px solid Highlight; }
  .status-dot, .live-label span, .telemetry-bar i, .network-banner i { background: Highlight; forced-color-adjust: none; }
}
