:root {
  color-scheme: dark;
  --background: #0b0d0c;
  --surface: rgba(29, 32, 30, 0.72);
  --surface-solid: #1b1e1c;
  --surface-raised: rgba(42, 46, 43, 0.72);
  --surface-hover: rgba(255, 255, 255, 0.075);
  --separator: rgba(255, 255, 255, 0.095);
  --separator-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7f5;
  --text-secondary: rgba(235, 242, 237, 0.62);
  --text-tertiary: rgba(235, 242, 237, 0.4);
  --accent: #79e69a;
  --accent-strong: #8df0a8;
  --accent-ink: #092311;
  --blue: #64a8ff;
  --amber: #f3be61;
  --red: #ff6961;
  --green: #74e293;
  --radius-small: 12px;
  --radius-medium: 18px;
  --radius-large: 24px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.045) inset, 0 18px 45px rgba(0, 0, 0, 0.2);
  --shadow-float: 0 24px 80px rgba(0, 0, 0, 0.48), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 74% -20%, rgba(81, 167, 111, 0.12), transparent 35rem),
    linear-gradient(145deg, #0d100e 0%, var(--background) 55%, #090b0a 100%);
  font: 400 1rem/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient i {
  position: absolute;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.1;
}

.ambient i:first-child { top: -20rem; right: -6rem; background: #56de86; }
.ambient i:last-child { bottom: -26rem; left: 22%; background: #4a8dff; opacity: 0.055; }

.overline {
  margin: 0 0 0.38rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.secondary-text { margin: 0; color: var(--text-secondary); }

.app-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 1.18rem;
  color: var(--accent-ink);
  background: linear-gradient(145deg, #a0f5b7, #62d989);
  box-shadow: 0 12px 32px rgba(86, 222, 134, 0.2), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

.app-icon::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), transparent 44%);
  pointer-events: none;
}

.app-icon span { position: relative; z-index: 1; font-size: 1.65rem; font-weight: 800; letter-spacing: -0.05em; }
.app-icon.small { width: 2.65rem; height: 2.65rem; border-radius: 0.82rem; box-shadow: 0 8px 22px rgba(86, 222, 134, 0.14), 0 1px 0 rgba(255, 255, 255, 0.55) inset; }
.app-icon.small span { font-size: 1.04rem; }

/* Authentication */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(25rem, 100%);
  padding: 2.4rem;
  border: 1px solid var(--separator);
  border-radius: 1.75rem;
  background: rgba(24, 28, 25, 0.7);
  backdrop-filter: blur(32px) saturate(155%);
  -webkit-backdrop-filter: blur(32px) saturate(155%);
  box-shadow: var(--shadow-float);
  animation: materialize 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-copy { margin: 1.5rem 0 1.8rem; }
.login-copy h1 { margin: 0; font-size: 2rem; font-weight: 720; line-height: 1.1; letter-spacing: -0.035em; }
.login-copy .secondary-text { margin-top: 0.65rem; font-size: 0.9rem; }
.field-group { margin-bottom: 0.9rem; }
.field-group label { display: block; margin: 0 0 0.48rem 0.18rem; color: var(--text-secondary); font-size: 0.78rem; font-weight: 600; }

input {
  width: 100%;
  min-height: 3rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--separator-strong);
  border-radius: var(--radius-small);
  outline: none;
  color: var(--text);
  background: rgba(4, 7, 5, 0.42);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus { border-color: rgba(121, 230, 154, 0.78); background: rgba(6, 10, 7, 0.6); box-shadow: 0 0 0 4px rgba(121, 230, 154, 0.12); }
.login-card .button.large { width: 100%; min-height: 3rem; }
.passkey-login-area { margin-top: 0.65rem; }
.login-separator { display: flex; align-items: center; gap: 0.7rem; margin: 0.15rem 0 0.65rem; color: var(--text-tertiary); font-size: 0.68rem; }
.login-separator::before, .login-separator::after { content: ""; height: 1px; flex: 1; background: var(--separator); }
.form-error { min-height: 1.3rem; margin: 0.75rem 0 0; color: #ff8d88; font-size: 0.78rem; }
.login-footnote { margin: 0.4rem 0 0; text-align: center; color: var(--text-tertiary); font-size: 0.7rem; }

/* Shell */
.app-shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.45rem 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.065);
  background: rgba(17, 20, 18, 0.68);
  backdrop-filter: blur(30px) saturate(145%);
  -webkit-backdrop-filter: blur(30px) saturate(145%);
  display: flex;
  flex-direction: column;
  z-index: 4;
}

.brand { display: flex; align-items: center; gap: 0.8rem; padding: 0 0.6rem 2rem; }
.brand-copy { display: flex; min-width: 0; flex-direction: column; }
.brand-copy strong { font-size: 0.98rem; font-weight: 680; letter-spacing: -0.015em; }
.brand-copy small { margin-top: 0.08rem; color: var(--text-tertiary); font-size: 0.69rem; }

.sidebar nav { display: grid; gap: 0.28rem; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.78rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.62rem 0.78rem;
  border: 0;
  border-radius: 0.76rem;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 0.84rem;
  font-weight: 540;
  transition: color 140ms ease, background 140ms ease, transform 100ms ease-out;
}

.nav-item svg, .button svg, .icon-button svg, .safety-note svg {
  width: 1.18rem;
  height: 1.18rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.052); }
.nav-item.active { color: var(--text); background: rgba(255, 255, 255, 0.09); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset; }
.nav-item.active svg { color: var(--accent); }
.nav-item:active { transform: scale(0.975); transition-duration: 60ms; }

.sidebar-footer { margin-top: auto; padding: 1rem 0.62rem 0; border-top: 1px solid var(--separator); }
.connection-state { display: flex; align-items: center; gap: 0.68rem; }
.connection-state > div { display: flex; min-width: 0; flex-direction: column; }
.connection-state strong { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); }
.connection-state small { color: var(--text-tertiary); font-size: 0.64rem; }

main { min-width: 0; width: min(100%, 92rem); padding: 0 2.25rem 4rem; margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 7.2rem;
  margin-bottom: 0.2rem;
  padding: 1.25rem 0;
  background: linear-gradient(to bottom, rgba(11, 13, 12, 0.94) 64%, rgba(11, 13, 12, 0));
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.title-group h1 { margin: 0; font-size: clamp(1.85rem, 2.8vw, 2.45rem); font-weight: 730; line-height: 1.08; letter-spacing: -0.045em; }
.header-actions, .button-row { display: flex; align-items: center; gap: 0.58rem; }
.last-refresh { color: var(--text-tertiary); font-size: 0.69rem; }
.action-divider { width: 1px; height: 1.5rem; margin: 0 0.14rem; background: var(--separator); }

/* Controls */
.button, .icon-button {
  position: relative;
  border: 1px solid transparent;
  outline: none;
  cursor: pointer;
  user-select: none;
  transition: transform 100ms ease-out, background 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.55rem;
  padding: 0.58rem 1rem;
  border-radius: 0.78rem;
  font-size: 0.78rem;
  font-weight: 650;
}

.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: scale(0.96); transition-duration: 55ms; }
.button:disabled { opacity: 0.34; cursor: not-allowed; }
.button.primary { color: var(--accent-ink); background: linear-gradient(180deg, var(--accent-strong), var(--accent)); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 8px 20px rgba(70, 211, 111, 0.12); }
.button.primary:hover:not(:disabled) { filter: brightness(1.045); }
.button.secondary { color: var(--text); border-color: var(--separator); background: rgba(255, 255, 255, 0.055); }
.button.secondary:hover { background: rgba(255, 255, 255, 0.09); }
.button.destructive { color: #ff918b; border-color: rgba(255, 105, 97, 0.18); background: rgba(255, 105, 97, 0.085); }
.button.quiet { color: var(--text-secondary); border-color: transparent; background: transparent; }
.button.quiet:hover { color: var(--text); background: var(--surface-hover); }
.button.link-button { min-height: 2rem; padding: 0.3rem 0.6rem; color: var(--accent); background: transparent; }
.logout-button svg { width: 1.05rem; height: 1.05rem; }
.passkey-settings-button svg { width: 1.05rem; height: 1.05rem; }

.icon-button {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  border-radius: 50%;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.055);
}

.icon-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.095); }
.icon-button svg { width: 1.08rem; height: 1.08rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.small-button { width: 2.2rem; height: 2.2rem; }
.icon-button.spinning svg { animation: spin 700ms linear infinite; }

button:focus-visible, input:focus-visible { outline: 3px solid rgba(100, 168, 255, 0.72); outline-offset: 2px; }

/* Content */
.page { display: none; }
.page.active { display: block; animation: page-in 300ms cubic-bezier(0.22, 1, 0.36, 1) both; }

.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.82rem; margin-bottom: 0.82rem; }

.card {
  border: 1px solid var(--separator);
  border-radius: var(--radius-medium);
  background: linear-gradient(145deg, rgba(34, 38, 35, 0.76), rgba(24, 27, 25, 0.72));
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
}

.status-card, .metric-card { min-height: 9.3rem; padding: 1.25rem; }
.metric-label { display: flex; align-items: center; justify-content: space-between; min-height: 1rem; color: var(--text-secondary); font-size: 0.72rem; font-weight: 550; }
.status-card > strong, .metric-card > strong { display: block; margin-top: 1.25rem; font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 690; line-height: 1.05; letter-spacing: -0.035em; }
.status-card > small, .metric-card > small { display: block; margin-top: 0.62rem; color: var(--text-tertiary); font-size: 0.68rem; }

.status-dot { display: inline-block; width: 0.48rem; height: 0.48rem; border-radius: 50%; background: #69706b; box-shadow: 0 0 0 0.24rem rgba(105, 112, 107, 0.1); }
.status-dot.good { background: var(--green); box-shadow: 0 0 0 0.24rem rgba(116, 226, 147, 0.11); }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 0 0.24rem rgba(243, 190, 97, 0.11); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 0.24rem rgba(255, 105, 97, 0.11); }

.main-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(19rem, 0.8fr); gap: 0.82rem; }
.operation-card, .remote-card, .log-preview, .residue-card { padding: 1.45rem; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-heading h2 { margin: 0; font-size: 1.12rem; font-weight: 660; line-height: 1.25; letter-spacing: -0.025em; }
.card-description { max-width: 42rem; margin: 1.15rem 0 0; color: var(--text-secondary); font-size: 0.8rem; line-height: 1.65; }

.badge { display: inline-flex; align-items: center; gap: 0.42rem; padding: 0.34rem 0.62rem; border-radius: 999px; font-size: 0.66rem; font-weight: 650; white-space: nowrap; }
.badge i { width: 0.38rem; height: 0.38rem; border-radius: 50%; background: currentColor; }
.badge.success { color: var(--accent); background: rgba(121, 230, 154, 0.09); border: 1px solid rgba(121, 230, 154, 0.16); }

.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 1.55rem 0; padding: 0; list-style: none; }
.flow li { position: relative; display: flex; align-items: center; gap: 0.48rem; color: var(--text-secondary); font-size: 0.68rem; white-space: nowrap; }
.flow li:not(:last-child)::after { content: ""; height: 1px; flex: 1; margin: 0 0.55rem; background: var(--separator-strong); }
.flow li span { display: grid; place-items: center; width: 1.42rem; height: 1.42rem; flex: 0 0 auto; border-radius: 50%; color: var(--accent); background: rgba(121, 230, 154, 0.1); font-size: 0.62rem; font-weight: 700; }
.safety-note { display: flex; align-items: center; gap: 0.45rem; margin: 1rem 0 0; color: var(--text-tertiary); font-size: 0.68rem; }
.safety-note svg { width: 0.9rem; height: 0.9rem; color: var(--accent); }

.remote-card dl { margin: 1rem 0 0; }
.remote-card dl div { display: flex; align-items: center; justify-content: space-between; min-height: 2.45rem; border-bottom: 1px solid rgba(255, 255, 255, 0.065); }
.remote-card dl div:last-child { border-bottom: 0; }
.remote-card dt { color: var(--text-secondary); font-size: 0.72rem; }
.remote-card dd { margin: 0; font-size: 0.76rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.upload-progress { margin-top: 1rem; padding: 0.85rem; border-radius: var(--radius-small); background: rgba(121, 230, 154, 0.065); }
.upload-progress > div:first-child { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: 0.68rem; }
.progress-track { height: 0.28rem; margin: 0.62rem 0; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.progress-track i { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--accent); animation: progress-breathe 1.4s ease-in-out infinite alternate; }
.upload-progress small { display: block; overflow: hidden; color: var(--text-tertiary); font-size: 0.62rem; text-overflow: ellipsis; white-space: nowrap; }

.log-preview { margin-top: 0.82rem; }
.log-preview pre, .terminal-card pre { white-space: pre-wrap; word-break: break-word; color: rgba(224, 235, 227, 0.7); font: 0.7rem/1.68 "SFMono-Regular", "Cascadia Code", Consolas, monospace; }
.log-preview pre { max-height: 12rem; margin: 1rem 0 0; overflow: auto; }

.error-banner { margin-bottom: 0.82rem; padding: 0.8rem 1rem; border: 1px solid rgba(255, 105, 97, 0.2); border-radius: var(--radius-small); color: #ffaaa5; background: rgba(255, 105, 97, 0.09); font-size: 0.75rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.82rem; min-height: 2.6rem; }
.section-heading .secondary-text { font-size: 0.78rem; }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.95rem 1.15rem; border-bottom: 1px solid rgba(255, 255, 255, 0.07); text-align: left; font-size: 0.72rem; }
th { color: var(--text-tertiary); background: rgba(255, 255, 255, 0.022); font-size: 0.62rem; font-weight: 650; letter-spacing: 0.055em; text-transform: uppercase; }
td:first-child { color: rgba(235, 242, 237, 0.82); font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace; }
tbody tr { transition: background 130ms ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.empty { padding: 3.5rem !important; color: var(--text-tertiary) !important; text-align: center !important; font-family: inherit !important; }

.residue-card { margin-top: 0.82rem; }
.count-badge { display: grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 0.55rem; border-radius: 999px; color: var(--text-secondary); background: rgba(255, 255, 255, 0.06); font-size: 0.7rem; font-weight: 650; }
.residue-list { margin-top: 1rem; }
.residue-item { display: flex; justify-content: space-between; gap: 1rem; padding: 0.72rem 0; border-top: 1px solid var(--separator); color: var(--text-secondary); font: 0.68rem/1.4 "SFMono-Regular", "Cascadia Code", Consolas, monospace; }

.terminal-card { overflow: hidden; background: rgba(15, 18, 16, 0.82); }
.terminal-head { display: flex; align-items: center; min-height: 3rem; padding: 0 1rem; border-bottom: 1px solid var(--separator); background: rgba(255, 255, 255, 0.025); }
.window-controls { display: flex; gap: 0.38rem; }
.window-controls i { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: #ff655f; }
.window-controls i:nth-child(2) { background: #f5bd4f; }
.window-controls i:nth-child(3) { background: #5acb65; }
.terminal-head strong { margin-left: 0.85rem; color: var(--text-tertiary); font: 0.65rem "SFMono-Regular", "Cascadia Code", Consolas, monospace; }
.live-indicator { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: auto; color: var(--text-tertiary); font-size: 0.62rem; }
.live-indicator i { width: 0.38rem; height: 0.38rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0.2rem rgba(116, 226, 147, 0.09); }
.terminal-card pre { min-height: 31rem; max-height: calc(100vh - 14rem); margin: 0; padding: 1.1rem 1.25rem 1.5rem; overflow: auto; }

/* Modal and feedback */
dialog {
  width: min(28rem, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--separator-strong);
  border-radius: var(--radius-large);
  color: var(--text);
  background: rgba(38, 42, 39, 0.88);
  backdrop-filter: blur(34px) saturate(160%);
  -webkit-backdrop-filter: blur(34px) saturate(160%);
  box-shadow: var(--shadow-float);
}

dialog[open] { animation: dialog-in 280ms cubic-bezier(0.22, 1, 0.36, 1) both; }
dialog::backdrop { background: rgba(0, 0, 0, 0.58); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
dialog form { padding: 1.65rem; }
.dialog-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin-bottom: 1rem; border-radius: 0.8rem; color: var(--accent); background: rgba(121, 230, 154, 0.1); }
.dialog-icon svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
dialog h2 { margin: 0; font-size: 1.3rem; font-weight: 690; letter-spacing: -0.025em; }
dialog p:not(.overline) { margin: 0.75rem 0 0; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.65; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.55rem; margin-top: 1.5rem; }
.passkey-list { display: grid; gap: 0.55rem; margin-top: 1.25rem; }
.passkey-item { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.72rem 0.8rem; border: 1px solid var(--separator); border-radius: var(--radius-small); background: rgba(255, 255, 255, 0.035); }
.passkey-item > div { display: flex; min-width: 0; flex-direction: column; }
.passkey-item strong { overflow: hidden; font-size: 0.78rem; font-weight: 630; text-overflow: ellipsis; white-space: nowrap; }
.passkey-item small { margin-top: 0.2rem; color: var(--text-tertiary); font-size: 0.64rem; }
.passkey-remove { min-height: 2rem; padding: 0.3rem 0.55rem; color: #ff918b; background: transparent; }
.passkey-register { margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--separator); }
.passkey-register > label { display: block; margin: 0 0 0.48rem 0.18rem; color: var(--text-secondary); font-size: 0.72rem; font-weight: 600; }
.passkey-register-row { display: grid; grid-template-columns: 1fr auto; gap: 0.55rem; }

.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 10; max-width: min(24rem, calc(100% - 2.5rem)); padding: 0.8rem 1rem; border: 1px solid var(--separator-strong); border-radius: var(--radius-small); color: var(--text); background: rgba(43, 48, 44, 0.9); backdrop-filter: blur(20px) saturate(145%); -webkit-backdrop-filter: blur(20px) saturate(145%); box-shadow: var(--shadow-float); font-size: 0.75rem; animation: toast-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.toast.error { color: #ffaaa5; border-color: rgba(255, 105, 97, 0.22); background: rgba(74, 31, 30, 0.88); }

@keyframes materialize { from { opacity: 0; transform: scale(0.97) translateY(0.5rem); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes page-in { from { opacity: 0; transform: translateY(0.35rem); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.94) translateY(0.65rem); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.7rem) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes progress-breathe { to { opacity: 0.48; transform: scaleX(1.18); transform-origin: left; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 5.2rem minmax(0, 1fr); }
  .sidebar { align-items: center; padding-inline: 0.7rem; }
  .brand { padding-inline: 0; }
  .brand-copy, .connection-state > div { display: none; }
  .sidebar nav { width: 100%; }
  .nav-item { justify-content: center; }
  .nav-item span { display: none; }
  .sidebar-footer { width: 100%; display: grid; place-items: center; padding-inline: 0; }
  main { padding-inline: 1.4rem; }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: auto; right: 0; bottom: 0; left: 0; width: 100%; height: 4.35rem; padding: 0.5rem max(0.65rem, env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left)); border-top: 1px solid var(--separator); border-right: 0; background: rgba(19, 22, 20, 0.78); }
  .brand, .sidebar-footer { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; width: 100%; }
  .nav-item { min-height: 3.1rem; flex-direction: column; justify-content: center; gap: 0.15rem; padding: 0.25rem; border-radius: 0.72rem; }
  .nav-item span { display: block; font-size: 0.58rem; }
  .nav-item svg { width: 1.1rem; height: 1.1rem; }
  main { padding: 0 0.9rem 6rem; }
  .topbar { min-height: 6rem; padding: 1rem 0; }
  .title-group .overline { display: none; }
  .title-group h1 { font-size: 1.65rem; }
  .last-refresh, .action-divider { display: none; }
  .header-actions { gap: 0.32rem; }
  .logout-button { width: 2.55rem; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.055) !important; }
  .logout-button span { display: none; }
  .passkey-settings-button { width: 2.55rem; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.055) !important; }
  .passkey-settings-button span { display: none; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.58rem; }
  .status-card, .metric-card { min-height: 8.1rem; padding: 1rem; }
  .status-card > strong, .metric-card > strong { font-size: 1.35rem; }
  .operation-card, .remote-card, .log-preview, .residue-card { padding: 1.15rem; }
  .flow { grid-template-columns: repeat(2, 1fr); row-gap: 0.8rem; }
  .flow li:nth-child(2)::after { display: none; }
  .section-heading { align-items: flex-start; }
  .section-heading > .secondary-text { max-width: 55%; }
  .terminal-card pre { min-height: 25rem; }
}

@media (max-width: 390px) {
  .status-grid { grid-template-columns: 1fr; }
  .button-row { align-items: stretch; flex-direction: column; }
  .button-row .button { width: 100%; }
  .card-heading { align-items: flex-start; }
  .passkey-register-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .page.active, .login-card, dialog[open], .toast { transform: none !important; filter: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .card, .login-card, dialog, .toast { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --separator: rgba(255, 255, 255, 0.28); --separator-strong: rgba(255, 255, 255, 0.45); --text-secondary: rgba(255, 255, 255, 0.82); }
  .card, .sidebar, .login-card { border-color: var(--separator-strong); }
}
