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

:root {
  color-scheme: dark;
  --bg: #0a0f17;
  --sidebar: #0f1621;
  --surface: #131c28;
  --surface-raised: #182332;
  --surface-hover: #1d2a3b;
  --border: rgba(148, 163, 184, .16);
  --border-strong: rgba(148, 163, 184, .28);
  --text: #edf3fb;
  --muted: #91a0b5;
  --subtle: #64748b;
  --accent: #6ea8fe;
  --accent-strong: #3b82f6;
  --green: #4ade80;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #fb7185;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow: 0 16px 44px rgba(0, 0, 0, .22);
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  overflow: hidden;
}

button, input, select { font: inherit; }
button {
  min-height: 36px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
button:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .42; }
button.primary {
  color: white;
  background: var(--accent-strong);
  border-color: rgba(110, 168, 254, .7);
  font-weight: 650;
}
button.primary:hover:not(:disabled) { background: #4b8ef7; color: white; }

input, select {
  min-height: 38px;
  color: var(--text);
  background: #0d1520;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 10px;
}
input::placeholder { color: var(--subtle); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(110, 168, 254, .35);
  outline-offset: 2px;
  border-color: var(--accent);
}

.app-shell {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}

.app-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 5px; }
.brand-mark, .auth-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(110, 168, 254, .46);
  border-radius: 11px;
  color: #dbeafe;
  background: rgba(59, 130, 246, .18);
  font-size: 17px;
  font-weight: 750;
  box-shadow: inset 0 0 18px rgba(59, 130, 246, .12);
}
.brand-copy { min-width: 0; display: flex; flex-direction: column; }
.brand-copy strong { font-size: 15px; letter-spacing: .2px; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.view-tabs { display: grid; gap: 5px; margin-top: 28px; }
.tab {
  position: relative;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  padding: 9px 13px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  text-align: left;
}
.tab::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 19px;
  width: 3px;
  height: 20px;
  border-radius: 3px;
  background: transparent;
}
.tab span { color: inherit; font-weight: 650; }
.tab small { color: var(--subtle); font-size: 11px; }
.tab:hover:not(:disabled) { color: var(--text); background: rgba(148, 163, 184, .07); }
.tab.selected {
  color: #dbeafe;
  background: rgba(59, 130, 246, .13);
  border-color: rgba(110, 168, 254, .18);
}
.tab.selected::before { background: var(--accent); }
.tab.selected small { color: #8fbaf9; }

.key-panel { margin-top: auto; padding-top: 24px; }
.sidebar-label {
  margin: 0 0 8px 4px;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.key-card {
  padding: 12px;
  background: rgba(255, 255, 255, .025);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.key-state {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.key-state::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px currentColor;
  opacity: .8;
}
.key-state.locked { color: var(--yellow); }
.key-state.unlocked { color: var(--green); }
.key-actions { display: flex; gap: 6px; margin-top: 11px; }
.key-actions button { flex: 1; min-width: 0; padding-inline: 8px; font-size: 12px; }
#choose-key { flex-grow: 1.7; }
#lock-key { flex-grow: .7; }
.key-note { margin: 10px 0 0; color: var(--subtle); font-size: 11px; line-height: 1.55; }
.sidebar-footer { padding-top: 10px; }
.secondary-action { width: 100%; color: var(--muted); background: transparent; }

.app-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.app-header {
  min-height: 94px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  background: rgba(15, 22, 33, .88);
  border-bottom: 1px solid var(--border);
}
.page-heading { min-width: 0; }
.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.page-heading h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.2px; }
.page-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.header-meta { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.header-actions { display: flex; align-items: center; gap: 7px; }
.status {
  min-width: 0;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: rgba(148, 163, 184, .06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--subtle);
}
.status.connected::before { background: var(--green); box-shadow: 0 0 0 3px rgba(74, 222, 128, .12); }
.status.error { color: #fecdd3; border-color: rgba(251, 113, 133, .28); background: rgba(251, 113, 133, .08); }
.status.error::before { background: var(--red); }

.auth-gate {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 35%, rgba(59, 130, 246, .09), transparent 38%),
    var(--bg);
}
body[data-connection="connected"] .auth-gate { display: none; }
body[data-connection="disconnected"] .auth-checking { display: none; }
body[data-connection="checking"] .credential-form { display: none; }
.auth-checking {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}
.auth-checking strong { color: var(--text); font-size: 16px; }
.auth-checking span:last-child { font-size: 12px; }
.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border: 3px solid rgba(110, 168, 254, .16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-color: var(--accent); } }

.credential-form {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 26px;
  background: rgba(19, 28, 40, .96);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.auth-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 4px; }
.auth-heading h2 { margin: 0; font-size: 18px; }
.auth-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.auth-mark { width: 42px; height: 42px; }
.credential-field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.credential-field input { width: 100%; font-size: 13px; }
.credential-field input[readonly] { color: var(--muted); background: rgba(13, 21, 32, .7); }
.remember-session { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.remember-session input { min-height: 0; margin: 0; accent-color: var(--accent-strong); }
.auth-note { margin: -2px 0 0; color: var(--subtle); font-size: 11px; text-align: center; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background: var(--bg);
}
.mobile-workspace-nav { display: none; }
body:not([data-connection="connected"]) .workspace { display: none; }
.workspace[data-view="overview"] {
  grid-template-columns: minmax(230px, 255px) minmax(0, 1fr);
  grid-template-rows: minmax(300px, 1.15fr) minmax(190px, .85fr);
  grid-template-areas:
    "devices list"
    "devices content";
}
.workspace[data-view="backups"],
.workspace[data-view="activity"] {
  grid-template-columns: minmax(220px, 245px) minmax(330px, 390px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "devices list content";
}
.devices-pane { grid-area: devices; }
.list-pane { grid-area: list; }
.content-pane { grid-area: content; }

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .08);
}
.pane-header {
  min-height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  background: rgba(24, 35, 50, .72);
  border-bottom: 1px solid var(--border);
}
.pane-heading { min-width: 0; display: flex; flex-direction: column; }
.pane-heading > span:last-child { font-size: 13px; font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-eyebrow { color: var(--subtle); font-size: 9px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; }
.count {
  max-width: 55%;
  margin-left: auto;
  color: var(--muted);
  background: rgba(148, 163, 184, .08);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-tools { flex: 0 0 auto; padding: 9px; border-bottom: 1px solid var(--border); display: flex; gap: 7px; }
.pane-tools:empty { display: none; }
.pane-tools .search { width: 100%; }
.pane-tools select { min-width: 0; flex: 1; }
.pane-body { flex: 1; min-height: 0; overflow: auto; }
.content { height: 100%; overflow: auto; padding: 17px; }

.row {
  position: relative;
  width: 100%;
  min-height: 62px;
  display: block;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
  transition: background-color .14s ease;
}
.row:last-child { border-bottom: 0; }
.row:hover, .row.selected { background: var(--surface-hover); color: var(--text); }
.row.selected::after {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.row.unread .row-title::before, .unread-dot {
  content: "";
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: middle;
}
.row-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 620; }
.row-title .unread-dot { display: none; }
.row-sub { color: var(--muted); font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > .badge { float: right; margin: 0 0 4px 8px; }

.load-more { flex: 0 0 auto; margin: 8px; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.empty, .loading, .error-panel {
  color: var(--muted);
  text-align: center;
  padding: 44px 18px;
  line-height: 1.75;
}
.loading::before {
  content: "";
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(110, 168, 254, .1);
}
.error-panel { color: #fecdd3; }

.badge {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.green { color: #86efac; background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .18); }
.badge.yellow { color: #fde047; background: rgba(250, 204, 21, .09); border-color: rgba(250, 204, 21, .18); }
.badge.orange { color: #fdba74; background: rgba(251, 146, 60, .1); border-color: rgba(251, 146, 60, .18); }
.badge.red { color: #fda4af; background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .18); }
.badge.gray { color: #aeb9c8; background: rgba(148, 163, 184, .08); border-color: var(--border); }
.badge.blue { color: #bfdbfe; background: rgba(110, 168, 254, .1); border-color: rgba(110, 168, 254, .18); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; padding: 12px; }
.stat-card, .card { border: 1px solid var(--border); border-radius: 11px; background: rgba(24, 35, 50, .7); }
.stat-card { position: relative; min-height: 102px; padding: 13px; overflow: hidden; }
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--subtle);
}
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.red::before { background: var(--red); }
.stat-card.orange::before { background: var(--orange); }
.stat-value { color: var(--text); font-size: 26px; font-weight: 730; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 650; margin-top: 6px; }
.stat-hint { color: var(--subtle); font-size: 9px; margin-top: 2px; }
.card { margin-bottom: 12px; padding: 14px; }
.card-title { color: #dbeafe; font-size: 13px; font-weight: 680; margin-bottom: 10px; }
.section-title { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; margin: 20px 0 9px; }
.meta { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 7px 13px; margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }
.meta dd, .row-title, .dialog-file { font-variant-numeric: tabular-nums; }
.warning {
  border: 1px solid rgba(250, 204, 21, .25);
  background: rgba(250, 204, 21, .07);
  color: #fde68a;
  padding: 11px 12px;
  border-radius: 9px;
  margin-bottom: 12px;
}
.success { border-color: rgba(74, 222, 128, .25); color: #bbf7d0; background: rgba(74, 222, 128, .07); }
.action-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.detail-navigation { display: flex; align-items: center; margin-bottom: 12px; }
.detail-navigation button { color: var(--muted); background: transparent; }
.attention-card { padding: 0; overflow: hidden; }
.attention-header { padding: 13px 14px 10px; }
.attention-header strong { display: block; font-size: 13px; }
.attention-header span { color: var(--muted); font-size: 11px; }
.attention-list { display: grid; }
.attention-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
}
.attention-copy { min-width: 0; flex: 1; }
.attention-copy strong { display: block; font-size: 12px; }
.attention-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.attention-item button { flex: 0 0 auto; min-height: 32px; padding: 5px 9px; font-size: 11px; }
.attention-item.danger strong { color: #fda4af; }
.attention-item.warning-item strong { color: #fdba74; }
.attention-clear { color: #bbf7d0; background: rgba(74, 222, 128, .04); }

.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; word-break: break-word; }
th { color: var(--muted); background: #17212f; font-weight: 600; position: sticky; top: -17px; z-index: 1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(29, 42, 59, .55); }
.file-name { min-width: 170px; font-weight: 620; }
.file-id, code, pre { font-family: var(--mono); }
.file-id { margin-top: 3px; color: var(--subtle); font-size: 10px; }
.file-protection { display: grid; gap: 4px; }
.file-protection small { color: var(--subtle); font-family: var(--mono); }
.table-actions { display: flex; gap: 5px; white-space: nowrap; }
.table-actions button { min-height: 32px; padding: 5px 8px; font-size: 11px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.secret { color: var(--muted); }
.secret-button { min-height: 24px; border: 0; background: transparent; color: var(--accent); padding: 0 5px; font-size: 11px; }
.filter-input { width: 100%; margin-bottom: 10px; }

pre {
  margin: 0;
  max-width: 100%;
  overflow: auto;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #0d1520;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.65;
}
.preview { max-width: 100%; max-height: 620px; display: block; border: 1px solid var(--border); border-radius: 9px; }
a { color: var(--accent); }

.unlock-dialog {
  width: min(500px, calc(100vw - 30px));
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 0;
  box-shadow: var(--shadow);
}
.unlock-dialog::backdrop { background: rgba(2, 6, 12, .76); backdrop-filter: blur(3px); }
.unlock-dialog form { padding: 24px; }
.unlock-dialog h2 { margin: 0 0 5px; font-size: 18px; }
.unlock-dialog label { display: block; color: var(--muted); margin: 14px 0 5px; font-size: 12px; font-weight: 600; }
.unlock-dialog input { width: 100%; }
.unlock-dialog input[readonly] { color: var(--muted); }
.dialog-note { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-file { margin: 13px 0 0; padding: 9px 10px; color: #bfdbfe; background: rgba(110, 168, 254, .07); border-radius: 8px; overflow-wrap: anywhere; }
.saved-credential-action {
  width: 100%;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  margin-top: 16px;
  padding: 10px 14px;
  text-align: left;
}
.saved-credential-action span { font-size: 14px; }
.saved-credential-action small { color: rgba(255, 255, 255, .7); font-size: 10px; font-weight: 500; }
.unlock-separator { display: flex; align-items: center; gap: 9px; margin: 15px 0 3px; color: var(--subtle); font-size: 10px; }
.unlock-separator::before, .unlock-separator::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.dialog-error { color: #fda4af; min-height: 22px; margin-top: 9px; }
.dialog-actions { display: flex; align-items: center; gap: 7px; margin-top: 12px; }
.dialog-spacer { flex: 1; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a384b; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3b4d64; }

@media (max-width: 1240px) {
  .app-shell { grid-template-columns: 188px minmax(0, 1fr); }
  .brand-copy small, .key-note { display: none; }
  .workspace[data-view="backups"],
  .workspace[data-view="activity"] { grid-template-columns: minmax(190px, 220px) minmax(300px, 340px) minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}

@media (max-width: 1024px) {
  .app-shell { height: 100dvh; display: flex; flex-direction: column; }
  .app-sidebar {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto minmax(300px, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .brand { padding: 0; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-copy strong { font-size: 13px; }
  .view-tabs { display: flex; gap: 4px; margin: 0; }
  .tab { min-height: 42px; flex: 1; align-items: center; padding: 5px 12px; }
  .tab::before, .tab small { display: none; }
  .key-panel { margin: 0; padding: 0; }
  .sidebar-label, .key-note { display: none; }
  .key-card { display: flex; align-items: center; gap: 8px; padding: 0; background: transparent; border: 0; }
  .key-state { max-width: 180px; }
  .key-actions { margin: 0; }
  .key-actions button { flex: 0 0 auto; }
  .sidebar-footer { padding: 0; }
  .secondary-action { width: auto; }
  .app-main { flex: 1; }
  .app-header { min-height: 78px; padding: 12px 16px; }
  .workspace[data-view="overview"] { grid-template-columns: minmax(210px, 230px) minmax(0, 1fr); }
  .workspace[data-view="backups"],
  .workspace[data-view="activity"] { grid-template-columns: minmax(190px, 215px) minmax(285px, 320px) minmax(0, 1fr); }
}

@media (max-width: 760px) {
  html, body { height: auto; min-height: 100%; }
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; }
  .app-sidebar {
    position: static;
    grid-template-columns: auto 1fr;
    gap: 9px;
    padding: 9px 11px;
  }
  .brand-copy { display: none; }
  .view-tabs { order: 2; }
  .tab { min-width: 68px; }
  .key-panel { grid-column: 1 / 3; order: 3; }
  .key-card { justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--border); border-radius: 0; }
  .key-state { max-width: min(48vw, 250px); }
  .key-actions button { min-height: 34px; font-size: 11px; }
  .sidebar-footer { grid-column: 1 / 3; order: 4; }
  .secondary-action { width: 100%; }
  .app-main { min-height: 0; overflow: visible; }
  .app-header { min-height: 0; align-items: flex-start; flex-wrap: wrap; gap: 9px; padding: 13px; }
  .page-heading h1 { font-size: 19px; }
  .page-heading p { max-width: 88vw; }
  .header-meta { width: 100%; justify-content: space-between; }
  .status { max-width: calc(100% - 96px); }
  .auth-gate { min-height: 70vh; padding: 18px 12px; }
  .credential-form { padding: 20px; border-radius: 14px; }
  .workspace,
  .workspace[data-view="overview"],
  .workspace[data-view="backups"],
  .workspace[data-view="activity"] {
    flex: none;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "mobile-nav"
      "devices"
      "list"
      "content";
    gap: 10px;
    padding: 10px;
    overflow: visible;
  }
  .mobile-workspace-nav {
    position: sticky;
    top: 8px;
    z-index: 5;
    grid-area: mobile-nav;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    padding: 5px;
    background: rgba(15, 22, 33, .94);
    border: 1px solid var(--border);
    border-radius: 11px;
    backdrop-filter: blur(10px);
  }
  .mobile-workspace-nav button { min-height: 34px; padding: 5px 8px; background: transparent; }
  .devices-pane { height: 230px; }
  .list-pane { min-height: 330px; max-height: 58vh; }
  .content-pane { min-height: 60vh; }
  .stat-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .stat-card { min-height: 96px; }
  .content { height: auto; min-height: 0; overflow: visible; padding: 14px; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: 8px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-spacer { display: none; }
  #choose-other-key { width: 100%; }
}

@media (max-width: 420px) {
  .tab { min-width: 60px; padding-inline: 8px; }
  .key-state { max-width: 42vw; font-size: 11px; }
  #lock-key { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 9px; }
  .stat-value { font-size: 22px; }
  .pane-tools { flex-wrap: wrap; }
  .pane-tools select { flex-basis: 100%; }
  .table-actions { flex-direction: column; }
}
