/* Wurzelsystem dashboard: GNOME's Adwaita look, recreated for the web.
   Sides are "start" and "end", never left and right, so right-to-left
   languages (Arabic) mirror the layout.
   Colours follow libadwaita's named colours; dark mode follows the system. */

:root {
  --accent: #3584e4;
  --accent-fg: #ffffff;
  --accent-text: #1c71d8;
  --destructive: #e01b24;
  --destructive-text: #c01c28;
  --success: #2ec27e;
  --success-text: #1b8553;
  --warning: #e5a50a;
  --warning-text: #9c6e03;
  --window-bg: #fafafb;
  --window-fg: rgba(0, 0, 6, 0.8);
  --dim-fg: rgba(0, 0, 6, 0.55);
  --view-bg: #ffffff;
  --headerbar-bg: #ffffff;
  --headerbar-shade: rgba(0, 0, 6, 0.12);
  --sidebar-bg: #ebebed;
  --card-bg: #ffffff;
  --card-shade: rgba(0, 0, 6, 0.07);
  --row-hover: rgba(0, 0, 6, 0.04);
  --row-selected: rgba(0, 0, 6, 0.08);
  --border: rgba(0, 0, 6, 0.08);
  --button-bg: rgba(0, 0, 6, 0.06);
  --button-hover: rgba(0, 0, 6, 0.1);
  --switch-off: rgba(0, 0, 6, 0.15);
  --switch-off-hover: rgba(0, 0, 6, 0.2);
  --toggle-checked: #ffffff;
  --entry-bg: rgba(0, 0, 6, 0.06);
  --focus-ring: rgba(53, 132, 228, 0.5);
  --radius-card: 12px;
  --radius-button: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #3584e4;
    --accent-text: #81d0ff;
    --destructive-text: #ff7b63;
    --success-text: #78e9ab;
    --warning-text: #ffc252;
    --window-bg: #222226;
    --window-fg: #ffffff;
    --dim-fg: rgba(255, 255, 255, 0.55);
    --view-bg: #1d1d20;
    --headerbar-bg: #2e2e32;
    --headerbar-shade: rgba(0, 0, 6, 0.36);
    --sidebar-bg: #2e2e32;
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-shade: rgba(0, 0, 6, 0.36);
    --row-hover: rgba(255, 255, 255, 0.04);
    --row-selected: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.08);
    --button-bg: rgba(255, 255, 255, 0.1);
    --button-hover: rgba(255, 255, 255, 0.15);
    --switch-off: rgba(255, 255, 255, 0.2);
    --switch-off-hover: rgba(255, 255, 255, 0.25);
    --toggle-checked: rgba(255, 255, 255, 0.2);
    --entry-bg: rgba(255, 255, 255, 0.1);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--window-bg);
  color: var(--window-fg);
  font-family: "Adwaita Sans", "Cantarell", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
}

a { color: var(--accent-text); }
code, .mono { font-family: "Adwaita Mono", "Source Code Pro", ui-monospace, monospace; }

/* --- Window layout: sidebar + content, like GNOME Settings ------------- */

.window { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex: none;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border);
}

.sidebar nav { padding: 6px; display: flex; flex-direction: column; gap: 2px; }

.sidebar .row {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-button);
  color: inherit;
  text-decoration: none;
}
.sidebar .row:hover { background: var(--row-hover); }
.sidebar .row.selected { background: var(--row-selected); font-weight: 600; }
.sidebar .row.disabled { color: var(--dim-fg); cursor: default; }
.sidebar .row.disabled:hover { background: none; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.headerbar {
  height: 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 6px;
  background: var(--headerbar-bg);
  box-shadow: 0 1px var(--headerbar-shade);
}
.headerbar .title { font-weight: 700; }
.headerbar .end { position: absolute; inset-inline-end: 6px; margin: 0; }
.sidebar .headerbar { background: var(--sidebar-bg); box-shadow: none; }

.page {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* --- Preferences groups and boxed lists --------------------------------- */

.group { margin-bottom: 28px; }
.group > h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  margin-inline-start: 2px;
}
.group > .description { color: var(--dim-fg); margin: 0 0 10px; margin-inline-start: 2px; font-size: 14px; }
.group > .description.below { margin: 10px 0 0; margin-inline-start: 2px; }

.boxed-list {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: 0 0 0 1px rgba(0, 0, 6, 0.03), 0 1px 3px 1px var(--card-shade);
  overflow: hidden;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
}
.action-row + .action-row { border-top: 1px solid var(--border); }
a.action-row:hover { background: var(--row-hover); }
.action-row .text { flex: 1; min-width: 0; }
.action-row .title { display: block; }
.action-row .subtitle {
  display: block;
  color: var(--dim-fg);
  font-size: 13px;
  overflow-wrap: anywhere;  /* as AdwActionRow: the whole subtitle, over lines if needed */
}
.action-row .suffix { flex: none; display: flex; align-items: center; gap: 8px; }
.action-row .problem { display: block; font-size: 13px; }
.chevron { color: var(--dim-fg); font-size: 20px; }

.status-page {
  text-align: center;
  padding: 64px 16px;
  color: var(--dim-fg);
}
.status-page .icon { font-size: 48px; opacity: 0.6; }
.status-page h2 { color: var(--window-fg); font-size: 20px; margin: 12px 0 6px; }

/* --- Buttons, entries, badges ------------------------------------------- */

button, .button {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-button);
  padding: 7px 17px;
  min-height: 34px;
  background: var(--button-bg);
  color: inherit;
  cursor: pointer;
}
button:hover { background: var(--button-hover); }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
button.suggested, .button.suggested { background: var(--accent); color: var(--accent-fg); }
button.suggested:hover { filter: brightness(1.08); }
button.destructive { color: var(--destructive-text); }
button.flat { background: none; font-weight: 400; }
button:disabled { opacity: 0.5; cursor: default; }
button:disabled:hover { background: var(--button-bg); filter: none; }
button.flat:hover { background: var(--button-hover); }
button.pill { border-radius: 999px; padding: 10px 32px; }

.buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

label.entry-row {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
}
label.entry-row + label.entry-row { border-top: 1px solid var(--border); }
label.entry-row span { font-size: 13px; color: var(--dim-fg); }
label.entry-row input, label.entry-row select {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 2px 0;
}
label.entry-row input:focus-visible, label.entry-row select:focus-visible { outline: none; }
label.entry-row:focus-within { box-shadow: inset 0 0 0 2px var(--focus-ring); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--button-bg);
}
.badge.accent { color: var(--accent-text); }
.badge.success { color: var(--success-text); }
.badge.warning { color: var(--warning-text); }
.badge.error { color: var(--destructive-text); }

/* --- Switches, toggle groups, spinners, icons (libadwaita's widgets) ----- */

/* AdwSwitchRow's switch: a form's button (role="switch", aria-checked). */
.switch {
  flex: none;
  width: 48px;
  min-height: 0;
  height: 26px;
  padding: 3px;
  border-radius: 14px;
  background: var(--switch-off);
  display: inline-flex;
}
.switch::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 6, 0.2);
  transition: transform 200ms ease;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::before { transform: translateX(22px); }
.switch:hover { background: var(--switch-off-hover); }
.switch[aria-checked="true"]:hover { background: var(--accent); filter: brightness(1.08); }
.switch:disabled:hover { background: var(--switch-off); filter: none; }
.switch[aria-checked="true"]:disabled:hover { background: var(--accent); }

/* AdwToggleGroup: one choice of a few, the chosen one raised. */
.toggle-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--button-bg);
}
.toggle-group > * {
  padding: 4px 12px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.toggle-group > a:hover { background: var(--button-hover); }
.toggle-group > [aria-current] { background: var(--toggle-checked); box-shadow: 0 1px 3px var(--card-shade); }

/* AdwSpinner, and symbolic icons (16 px, the text's colour). */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--dim-fg);
  border-inline-end-color: transparent;
  animation: spinner 1s linear infinite;
}
@keyframes spinner { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.icon { width: 16px; height: 16px; flex: none; fill: currentColor; }
.icon.success { color: var(--success-text); }
.icon.error { color: var(--destructive-text); }
.dim-label { opacity: 0.55; }

/* An insensitive row: shown, greyed out, not usable yet. */
.action-row.insensitive { opacity: 0.5; pointer-events: none; }

.pairing-code {
  font-family: "Adwaita Mono", ui-monospace, monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.recovery-key { font-size: 18px; letter-spacing: 0.02em; word-break: break-all; }

.error-text { color: var(--destructive-text); font-weight: 600; }

.banner {
  border-radius: var(--radius-card);
  padding: 12px 16px;
  margin-bottom: 20px;
  background: color-mix(in srgb, var(--destructive) 15%, transparent);
}

dl.properties { display: grid; grid-template-columns: max-content 1fr; margin: 0; }
dl.properties dt, dl.properties dd { padding: 10px 12px; margin: 0; }
dl.properties dt { color: var(--dim-fg); }
dl.properties dt:not(:first-of-type), dl.properties dt:not(:first-of-type) + dd {
  border-top: 1px solid var(--border);
}

.group h3 { font-size: 14px; font-weight: 700; margin: 20px 0 8px; margin-inline-start: 2px; }

label.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  cursor: pointer;
}
label.check-row + label.check-row { border-top: 1px solid var(--border); }
label.check-row input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
label.check-row:hover { background: var(--row-hover); }
label.check-row:focus-within { box-shadow: inset 0 0 0 2px var(--focus-ring); }

/* --- Handover sheet: printed for the person ------------------------------ */

.sheet { max-width: 640px; margin-top: 24px; }
.sheet h2 { font-size: 22px; margin: 0 0 12px; }
.sheet .pairing-code { font-size: 22px; }
.sheet ol { padding-inline-start: 22px; line-height: 1.6; }

@media print {
  .no-print { display: none !important; }
  body, .window, .content, .page { background: #fff; color: #000; display: block; padding: 0; }
  .sheet { margin: 0; max-width: none; break-after: page; }
  .sheet:last-of-type { break-after: auto; }
  .sheet .boxed-list { box-shadow: none; border: 1px solid #999; }
}

/* --- Login --------------------------------------------------------------- */

.login {
  max-width: 400px;
  margin: 12vh auto 0;
  padding: 0 16px;
  text-align: center;
}
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login p { color: var(--dim-fg); margin: 0 0 24px; }
.login form { text-align: start; }
.login .buttons { justify-content: center; }

/* --- Narrow windows ----------------------------------------------------- */

@media (max-width: 720px) {
  .window { flex-direction: column; }
  .sidebar { width: auto; border-inline-end: none; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar .row { white-space: nowrap; }
  .sidebar .row.disabled { display: none; }
}
