/* Shared visual reference: HomeRelayClient/src/styles.css and appearance.js.
   Keep this static, same-origin surface independent of the native app runtime. */
:root {
  font-family: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  color-scheme: light;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-subtle: rgba(247, 250, 254, 0.8);
  --border: rgba(84, 104, 126, 0.18);
  --border-strong: rgba(75, 93, 116, 0.3);
  --text: #17191c;
  --muted: #5d6570;
  --accent: #0f6cbd;
  --accent-text: #0b5ca4;
  --on-accent: #ffffff;
  --error: #a4262c;
  --page-background: linear-gradient(145deg, #d4e5f3 0%, #f3f8fd 48%, #bcd6ed 100%);
  color: var(--text);
  background: #eef5fd;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-padding-top: 24px; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 33%), var(--page-background);
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-window {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
  backdrop-filter: blur(38px) saturate(1.35);
}
.title-bar {
  flex-shrink: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}
.title-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; }
.title-brand svg { width: 19px; height: 19px; fill: var(--accent); }
.title-context { font-size: 12px; color: var(--muted); }
.app-body { flex: 1; display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 0; }
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 26px 12px 18px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-subtle) 82%, transparent);
}
.sidebar-brand { display: grid; gap: 4px; padding: 6px 15px 30px; }
.sidebar-brand strong { font-size: 19px; font-weight: 600; }
.sidebar-brand span { color: var(--muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  padding: 10px 15px;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  font-weight: 400;
}
.nav-item svg { width: 23px; height: 23px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface-subtle)); }
.nav-item[aria-current="page"] { color: var(--accent-text); background: color-mix(in srgb, var(--accent) 14%, var(--surface-solid)); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent); }
.sidebar-note { display: grid; gap: 6px; margin-top: auto; padding: 18px 14px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.sidebar-note strong { color: var(--text); font-size: 14px; font-weight: 400; }
main { min-width: 0; padding: 34px 42px 24px; }
.page-header { margin-bottom: 28px; }
h1 { margin: 0; font-size: 34px; line-height: 1.18; letter-spacing: -0.035em; font-weight: 600; }
.page-header p { margin: 9px 0 0; font-size: 16px; }
h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; line-height: 1.4; }
h3 { margin: 28px 0 8px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 16px; font-weight: 600; }
p { color: var(--muted); line-height: 1.6; }
.card {
  min-width: 0;
  margin: 0 0 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  scroll-margin-top: 24px;
}
.card > p:first-of-type { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.auth { max-width: 560px; }
.auth h2 { font-size: 24px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
.columns .card { margin-bottom: 0; }
label { display: block; font-weight: 500; margin: 18px 0 8px; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-bottom-color: var(--muted);
  border-radius: 4px;
  background: var(--surface-solid);
  color: var(--text);
}
textarea { resize: vertical; overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { border-bottom-color: var(--accent); }
button {
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background 140ms ease;
}
button:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface-solid)); }
button:active { background: var(--surface-subtle); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button.primary { border-color: transparent; background: var(--accent); color: var(--on-accent); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
form > button { margin-top: 18px; }
.auth form > button { width: 100%; }
form small, .hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip-link { position: absolute; left: 24px; top: -100px; z-index: 5; padding: 12px; border-radius: 4px; background: var(--surface-solid); color: var(--accent); }
.skip-link:focus { top: 20px; }
.account-bar, .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.account-bar { margin-bottom: 22px; padding: 0 0 20px; border-bottom: 1px solid var(--border); scroll-margin-top: 24px; }
.account-bar h2 { margin-bottom: 4px; overflow-wrap: anywhere; }
.account-bar p { margin: 0; }
.account-bar > div, .row > div { min-width: 0; }
.account-bar > button, .row > button { flex-shrink: 0; }
.row { padding: 16px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row p { margin: 4px 0; font-size: 12px; overflow-wrap: anywhere; }
.row strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.danger { color: var(--error); }
#notice { margin-bottom: 20px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, var(--surface-solid)); line-height: 1.6; overflow-wrap: anywhere; }
#notice.error { color: var(--error); border-color: color-mix(in srgb, var(--error) 46%, var(--border)); background: color-mix(in srgb, var(--error) 8%, var(--surface-solid)); }
.secret { background: color-mix(in srgb, var(--accent) 9%, var(--surface-solid)); }
#secret-value { font-family: ui-monospace, monospace; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
footer { padding-top: 24px; color: var(--muted); font-size: 12px; line-height: 1.8; }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: rgba(31, 37, 46, 0.88);
    --surface-solid: #252b34;
    --surface-subtle: rgba(39, 46, 57, 0.82);
    --border: rgba(255, 255, 255, 0.11);
    --border-strong: rgba(255, 255, 255, 0.2);
    --text: #f4f6f8;
    --muted: #b4bdc8;
    /* Default-blue lightening, consistent with the client's dark surfaces. */
    --accent: #498dcd;
    --accent-text: #9ac8f0;
    --on-accent: #111111;
    --error: #ffb4ab;
    --page-background: linear-gradient(145deg, #112234 0%, #17222d 55%, #0b1a2b 100%);
    background: #121820;
  }
  .nav-item[aria-current="page"] { background: color-mix(in srgb, var(--accent) 24%, var(--surface-solid)); }
}

@media (max-width: 1100px) {
  main { padding: 28px; }
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .app-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
  .sidebar-brand, .sidebar-note { display: none; }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .nav-item { justify-content: center; gap: 6px; padding: 10px 6px; font-size: 13px; text-align: center; }
  .nav-item svg { width: 18px; height: 18px; }
  main { padding: 24px 16px; }
  h1 { font-size: 28px; }
  .page-header { margin-bottom: 22px; }
  .page-header p { font-size: 14px; }
  .card { padding: 20px; }
  .auth { max-width: none; }
  .row, .account-bar { align-items: flex-start; flex-wrap: wrap; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  button, .nav-item { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .card, #notice { border: 1px solid CanvasText; }
  .nav-item[aria-current="page"], button.primary { color: HighlightText; background: Highlight; border: 1px solid Highlight; }
  :focus-visible { outline-color: Highlight; }
}
