/* ============================================================
   cockmail — monochrome "mail terminal" design system
   No color. State is shown through weight, fill, hairline rules,
   and inversion only.
   ============================================================ */

:root {
  --c-bg: #FFFFFF;
  --c-fg: #0A0A0A;
  --c-surface: #F2F2F2;
  --c-rule: #D9D9D9;
  --c-muted: #8A8A8A;
  --c-subtle: #4A4A4A;
  --c-invert-bg: #0A0A0A;
  --c-invert-fg: #FFFFFF;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;

  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.875rem;
  --fs-2xl: 2.5rem;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --radius: 2px;
  --dur: 150ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0A0A0A;
    --c-fg: #FFFFFF;
    --c-surface: #1A1A1A;
    --c-rule: #333333;
    --c-muted: #8A8A8A;
    --c-subtle: #D9D9D9;
    --c-invert-bg: #FFFFFF;
    --c-invert-fg: #0A0A0A;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must always win over any component's own display
   rule (e.g. .modal/.center-page setting display:flex) — otherwise toggling
   `el.hidden = true` in JS silently does nothing. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

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

::selection {
  background: var(--c-fg);
  color: var(--c-bg);
}

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

.mono {
  font-family: var(--font-mono);
}

.hairline {
  border: 1px solid var(--c-rule);
}

.hr {
  border: none;
  border-top: 1px solid var(--c-rule);
  margin: 0;
}

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-bg);
  color: var(--c-fg);
  border: 1px solid var(--c-fg);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.btn:hover {
  background: var(--c-fg);
  color: var(--c-bg);
}

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

.btn:disabled:hover {
  background: var(--c-bg);
  color: var(--c-fg);
}

.btn-solid {
  background: var(--c-invert-bg);
  color: var(--c-invert-fg);
  border-color: var(--c-invert-bg);
}

.btn-solid:hover {
  opacity: 0.85;
  background: var(--c-invert-bg);
  color: var(--c-invert-fg);
}

.btn-ghost {
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--c-surface);
  color: var(--c-fg);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
}

.btn-icon {
  padding: var(--sp-2);
  width: 32px;
  height: 32px;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.field label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-subtle);
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  background: var(--c-bg);
  border: 1px solid var(--c-rule);
  border-radius: var(--radius);
  padding: var(--sp-3);
  color: var(--c-fg);
  transition: border-color var(--dur) var(--ease);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--c-fg);
  outline: none;
}

.field .hint {
  font-size: var(--fs-xs);
  color: var(--c-muted);
}

.field .error {
  font-size: var(--fs-xs);
  color: var(--c-fg);
  font-weight: 700;
}

.error {
  color: var(--c-fg);
}

.error::before {
  content: "\25A0 ";
}

/* ---------- Layout: centered auth-style pages ---------- */

.center-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
}

.panel {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--c-fg);
  padding: var(--sp-6);
}

.panel-wide {
  max-width: 720px;
}

.brand {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-1);
}

.brand .mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--c-fg);
  margin-right: var(--sp-2);
  vertical-align: middle;
}

.subtitle {
  font-size: var(--fs-sm);
  color: var(--c-subtle);
  margin-bottom: var(--sp-6);
}

.banner {
  padding: var(--sp-3);
  border: 1px solid var(--c-fg);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}

.banner-solid {
  background: var(--c-invert-bg);
  color: var(--c-invert-fg);
  border-color: var(--c-invert-bg);
}

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

.toast-stack {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 1000;
}

.toast {
  background: var(--c-invert-bg);
  color: var(--c-invert-fg);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  min-width: 220px;
  border: 1px solid var(--c-invert-bg);
  animation: toast-in var(--dur) var(--ease);
}

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

/* ---------- Table (admin) ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th,
td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-rule);
}

th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-subtle);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--c-fg);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-solid {
  background: var(--c-invert-bg);
  color: var(--c-invert-fg);
  border-color: var(--c-invert-bg);
}

.scroll {
  overflow: auto;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--c-rule);
  border-top-color: var(--c-fg);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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