/* Fonts are served locally — no third-party requests */
@font-face {
  font-family: 'Readex Pro';
  src: url('/fonts/ReadexPro[wght].woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #141f0e;           /* lifted from #0f1a08 — less cave-like */
  --bg-card: #1d2b15;      /* clear step above bg — cards now float */
  --bg-input: #243219;     /* clear step above card */
  --border: #334d22;       /* slightly more visible */
  --border-focus: #6ab000;
  --text: #ddd8bc;         /* was #e8e0c0 — softer, reduces glare (12:1 ratio) */
  --text-dim: #a0b872;     /* secondary text */
  --text-muted: #708e48;   /* was #4d7030 — fixed: now ~4.8:1 (WCAG AA) */
  --accent: #6ab000;
  --accent-text: #141f0e;
  --accent-hover: #7cc800;
  --accent-dim: rgba(106,176,0,0.11);
  --success: #6ab000;
  --success-dim: rgba(106,176,0,0.11);
  --danger: #e05252;
  --danger-dim: rgba(224,82,82,0.13);
  --warning: #d5ab95;
  --row-hover: rgba(255,255,255,0.04); /* was 0.02 — actually visible now */
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 20px rgba(0,0,0,0.4);
}

/* Light theme — system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fff9e2;
    --bg-card: #ffffff;
    --bg-input: #fff4d0;
    --border: rgba(32,52,0,0.15);
    --border-focus: #477300;
    --text: #222831;
    --text-dim: rgba(32,52,0,0.70);
    --text-muted: rgba(32,52,0,0.30);
    --accent: #477300;
    --accent-text: #fff;
    --accent-hover: #5a9200;
    --accent-dim: rgba(71,115,0,0.1);
    --success: #477300;
    --success-dim: rgba(71,115,0,0.1);
    --danger: #c80000;
    --danger-dim: rgba(255,97,97,0.2);
    --warning: #d97706;
    --row-hover: rgba(0,0,0,0.02);
    --shadow: 0 2px 16px rgba(32,52,0,0.08);
  }
}

/* Light theme — manual override */
:root[data-theme="light"] {
  --bg: #fff9e2;
  --bg-card: #ffffff;
  --bg-input: #fff4d0;
  --border: rgba(32,52,0,0.15);
  --border-focus: #203400;
  --text: #222831;
  --text-dim: rgba(32,52,0,0.70);
  --text-muted: rgba(32,52,0,0.30);
  --accent: #203400;
  --accent-text: #fff;
  --accent-hover: #477300;
  --accent-dim: rgba(71,115,0,0.1);
  --success: #477300;
  --success-dim: rgba(71,115,0,0.1);
  --danger: #c80000;
  --danger-dim: rgba(255,97,97,0.2);
  --warning: #d97706;
  --row-hover: rgba(0,0,0,0.02);
  --shadow: 0 2px 16px rgba(32,52,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Readex Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.mono { font-family: 'Readex Pro', sans-serif; }

/* Layout */
.container { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem; }
.container-wide { max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* Poll description block */
.poll-description {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  color: var(--text);
  font-size: 1rem;
}
.poll-description p { margin-bottom: 0.75rem; }
.poll-description p:last-child { margin-bottom: 0; }
.poll-description h1,
.poll-description h2,
.poll-description h3,
.poll-description h4,
.poll-description h5,
.poll-description h6 {
  text-align: center;
  margin-bottom: 0.5rem;
}

/* Forms */
label { display: block; font-weight: 500; margin-bottom: 0.35rem; font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="url"],
input[type="number"], input[type="password"],
input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
}
textarea { resize: vertical; min-height: 80px; }

.form-group { margin-bottom: 1rem; }
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }
@media (max-width: 520px) { .form-row { flex-direction: column; gap: 0; } }

.checkbox-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0;
}
.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-danger { background: var(--danger-dim); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-dim); color: var(--success); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-icon { padding: 0.4rem; border-radius: 8px; background: transparent; border: 1px solid var(--border); color: var(--text-dim); cursor: pointer; }
.btn-icon:hover { border-color: var(--text-muted); color: var(--text); }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px; font-size: 0.75rem; font-weight: 600;
}
.badge-active { background: var(--success-dim); color: var(--success); }
.badge-inactive { background: var(--danger-dim); color: var(--danger); }
.badge-count { background: var(--accent-dim); color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.65rem 0.85rem;
  text-align: left; font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-dim); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: var(--row-hover); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: 0.65rem 1.2rem;
  font-weight: 600; font-size: 0.9rem;
  color: var(--text-dim); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Alert */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-error { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248,113,113,0.2); }
.alert-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(52,211,153,0.2); }
.alert-info { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(99,102,241,0.2); }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.header-brand {
  font-family: 'Readex Pro', sans-serif;
  font-weight: 700; font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
}

/* Misc */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Question card in form */
.question-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.question-card .q-label {
  font-weight: 600; margin-bottom: 0.5rem;
}
.question-card .q-label .optional {
  font-weight: 400; color: var(--text-muted); font-size: 0.85rem;
}

/* Pill */
.pill-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-input);
  color: var(--text);
}
.pill:hover { border-color: var(--accent); }
.pill.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Skeleton loading */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* Success animation */
@keyframes checkIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
.success-check {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--success-dim);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  animation: checkIn 0.4s ease-out;
}
.success-check svg { color: var(--success); }
