:root {
  /* Every text colour here keeps 4.5:1 (WCAG AA) on --bg and --bg-elevated,
     as tests/test_accessible_names.py checks (#261). */
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #646b78;
  --accent: #3866ea;
  --accent-contrast: #ffffff;
  --danger: #c74040;
  --danger-contrast: #ffffff;
  --ok: #15804b;
  --warn: #97670d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --bg-elevated: #1c1f26;
    --border: #2b2f38;
    --text: #e7e9ed;
    --text-muted: #9096a2;
    --accent: #5b8bff;
    --accent-contrast: #0c0e12;
    --danger: #ff6b6b;
    --danger-contrast: #1a0a0a;
    --ok: #3ecf8e;
    --warn: #e0a83e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

/* Theme-toggle override - wins over prefers-color-scheme either direction. */
:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-elevated: #1c1f26;
  --border: #2b2f38;
  --text: #e7e9ed;
  --text-muted: #9096a2;
  --accent: #5b8bff;
  --accent-contrast: #0c0e12;
  --danger: #ff6b6b;
  --danger-contrast: #1a0a0a;
  --ok: #3ecf8e;
  --warn: #e0a83e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Black, one-colour app icons turn white on the dark theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img[src$="/vaultwarden.svg"] { filter: invert(1); }
}
:root[data-theme="dark"] img[src$="/vaultwarden.svg"] { filter: invert(1); }

* { box-sizing: border-box; }

/* !important since it must win over any element's base display value. */
.hidden { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* Pins the footer to the viewport bottom on short pages, scrolls normally otherwise. */
.content { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-name {
  font-weight: 700;
  font-size: 24px;
}

.brand-tagline {
  font-weight: 400;
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Narrow screens: brand and account on one row, the tabs across the full
   width below, sized to fit (scrolling inside the bar on the narrowest). */
@media (max-width: 860px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand { margin-right: auto; }
  .tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex: 1 1 auto; padding: 6px 8px; white-space: nowrap; }
}

@media (max-width: 480px) {
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { font-size: 20px; }
  .brand-tagline { font-size: 13px; }
  /* The account button is just its icon, so brand, account and theme keep
     one row beside the tagline. */
  .user-name { display: none; }
  .tabs { gap: 2px; }
  .tab-btn { font-size: 14px; padding: 6px 4px; }
}

@media (max-width: 360px) {
  .topbar { gap: 8px; }
  .brand-tagline { font-size: 12px; }
}

/* Phones under 360px: a little smaller still, so the header keeps one row. */
@media (max-width: 359px) {
  .topbar { padding: 10px 8px; gap: 6px; }
  .brand { gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-name { font-size: 18px; }
  .brand-tagline { font-size: 11px; letter-spacing: 0; }
  .theme-toggle { width: 30px; height: 30px; font-size: 16px; }
}

@media (max-width: 360px) {
  .tab-btn { font-size: 13px; padding: 5px 3px; }
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 18.5px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle:hover { border-color: var(--accent); }

.app-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  object-fit: contain;
  flex-shrink: 0;
}

/* An app with a second icon for the dark theme (APP_META icon_dark): the
   one that fits the theme shows - the toggle's choice, else the system's. */
.app-icon.icon-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .app-icon.icon-light { display: none; }
  :root:not([data-theme="light"]) .app-icon.icon-dark { display: inline; }
}
:root[data-theme="dark"] .app-icon.icon-light { display: none; }
:root[data-theme="dark"] .app-icon.icon-dark { display: inline; }

.content {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.site-footer {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 14.5px;
}

/* Bottom-right feedback button + popover. Below .modal-overlay (200) so dialogs cover it. */
.feedback {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.feedback-btn {
  width: 48px;
  height: 48px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-btn:hover,
.feedback-btn[aria-expanded="true"] { border-color: var(--accent); }

.feedback-btn img { width: 100%; height: 100%; object-fit: contain; }

.feedback-menu {
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.feedback-link {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
}

.feedback-link + .feedback-link { border-top: 1px solid var(--border); }
.feedback-link:hover, .feedback-link:focus-visible { background: var(--bg); color: var(--accent); }

.site-footer-name { font-weight: 600; }

.site-footer-version { margin-left: 6px; }

.version-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
}

.version-check-text.ok { color: var(--ok); }
.version-check-text.fail { color: var(--danger); }
.version-check-text a { color: inherit; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.settings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 20px;
  position: sticky;
  /* Set to the topbar's real height by JS on load/resize; falls back until then. */
  top: calc(var(--topbar-h, 64px) + 12px);
  z-index: 5;
}

.settings-toolbar .hint {
  display: block;
  margin: 2px 0 0;
}

.grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.right-col .card { margin-bottom: 0; }

.request-header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}
.request-header-row .field { min-width: 0; margin: 0; }
.request-header-row input { width: 100%; min-width: 0; }
.request-header-row .remove-header { margin-bottom: 2px; }
.request-header-row .header-scope { grid-column: 1 / -1; font-size: 0.85rem; }
.header-scope summary { cursor: pointer; color: var(--text-muted); }
.header-scope-options { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.request-headers-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.request-headers-actions label { font-size: 0.85rem; }
.request-headers-help { margin-top: 14px; font-size: 0.85rem; }
.request-headers-help summary { cursor: pointer; }
.basic-auth-form .field { min-width: 0; }
.basic-auth-form input { width: 100%; min-width: 0; }
.basic-auth-form .test-result { margin-bottom: 0; overflow-wrap: anywhere; }
#request-headers-card code { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .request-header-row { grid-template-columns: minmax(0, 1fr) auto; }
  .request-header-row .field:first-child { grid-column: 1 / -1; }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
}

.hint {
  color: var(--text-muted);
  font-size: 14.5px;
  margin: 4px 0 16px;
}

.app-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.app-card:last-child { margin-bottom: 0; }

/* "Enabled" / "Not enabled" dividers between the grouped app cards. */
/* ---------------------------------------------------- app categories --- */
/* A collapsible group of app cards (#148), on Settings and History. */
.app-category + .app-category, .history-category + .history-category { margin-top: 10px; }
.category-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.category-head:hover, .category-head:focus-visible { border-color: var(--accent); }
.category-emoji { font-size: 18px; line-height: 1; }
/* The pickers' category headings: bold, upright (Firefox slants them). */
optgroup { font-weight: 700; font-style: normal; }
/* A category's own icon (#189), drawn in the text colour: the outline one on
   the light theme, the filled one on the dark. As wide as an emoji, so every
   category's name starts in line. */
.category-icon {
  flex: none;
  width: 22.5px;
  height: 20px;
  background-color: var(--text);
  -webkit-mask: var(--category-icon) center / contain no-repeat;
  mask: var(--category-icon) center / contain no-repeat;
}
.category-icon-server { --category-icon: url("icons/server-outline.png"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .category-icon-server { --category-icon: url("icons/server-filled.png"); }
}
:root[data-theme="dark"] .category-icon-server { --category-icon: url("icons/server-filled.png"); }
.category-name { font-size: 15.5px; font-weight: 600; flex: 1; }
.category-count { color: var(--text-muted); font-size: 13.5px; white-space: nowrap; }
.category-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  margin: 0 4px 4px 2px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
[aria-expanded="false"] > .category-chevron { transform: rotate(-45deg); margin: 0 4px 0 0; }
.category-body { padding-top: 10px; }
.history-category > .category-body { padding: 12px 4px 0; }

/* Destinations folds the same way, its h2 the button. */
/* Spaced like any card's h2 (.card h2); folded, the card is just its title. */
.section-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.section-toggle > span:first-child { flex: 1; }
.dest-head-icons { display: flex; align-items: center; gap: 6px; }
.dest-head-icons .app-icon { width: 18px; height: 18px; }
.section-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

/* -------------------------------------------- picking several backups --- */
.history-select { display: none; width: auto; margin: 0 8px 0 0; vertical-align: middle; cursor: pointer; }
#history-root.selecting .history-select { display: inline-block; }
#history-root.selecting .history-app h3 { display: flex; align-items: center; }
#history-select-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn-icon-text { display: inline-flex; align-items: center; gap: 6px; }
.btn-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
/* Room below the last row so the bar never covers it. */
#history-root.selecting { padding-bottom: 72px; }
.bulk-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.bulk-bar.hidden { display: none; }
.bulk-count { font-weight: 600; font-size: 14.5px; margin-right: 4px; white-space: nowrap; }
.bulk-bar .btn { white-space: nowrap; }
/* Why some couldn't be deleted (#164): its own line, wrapping, under the rest. */
.bulk-bar:has(.bulk-error:not(.hidden)) { flex-wrap: wrap; max-width: min(640px, calc(100vw - 32px)); }
.bulk-error { flex-basis: 100%; color: var(--danger); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.bulk-error.hidden { display: none; }
/* On a phone the bar spans the width, clear of the feedback button: the
   count on one line, the three buttons on the next. */
@media (max-width: 560px) {
  .bulk-bar { left: 12px; right: 76px; transform: none; flex-wrap: wrap; gap: 8px; }
  .bulk-count { flex-basis: 100%; text-align: center; margin-right: 0; }
  .bulk-bar { justify-content: center; }
}

.discovery-badge {
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.discovery-status { margin: 8px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.app-discovery { display: grid; gap: 8px; }
.app-discovery p { margin: 0; overflow-wrap: anywhere; }
.app-discovery .btn { justify-self: start; white-space: normal; text-align: left; }
.discovery-key-status { display: block; margin-top: 6px; color: var(--danger); font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.discovery-warning { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }

/* Extra Radarr/Sonarr instances sit indented under their app's card. */
.instance-card { margin-left: 16px; }
.instance-add { display: grid; gap: 8px; justify-items: start; margin: -4px 0 12px 16px; }
.instance-add-form { width: 100%; }
.instance-add-form .field { margin-bottom: 8px; }
.instance-discovered { display: grid; gap: 6px; width: 100%; font-size: 14px; }
.instance-discovered p { margin: 0; overflow-wrap: anywhere; }
.instance-discovered-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .instance-card, .instance-add { margin-left: 0; }
}

@media (max-width: 480px) {
  .app-card-head { flex-wrap: wrap; }
}

.app-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-card-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.app-card-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.app-card-body.hidden { display: none; }

.field {
  display: block;
  margin-bottom: 12px;
}

.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-muted);
}

.muted {
  font-weight: 400;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14.5px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.inline-group {
  display: flex;
  gap: 8px;
}

.inline-group input { flex: 1; }

.schedule-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.schedule-picker select,
.schedule-picker input[type="time"] {
  width: auto;
  flex: 1;
  min-width: 110px;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  padding: 0;
  cursor: pointer;
}

.collapse-toggle:hover { color: var(--text); }

.collapse-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 11.5px;
}

.collapse-toggle[aria-expanded="true"] .collapse-arrow { transform: rotate(90deg); }

.collapse-body {
  margin-top: 10px;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-danger {
  background: var(--danger);
  color: var(--danger-contrast);
}

.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) { border-color: var(--accent); }

.btn-sm { padding: 5px 12px; font-size: 14.5px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.app-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* A long test result wraps beside the buttons; the buttons never do. */
.app-card-actions .btn { flex: none; white-space: nowrap; }
/* On a phone a row of buttons (Prowlarr's three) is wider than the card:
   the row wraps instead, each button still on one line. */
@media (max-width: 480px) {
  .app-card-actions { flex-wrap: wrap; }
}

.field-actions-spaced { margin-top: 10px; }

.plex-auth-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: help;
}

.help-tip:hover,
.help-tip:focus { color: var(--accent); border-color: var(--accent); outline: none; }
/* A "?" that's also a link (the Home Assistant integration's). It ends its
   line, so its tooltip opens to the left, within the card on a phone. */
a.help-tip-link { cursor: pointer; text-decoration: none; }
a.help-tip-link:hover::after,
a.help-tip-link:focus::after { left: auto; right: -6px; transform: none; }

/* A card's "?": its app's page in the docs, at "Setting it up". */
.card-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}

.card-help:hover,
.card-help:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }

.help-tip:hover::after,
.help-tip:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(280px, 70vw);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
}

/* A certificate fingerprint's tooltip (#189): its "?" sits near the start of
   a line, so the tooltip lines up with that line, within the card. */
.cert-fingerprint, .https-fingerprint { position: relative; }
.help-tip-fingerprint { position: static; }
.help-tip-fingerprint:hover::after,
.help-tip-fingerprint:focus::after {
  left: 0;
  transform: none;
  width: max-content;
  max-width: 100%;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.test-result {
  font-size: 14.5px;
  color: var(--text-muted);
}

.test-result.ok { color: var(--ok); }
.test-result.fail { color: var(--danger); }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.status-dot[data-state="ok"] { background: var(--ok); }
.status-dot[data-state="fail"] { background: var(--danger); }

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 21px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: var(--bg-elevated);
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(15px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A setting switched like the app itself: the same toggle, then its label. */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* An option that's always on (Home Assistant's Settings, #155). */
.switch input:disabled + .slider { opacity: 0.6; cursor: default; }
.toggle-field:has(input:disabled) { cursor: default; }

/* Home Assistant's chosen apps (#155): one switch per installed app. */
.app-list {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
  min-width: 0;
}
.app-list .field-label { padding: 0; margin-bottom: 6px; }
.app-list-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}
.app-list-item { margin: 0; overflow-wrap: anywhere; }

.save-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.save-result { font-size: 14.5px; color: var(--text-muted); }
.save-result.ok { color: var(--ok); }
.save-result.fail { color: var(--danger); }
.save-result.warn { color: var(--warn); }

.run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.run-head h2 { margin: 0; }

.run-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-head-actions select { width: auto; }

@media (max-width: 560px) {
  .run-head { flex-wrap: wrap; gap: 10px; }
  /* Cancel, the app picker and "Running..." don't fit on one line. */
  .run-head-actions { flex-wrap: wrap; }
}

.run-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--text-muted);
}

.run-summary strong { color: var(--text); }

/* A saved schedule that stopped being valid (#166), on Overview and Run & Status. */
.schedule-warning { color: var(--warn); font-weight: 600; margin: 12px 0 0; }
#run-schedule-warning { margin: 0 0 12px; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.run-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
}

.run-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.log-view {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  height: 420px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-app {
  margin-bottom: 18px;
}

.history-app:last-child { margin-bottom: 0; }

.history-app h3 {
  font-size: 15.5px;
  margin: 0 0 8px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.history-table th, .history-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
}

/* Each app has its own table: with room to spare, fixed column widths keep
   Size and Modified in one line down the page. */
@media (min-width: 720px) {
  .history-table { table-layout: fixed; }
  .history-table th:nth-child(2) { width: 11em; }
  .history-table th:nth-child(3) { width: 7em; }
  .history-table th:nth-child(4) { width: 13em; }
  .history-table th:nth-child(5) { width: 150px; }
  .history-table td:nth-child(2) { overflow-wrap: anywhere; }
  .history-table td:first-child { overflow-wrap: anywhere; }
}

.empty-note {
  color: var(--text-muted);
  font-size: 14.5px;
  padding: 8px 0;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-field input { width: auto; }

.extra-field-block {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}
.danger-text { color: var(--danger); }
.restore-version.ok { color: var(--ok); }
.restore-version.warn { color: var(--warn); }
.restore-version.fail { color: var(--danger); }
.restore-version .btn { margin-left: 6px; }

/* A self-signed certificate to trust (#153), and links to a card from a failure. */
.cert-trust { margin-top: 10px; display: grid; gap: 10px; }
.cert-details { display: grid; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }
.cert-details .cert-fingerprint { display: flex; align-items: center; gap: 6px; }
.card-link { margin-left: 8px; }

/* An app restored by hand (#151): its download and steps on the Restore tab. */
.restore-manual { margin: 4px 0 8px; }
.restore-manual a.btn { display: inline-block; text-decoration: none; }
.restore-steps-title { font-size: 15px; margin: 16px 0 6px; }
.restore-steps { margin: 0 0 8px; padding-left: 22px; }
.restore-steps li { margin: 4px 0; line-height: 1.45; }
.restore-manual a:not(.btn) { color: var(--accent); }

.server-pw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.server-pw-row .server-label {
  min-width: 220px;
  font-size: 15px;
}

.server-pw-row input { flex: 1; }

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  max-width: 340px;
}

.toast.ok { border-color: var(--ok); }
.toast.fail { border-color: var(--danger); }
.toast.warn { border-color: var(--warn); }

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13.5px;
}

/* ------------------------------------------------------------ overview --- */
.overview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 4px;
}

.overview-stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
}

.overview-stat .stat-value {
  font-size: 23px;
  font-weight: 700;
}

.overview-stat .stat-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Centers the icon row and its "Destinations" label on each other's
   natural width, so the label re-centers as the icon count changes. */
.overview-stat-dest { align-items: center; }

.overview-dest-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 20px;
}

.overview-dest-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.overview-dest-icon .app-icon {
  width: 20px;
  height: 20px;
}

.overview-dest-icon span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Retention per destination (#133): icon and days, one destination a line. */
.overview-retention-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.overview-retention-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.overview-retention-row .app-icon {
  width: 20px;
  height: 20px;
}

/* Each run's apps not backed up yet, under its size. */
.overview-stat .stat-note {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Storage needed per destination: icon, then needed, used and free. */
.overview-storage-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.overview-storage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.overview-storage-row .app-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.overview-storage-row .storage-muted { font-weight: 500; color: var(--text-muted); }
.overview-stat .storage-short { font-weight: 700; color: var(--warn); }
.overview-stat .storage-part { white-space: nowrap; }

/* Under a retention field: the backups it keeps and their size. */
.hint.storage-hint {
  display: block;
  margin: 6px 0 0;
  font-size: 13.5px;
}

.overview-apps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* Home Assistant's switch on Backuparr's card (#170). */
.ha-integration { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.https-settings { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.https-settings .hint { margin: 0 0 8px; }
.https-settings .hint.warn { color: var(--warn); }
.https-settings .toggle-field { margin: 4px 0 4px; }
.https-fingerprint { display: flex; align-items: center; gap: 6px; }
.ha-integration .toggle-field { margin-bottom: 0; }
.ha-integration #ha-token-field { margin-top: 12px; }
.ha-integration #ha-token { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.ha-integration .app-card-actions { margin-top: 10px; }

/* The status bar over the app cards (#167). */
.overview-status-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 16px;
}
.overview-status-text { font-weight: 600; }
.overview-status-extra { color: var(--text-muted); }
.overview-status-extra::before { content: "\00b7"; margin-right: 10px; }
.status-icon { width: 24px; height: 24px; flex: none; fill: currentColor; stroke: var(--bg-elevated); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.overview-status[data-state="ok"] .status-icon { color: var(--ok); }
.overview-status[data-state="fail"] .status-icon { color: var(--danger); }
.overview-status-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.overview-status-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.overview-status-item:hover, .overview-status-item:focus-visible { background: var(--bg); }
.overview-status-item .app-icon { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.overview-status-line { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.overview-status-error { color: var(--text-muted); }
@media (max-width: 480px) {
  /* "n not backed up yet" on its own line, under the text, without the dot. */
  .overview-status-extra { flex-basis: 100%; padding-left: 34px; }
  .overview-status-extra::before { content: none; }
}
.overview-app-card.flash, .app-card.flash { animation: card-flash 1.6s ease-out; }
@keyframes card-flash {
  from { box-shadow: 0 0 0 3px var(--accent); }
  to { box-shadow: var(--shadow); }
}
@media (prefers-reduced-motion: reduce) {
  .overview-app-card.flash, .app-card.flash { animation: none; outline: 3px solid var(--accent); }
}

.overview-app-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.overview-app-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.overview-app-head .app-icon { width: 26px; height: 26px; }

.overview-app-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.overview-app-last {
  font-size: 14.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.overview-app-last .filename {
  display: block;
  color: var(--text);
  font-size: 14.5px;
  margin-top: 2px;
  word-break: break-all;
}

.overview-download-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.overview-download-link:hover { text-decoration: underline; }

.overview-empty {
  grid-column: 1 / -1;
  max-width: 420px;
  margin: 12px auto;
  padding: 24px 20px;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  font-size: 15px;
}

/* ---------------------------------------------------------- icon button --- */
.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 15px;
  cursor: pointer;
}

.icon-btn:hover { color: var(--danger); border-color: var(--danger); }

.history-table td.actions-cell { width: 1%; white-space: nowrap; }
.history-table td.actions-cell .icon-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.history-table td.actions-cell .icon-btn + .icon-btn { margin-left: 6px; }

/* -------------------------------------------------------- destinations --- */
.dest-description { margin: 6px 0 0; }

/* -------------------------------------------------------------- modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
}

.modal-head h3 { margin: 0; font-size: 19.5px; }

.modal-body { padding: 20px; font-size: 16.5px; }

/* Larger than the app-wide hint size - this modal's text is read as instructions. */
.modal-body .hint { font-size: 16px; line-height: 1.5; }
.modal-body .field-label { font-size: 16px; }

.guide-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-steps li { font-size: 17px; line-height: 1.6; }

.guide-steps .field { margin: 8px 0 0; }

.guide-step-link {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.guide-step-link:hover { text-decoration: underline; }

.guide-step-checklist {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: disc;
}

.guide-step-checklist li {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.guide-step-code {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  overflow-x: auto;
}

.guide-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16.5px;
}

.guide-links a { color: var(--accent); }

.release-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.release-item + .release-item {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.release-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.release-tag { font-weight: 600; font-size: 17px; }
.release-date { font-size: 14.5px; color: var(--text-muted); white-space: nowrap; }

.release-body {
  margin: 8px 0 0;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text);
  word-wrap: break-word;
}

.release-body h1,
.release-body h2,
.release-body h3,
.release-body h4 {
  margin: 14px 0 6px;
  font-size: 15.5px;
  font-weight: 600;
}

.release-body :first-child { margin-top: 0; }

.release-body p { margin: 8px 0; }

.release-body ul {
  margin: 4px 0 12px;
  padding-left: 20px;
}

.release-body li { margin: 4px 0; }

.whats-changed-error { font-size: 16px; color: var(--danger); }
.whats-changed-all { margin: 16px 0 0; text-align: center; font-size: 15px; }

/* ------------------------------------------------------------- auth ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 360px;
}

.auth-brand {
  margin-bottom: 20px;
}

.auth-card h2 {
  margin: 0 0 12px;
  font-size: 20.5px;
}

/* A result message goes under the buttons, so they keep their width. */
.auth-card .save-row { flex-wrap: wrap; }
.auth-card .save-result { flex-basis: 100%; }
.auth-card .save-result:empty { display: none; }

.auth-forgot {
  margin: 16px 0 0;
  text-align: center;
}

/* ------------------------------------------------------------ run log --- */
.log-panel {
  position: fixed;
  top: calc(var(--topbar-h, 72px) + 16px);
  right: 16px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - var(--topbar-h, 72px) - 32px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.log-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.log-panel-head h3 { margin: 0; font-size: 16px; }
.log-panel-meta { padding: 10px 16px; font-size: 14.5px; border-bottom: 1px solid var(--border); }
.log-panel-meta p { margin: 0 0 4px; }
.log-panel-meta ul { margin: 4px 0 0; padding-left: 18px; }
.log-panel-meta .ok { color: var(--ok); }
.log-panel-meta .fail { color: var(--danger); }
.log-panel-meta .muted { color: var(--text-muted); }
.log-panel-lines {
  margin: 0;
  padding: 10px 16px 14px;
  list-style: none;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.5;
}
.log-panel-lines li { display: flex; gap: 10px; overflow-wrap: anywhere; }
.log-panel-lines .log-time { flex: none; color: var(--text-muted); }
.log-panel-lines li.log-warning { color: var(--warn); }
.log-panel-lines li.log-error, .log-panel-lines li.log-critical { color: var(--danger); font-weight: 600; }
.link-btn {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.overview-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 14.5px; }
.overview-links .overview-download-link { margin-top: 0; }
.history-table tr.history-missing td { color: var(--text-muted); }
.history-table tr.history-missing td.history-reason { color: var(--danger); font-weight: 600; white-space: nowrap; }
.history-table td.actions-cell .link-btn { font-size: 14px; margin-right: 6px; }

/* Narrow screens: each backup is a block - the file name, then version, size
   and time on one line with its actions. */
@media (max-width: 719px) {
  .history-table thead { display: none; }
  .history-table, .history-table tbody { display: block; }
  .history-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .history-table td { padding: 0; border: none; font-size: 14px; color: var(--text-muted); }
  .history-table td:first-child { flex-basis: 100%; color: var(--text); font-size: 15px; overflow-wrap: anywhere; }
  .history-table td.actions-cell { margin-left: auto; width: auto; }
}

/* ---------------------------------------------------- encrypted backups --- */
/* A padlock and a word (#147): closed and filled in green, open and outlined
   in amber, so the two never look alike. */
.enc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 8px 1px 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}
.enc-badge.enc-on { color: var(--ok); }
.enc-badge.enc-off { color: var(--warn); }
.enc-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.enc-icon .enc-icon-fill { fill: currentColor; }
.overview-app-last .enc-badge { margin: 6px 0 0; }
/* A Jellyfin, Emby or Plex backup with the app's metadata (#196). */
.meta-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}
.encrypt-note { margin: 4px 0 10px; }

/* ------------------------------------------------------ encryption key --- */
.key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.key-value {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14.5px;
  overflow-wrap: anywhere;
  user-select: all;
}
.key-warning { color: var(--danger); margin: 8px 0 14px; }
.key-warning-centered { text-align: center; }
/* The key prompt's confirm button sits centered under the warning, its
   result message (if any) on a line of its own below. */
.key-ack-row { justify-content: center; flex-wrap: wrap; }
.key-ack-row .save-result { flex-basis: 100%; text-align: center; }
.key-ack-row .save-result:empty { display: none; }

/* ------------------------------------------------------------ user menu --- */
.user-menu { position: relative; }
.user-menu-btn { display: inline-flex; align-items: center; gap: 6px; }
.user-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.user-name { max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
}
.user-menu-item + .user-menu-item { border-top: 1px solid var(--border); }
.user-menu-item:hover, .user-menu-item:focus-visible { background: var(--bg); color: var(--accent); }

/* Google's folder picker places itself on the page (position: absolute) for
   the scroll position it opened at, and the page can scroll on after, leaving
   it off screen. Keep it in the middle of the window instead - on a narrow
   screen at the left edge, where its Select button is. */
.picker-dialog {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
}

@media (max-width: 600px) {
  .picker-dialog {
    left: 0 !important;
    transform: translateY(-50%);
  }
}
