/* ==========================================================================
   Theme variables and shared styles
   ========================================================================== */

:root {
  /* ---- color: light ---- */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --surface-raised: #ffffff;
  --text-primary: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-tertiary: #a0a0a6;
  --separator: rgba(60, 60, 67, 0.13);
  --separator-strong: rgba(60, 60, 67, 0.29);

  --accent: #12a594;
  --accent-strong: #0b7a70;
  --accent-soft: rgba(18, 165, 148, 0.12);
  --accent-contrast: #ffffff;

  --sem-correct: #2fae60;
  --sem-correct-soft: rgba(47, 174, 96, 0.14);
  --sem-incorrect: #e5484d;
  --sem-incorrect-soft: rgba(229, 72, 77, 0.14);
  --sem-unanswered: #d7a216;
  --sem-unanswered-soft: rgba(215, 162, 22, 0.16);
  --sem-doubt: #da0000;
  --sem-doubt-soft: rgba(232, 121, 26, 0.15);

  --danger: #e5484d;
  --shadow-card:
    0 1px 2px rgba(20, 20, 25, 0.04), 0 6px 16px rgba(20, 20, 25, 0.06);
  --shadow-sheet: 0 -8px 30px rgba(20, 20, 25, 0.18);
  --overlay-scrim: rgba(0, 0, 0, 0.42);

  /* ---- type ---- */
  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-display:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto,
    sans-serif;

  /* ---- shape / spacing ---- */
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --gutter: 18px;
  --content-max: 480px;

  --safe-top: env(safe-area-inset-top, 10px);
  --safe-bottom: env(safe-area-inset-bottom, 10px);

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #242426;
  --surface-raised: #262628;
  --text-primary: #f5f5f7;
  --text-secondary: #98989f;
  --text-tertiary: #6c6c70;
  --separator: rgba(255, 255, 255, 0.11);
  --separator-strong: rgba(255, 255, 255, 0.2);

  --accent: #2fd3be;
  --accent-strong: #58e6d3;
  --accent-soft: rgba(47, 211, 190, 0.16);
  --accent-contrast: #04211d;

  --sem-correct: #3ec96e;
  --sem-correct-soft: rgba(62, 201, 110, 0.16);
  --sem-incorrect: #ff6369;
  --sem-incorrect-soft: rgba(255, 99, 105, 0.16);
  --sem-unanswered: #f0c33e;
  --sem-unanswered-soft: rgba(240, 195, 62, 0.18);
  --sem-doubt: #da0000;
  --sem-doubt-soft: rgba(255, 155, 74, 0.18);

  --danger: #ff6369;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-sheet: 0 -8px 30px rgba(0, 0, 0, 0.5);
  --overlay-scrim: rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

/* ---- reset ---- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  overscroll-behavior-y: none;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select {
  font-family: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  max-width: 100%;
  display: block;
}

/* ---- shared primitives ---- */
.stack {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
  align-items: center;
}
.spacer {
  flex: 1;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 18px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease,
    background-color 0.2s;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--sem-incorrect-soft);
  color: var(--sem-incorrect);
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 10px 12px;
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
}
.icon-btn:active {
  transform: scale(0.92);
}

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

input[type="text"],
input[type="number"],
input[type="date"],
select.field {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--separator-strong);
  background: var(--surface-2);
  color: var(--text-primary);
}
input::placeholder {
  color: var(--text-tertiary);
}
label.field-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar {
  display: none;
}
