/* v2 */
/* base.css — CSS variables, reset, page fade-in */
/* ============ CSS Variables (defaults — overridden by theme.js) ============ */
:root {
  /* Colors — set by theme */
  --bg-primary: #faf8f5;
  --bg-secondary: #f0ece6;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --text-primary: #2c2c2c;
  --text-secondary: #6b6b6b;
  --text-muted: #999999;
  --border-color: #e8e4de;
  --border-light: #f0ece6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.12);
  --border-subtle: #f3f0eb;
  --overlay-bg: rgba(0,0,0,0.4);

  /* Accent — set by theme */
  --accent: #5b7fd6;
  --accent-light: #5b7fd620;
  --accent-hover: #5b7fd6dd;

  /* Semantic colors */
  --success-bg: #e8f5e9;
  --success-text: #2e7d32;
  --warning-bg: #fff3e0;
  --warning-text: #e65100;
  --danger-bg: #ffebee;
  --danger-text: #c62828;
  --info-bg: #e3f2fd;
  --info-text: #1565c0;

  /* Grade colors */
  --grade-a: #2e7d32;
  --grade-b: #1565c0;
  --grade-c: #f9a825;
  --grade-d: #e65100;
  --grade-f: #c62828;

  /* Layout */
  --nav-height: 60px;
  --header-height: 56px;
  --max-width: 600px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-md: 1rem;
  --font-size-2xl: 2rem;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Accent pressed */
  --accent-pressed: color-mix(in srgb, var(--accent) 85%, #000);
}

/* ============ Reset ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

/* ============ Page Fade-in ============ */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
