/* 基礎樣式、設計變數與主題 */

:root {
  color-scheme: dark;

  /* 深色主題（預設） */
  --bg: #0e1014;
  --bg-elevated: #171a21;
  --bg-input: #1d212a;
  --surface: #14171d;
  --surface-hover: #1e222b;
  --border: #262b36;
  --border-strong: #333a48;

  --text: #f2f4f8;
  --text-muted: #9aa3b2;
  --text-subtle: #6b7382;

  --accent: #ff8a3d;
  --accent-strong: #ff6f12;
  --accent-soft: rgba(255, 138, 61, 0.14);
  --accent-contrast: #1a0e04;

  --great: #34d399;
  --good: #7dd3fc;
  --ok: #fbbf24;
  --poor: #f87171;

  --danger: #f2555a;
  --danger-soft: rgba(242, 85, 90, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-full: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --header-h: auto;
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: 'PingFang HK', 'PingFang TC', 'Noto Sans HK', 'Microsoft JhengHei',
    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #faf7f2;
  --bg-elevated: #ffffff;
  --bg-input: #f2eee7;
  --surface: #ffffff;
  --surface-hover: #f6f2ec;
  --border: #e6e0d6;
  --border-strong: #d3cbbe;

  --text: #1c1a17;
  --text-muted: #6f6a62;
  --text-subtle: #948d82;

  --accent: #e2621a;
  --accent-strong: #c8500f;
  --accent-soft: rgba(226, 98, 26, 0.12);
  --accent-contrast: #fffaf5;

  --great: #0f9d69;
  --good: #1f7fb8;
  --ok: #c98a06;
  --poor: #d64545;

  --danger: #d33a3f;
  --danger-soft: rgba(211, 58, 63, 0.1);

  --shadow-sm: 0 1px 2px rgba(60, 45, 30, 0.08);
  --shadow-md: 0 6px 18px rgba(60, 45, 30, 0.1);
  --shadow-lg: 0 18px 44px rgba(60, 45, 30, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

img,
picture,
video,
canvas {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: var(--space-3);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: calc(var(--safe-top) + var(--space-2));
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
