/* RA Tracker — base + shared components. Colors/fonts come from tokens.css. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--brand-soft);
  color: var(--text);
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.icon-lg {
  width: 22px;
  height: 22px;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
}

.figure {
  font-family: var(--font-figures);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.serif {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Brand mark ------------------------------------------------------- */

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

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: var(--logo) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}

.brand b {
  color: var(--brand);
  font-weight: 650;
}

/* ---- Buttons ---------------------------------------------------------- */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 550;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.btn:hover {
  --btn-border: var(--border-strong);
  --btn-bg: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  pointer-events: none;
}

.btn-primary {
  --btn-bg: var(--brand);
  --btn-fg: var(--on-brand);
  --btn-border: var(--brand);
}

.btn-primary:hover {
  --btn-bg: var(--brand-strong);
  --btn-border: var(--brand-strong);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  --btn-fg: var(--text-2);
}

.btn-ghost:hover {
  --btn-bg: var(--surface-2);
  --btn-border: transparent;
  --btn-fg: var(--text);
}

.btn-danger {
  --btn-fg: var(--c-danger);
}

.btn-danger:hover {
  --btn-bg: var(--c-danger-soft);
  --btn-border: transparent;
}

.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.icon-btn.is-active {
  color: var(--brand);
}

/* ---- Inputs ----------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
}

.hint {
  font-size: 12.5px;
  color: var(--text-3);
}

.input,
.select {
  height: 42px;
  width: 100%;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23868f87' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group > .icon {
  position: absolute;
  left: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.input-group > .input {
  padding-left: 42px;
}

.input-group > .input-action {
  position: absolute;
  right: 4px;
}

/* ---- Segmented control ------------------------------------------------ */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

/* ---- Chips & badges --------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

button.chip:hover,
a.chip:hover {
  border-color: var(--brand);
  color: var(--text);
  text-decoration: none;
}

.chip .count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text-2);
}

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

:root[data-theme="dark"] .badge-brand {
  color: var(--brand);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-brand {
    color: var(--brand);
  }
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}

.dot.ok {
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.dot.warn {
  background: var(--c-warn);
  box-shadow: 0 0 0 3px var(--c-warn-soft);
}

.dot.err {
  background: var(--c-danger);
  box-shadow: 0 0 0 3px var(--c-danger-soft);
}

/* ---- Card ------------------------------------------------------------- */

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

/* ---- Toast ------------------------------------------------------------ */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--text-invert);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease;
}

.toast .icon {
  color: var(--brand);
}

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

/* ---- Theme toggle ----------------------------------------------------- */

.theme-toggle button {
  width: 32px;
  padding: 0;
  justify-content: center;
}

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