/* ------------------------------------------------------------------ Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ring);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-press);
}
.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--panel);
  border-color: var(--accent);
  color: var(--accent);
}
.btn--danger {
  background: transparent;
  border-color: var(--bad-line);
  color: var(--bad);
}
.btn--danger:hover:not(:disabled) {
  background: var(--bad-soft);
  border-color: var(--bad);
}
.btn--block {
  width: 100%;
}
.btn__spin {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: 0.85;
  animation: gc-spin 0.7s linear infinite;
}

/* --------------------------------------------------------- Status dot/badge */
.statusdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.statusdot--ok {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok-soft);
}
.statusdot--warn {
  background: var(--warn);
  animation: gc-pulse 1.6s var(--ease) infinite;
}
.statusdot--bad {
  background: var(--bad);
}
.statusdot--neutral {
  background: var(--neutral);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--panel-2);
}
.badge--ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
}
.badge--warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}
.badge--bad {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: transparent;
}
.badge--neutral {
  color: var(--text-muted);
  background: var(--neutral-soft);
  border-color: transparent;
}
.badge--accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

/* ------------------------------------------------------------- Card / Panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.panel__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0;
}
.panel__body {
  padding: 16px;
}

/* ------------------------------------------------------------------ Spinner */
.spinner {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner__ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: gc-spin 0.8s linear infinite;
}
@keyframes gc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------- Empty / Error states */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.state__msg {
  font-size: 13px;
  max-width: 380px;
}
.state--error .state__title {
  color: var(--bad);
}

/* --------------------------------------------------------------------- Modal */
/* Shared icon button (modal close, toast dismiss). 28px square hit target. */
.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}
.iconbtn:hover {
  color: var(--text);
  background: var(--panel-2);
}
.iconbtn:focus-visible {
  outline: none;
  color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ring);
}

.modal__overlay {
  position: fixed;
  inset: 0;
  background: oklch(15% 0.01 var(--brand-hue) / 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: var(--z-modal);
  animation: gc-fade 120ms var(--ease);
}
@keyframes gc-fade {
  from {
    opacity: 0;
  }
}
.modal {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: gc-pop 140ms var(--ease);
}
@keyframes gc-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
.modal--wide {
  max-width: 720px;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.modal__body {
  padding: 18px;
}
.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------- Drawer */
.drawer__scrim {
  position: fixed;
  inset: 0;
  background: oklch(15% 0.01 var(--brand-hue) / 0.5);
  display: flex;
  justify-content: flex-end;
  z-index: var(--z-drawer);
  animation: gc-fade 120ms var(--ease);
}
.drawer {
  width: min(520px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop);
  animation: gc-drawer-in var(--dur-panel) var(--ease-out);
}
.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawer__titles {
  min-width: 0;
}
.drawer__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer__subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.drawer__body {
  padding: 18px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.drawer__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------- Toast */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  animation: gc-toast-in 180ms var(--ease);
}
@keyframes gc-toast-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}
.toast__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
}
.toast__icon--success {
  color: var(--ok);
  background: var(--ok-soft);
}
.toast__icon--error {
  color: var(--bad);
  background: var(--bad-soft);
}
.toast__icon--info {
  color: var(--accent);
  background: var(--accent-soft);
}
.toast__body {
  flex: 1;
  color: var(--text);
}
.toast__title {
  font-weight: 600;
  margin-bottom: 2px;
}
.toast__msg {
  color: var(--text-muted);
  word-break: break-word;
}

/* --------------------------------------------------------------------- Input */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.input {
  height: 36px;
  padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder {
  color: var(--text-faint);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input--mono {
  font-family: var(--font-mono);
}
