/* RelayDesk shared design tokens and components (website + desktop app). */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e0e4ea;
  --border-strong: #cdd3dc;
  --text: #12161c;
  --text-2: #545d6b;
  --text-3: #858d9a;
  --accent: #2b67f6;
  --accent-hover: #1f55d6;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(43, 103, 246, 0.1);
  --ok: #138a43;
  --ok-soft: rgba(19, 138, 67, 0.12);
  --warn: #b86e00;
  --warn-soft: rgba(184, 110, 0, 0.12);
  --danger: #d02a2a;
  --danger-hover: #b31f1f;
  --danger-soft: rgba(208, 42, 42, 0.1);
  --stage: #0b0d11;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 20px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 2px 6px rgba(16, 24, 40, 0.08), 0 24px 48px rgba(16, 24, 40, 0.16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1015;
    --surface: #151920;
    --surface-2: #1b2029;
    --surface-3: #232a35;
    --border: #262d38;
    --border-strong: #343d4b;
    --text: #e9ecf1;
    --text-2: #a4acb9;
    --text-3: #6e7785;
    --accent: #5d8dff;
    --accent-hover: #7ca3ff;
    --accent-contrast: #0b1020;
    --accent-soft: rgba(93, 141, 255, 0.14);
    --ok: #3ccf7a;
    --ok-soft: rgba(60, 207, 122, 0.14);
    --warn: #f0a63a;
    --warn-soft: rgba(240, 166, 58, 0.14);
    --danger: #ff6b6b;
    --danger-hover: #ff8a8a;
    --danger-soft: rgba(255, 107, 107, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 48px rgba(0, 0, 0, 0.5);
  }
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.muted {
  color: var(--text-2);
}

.subtle {
  color: var(--text-3);
  font-size: 13px;
}

/* ---------------------------------------------------------------- brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand svg {
  width: 28px;
  height: 28px;
  flex: none;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 560;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:focus-visible,
.field input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

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

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

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

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

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

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-block {
  width: 100%;
  height: 42px;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

/* ---------------------------------------------------------------- forms */
.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field input,
select,
textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

textarea {
  height: auto;
  min-height: 120px;
  padding: 10px 12px;
  resize: vertical;
}

/* Phones zoom into inputs smaller than 16px when they get focus. */
@media (pointer: coarse) {
  .field input,
  select,
  textarea {
    font-size: 16px;
  }
}

select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.form {
  display: grid;
  gap: 16px;
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.form-note {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.toggle input {
  appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.15s;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.toggle input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked::after {
  transform: translateX(18px);
}

/* ---------------------------------------------------------------- surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  flex: none;
}

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

.code-chip {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- toast */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
