/* Tokens follow the Basta dashboard sign-in (basta-web-monorepo globals.css). */
:root {
  color-scheme: light;
  --page: #ffffff;
  --page-wash: linear-gradient(89deg, rgb(33 80 213 / 10%) 1.16%, rgb(255 70 31 / 10%) 96.57%);
  --card: #fafafa;
  --surface: #ffffff;
  --text: #171717;
  --muted: #525252;
  --subtle: #737373;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --link: #1a40aa;
  --primary: #262626;
  --primary-hover: #0a0a0a;
  --primary-text: #ffffff;
  --accent: #2150d5;
  --accent-soft: #e9eefb;
  --yes: #11883a;
  --no: #cc3819;
  --warn-bg: #fffbea;
  --warn-border: #ffe583;
  --warn-text: #665413;
  --danger-text: #cc3819;
  --danger-soft: #ffede9;
  --focus: #2150d5;

  --radius: 6px;
  --radius-lg: 10px;
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-xl: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #111111;
    --page-wash: linear-gradient(88.54deg, rgb(63 106 176 / 14%) 1.16%, rgb(237 92 52 / 12%) 96.57%);
    --card: #191919;
    --surface: #222222;
    --text: #fafafa;
    --muted: #b4b4b4;
    --subtle: #a1a1a1;
    --border: rgb(255 255 255 / 10%);
    --border-strong: rgb(255 255 255 / 18%);
    --link: #a6b9ee;
    --primary: #fafafa;
    --primary-hover: #ffffff;
    --primary-text: #0a0a0a;
    --accent: #7a96e6;
    --accent-soft: rgb(77 115 221 / 16%);
    --yes: #73cc91;
    --no: #ff9079;
    --warn-bg: rgb(255 211 48 / 8%);
    --warn-border: rgb(255 211 48 / 30%);
    --warn-text: #ffe583;
    --danger-text: #ff9079;
    --danger-soft: rgb(255 107 76 / 14%);
    --focus: #a6b9ee;
  }
}

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

html {
  min-height: 100%;
  background: var(--page-wash), var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.card {
  width: 100%;
  max-width: 520px;
  padding: 40px 48px 44px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 8px 32px rgb(33 80 213 / 6%);
}

.page-foot {
  margin: 20px 0 0;
  color: var(--subtle);
  font-size: var(--text-xs);
}

/* Brand header */
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 36px;
}
.logo { display: block; width: 104px; height: auto; color: var(--text); }
.brand-tag {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

/* Type */
h1 {
  margin: 0 0 8px;
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
h2 {
  margin: 0 0 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
p { margin: 0 0 12px; }
a { color: var(--link); font-weight: 500; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
.lead { color: var(--muted); }
.intro { margin-bottom: 24px; }
.intro .lead { margin: 0; }
.note, .hint { color: var(--muted); font-size: var(--text-sm); }
.note { margin: 20px 0 0; }
.back { margin: 28px 0 0; font-size: var(--text-sm); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Consent */
.app-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-weight: 700;
}
.claimed {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}
/* Client-controlled text: keep bidi overrides (e.g. U+202E) from reordering the text around it. */
.app-name, .account-name, .connection-app, .connection-meta dd, .return-host { unicode-bidi: isolate; }

.return {
  display: flex;
  gap: 12px;
  margin: 0 0 24px;
  padding: 14px 16px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
}
.return-icon { flex: none; color: var(--warn-text); padding-top: 2px; }
.return p { margin: 0; }
.return-label { font-size: var(--text-sm); color: var(--muted); }
.return-host {
  font-family: var(--mono);
  font-size: var(--text-md);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.return .return-warn { margin-top: 4px; font-size: var(--text-sm); color: var(--warn-text); }

.scope { margin-bottom: 24px; }
.checklist { list-style: none; margin: 0 0 20px; padding: 0; }
.checklist:last-child { margin-bottom: 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
}
.icon { display: block; flex: none; }
.checklist .icon { margin-top: 2px; }
.icon-yes { color: var(--yes); }
.icon-no { color: var(--no); }

fieldset.accounts { border: 0; margin: 0; padding: 0; min-width: 0; }
.accounts legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.account {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}
.account:hover { border-color: var(--accent); }
.account input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.account input:focus-visible { outline-offset: 3px; }
.account:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.account-name { font-weight: 500; overflow-wrap: anywhere; }

/* Buttons */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 20px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.2;
  color: var(--primary-text);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover, .button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
}
button.secondary:hover { background: var(--card); border-color: var(--subtle); }
button.danger { color: var(--danger-text); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger-text); }

/* Connections */
.connections {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.connection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}
.connection + .connection { border-top: 1px solid var(--border); }
.connection-info { min-width: 0; }
.connection-app { margin: 0 0 2px; font-weight: 600; overflow-wrap: anywhere; }
.connection-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}
.connection-meta div { display: flex; gap: 6px; min-width: 0; }
.connection-meta dt { color: var(--subtle); }
.connection-meta dd { margin: 0; overflow-wrap: anywhere; }
.connection form { flex: none; margin: 0; }
.connection button { min-height: 34px; padding: 0 14px; }

.empty {
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: var(--text-sm);
}
.empty p { margin: 0; }
.empty .empty-title { color: var(--text); font-weight: 500; font-size: var(--text-md); margin-bottom: 4px; }

/* Home */
.code-block {
  margin: 0 0 24px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
}
.steps { margin: 0; padding-left: 1.25rem; color: var(--muted); }
.steps li { padding: 2px 0 2px 4px; }
.steps li::marker { color: var(--subtle); font-weight: 600; }

/* Error */
.status-icon {
  display: inline-flex;
  margin-bottom: 16px;
  padding: 10px;
  color: var(--danger-text);
  background: var(--danger-soft);
  border-radius: 999px;
}
.status .lead { margin: 0; }

@media (max-width: 560px) {
  .page { justify-content: flex-start; padding: 16px; }
  .card { padding: 24px 20px 28px; }
  .brand { margin-bottom: 28px; }
  h1 { font-size: 1.3125rem; }
}

@media (max-width: 400px) {
  .connection { flex-direction: column; align-items: stretch; }
  .connection button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
