/* ============================================================
   base.css — 設計 token、reset、版面骨架
   ============================================================ */

:root {
  --radius-card: 22px;
  --radius-pill: 50px;
  --radius-field: 14px;
  --radius-sm: 10px;

  --bg: #f2f4f7;
  --bg-grad: radial-gradient(120% 60% at 50% 0%, #ffffff 0%, #f2f4f7 55%);
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;
  --text: #14161a;
  --text-2: #6b7280;
  --text-3: #9aa1ac;
  --line: rgba(0, 0, 0, 0.07);
  --line-strong: rgba(0, 0, 0, 0.12);

  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --green: #2fbf5f;
  --green-soft: rgba(47, 191, 95, 0.14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.15);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.13);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.14);
  --gray: #8e8e93;
  --gray-soft: rgba(142, 142, 147, 0.14);

  --shadow-soft: 0 8px 28px -8px rgba(16, 24, 40, 0.12), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
  --shadow-float: 0 12px 40px -10px rgba(16, 24, 40, 0.24);
  --shadow-press: 0 2px 8px -2px rgba(16, 24, 40, 0.18);

  --page-gutter: clamp(16px, 4.6vw, 24px);
  --page-max: 560px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC",
    "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tab-h: 62px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html.dark {
  --bg: #08090b;
  --bg-grad: radial-gradient(120% 60% at 50% 0%, #16181d 0%, #08090b 60%);
  --surface: #17191e;
  --surface-2: #1f2228;
  --surface-3: #262a31;
  --text: #f2f3f7;
  --text-2: #9aa1ac;
  --text-3: #6f7683;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --accent-soft: rgba(10, 132, 255, 0.2);
  --green-soft: rgba(47, 191, 95, 0.2);
  --orange-soft: rgba(255, 149, 0, 0.2);
  --red-soft: rgba(255, 59, 48, 0.2);
  --purple-soft: rgba(168, 85, 247, 0.22);
  --gray-soft: rgba(142, 142, 147, 0.2);

  --shadow-soft: 0 8px 28px -8px rgba(0, 0, 0, 0.7), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-float: 0 14px 44px -12px rgba(0, 0, 0, 0.85);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
}

body.no-tab {
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  padding-top: calc(env(safe-area-inset-top) + 8px);
  min-height: 60vh;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 26px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 16px;
}

p {
  margin: 0;
}

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

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

input,
select,
textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
}

::selection {
  background: var(--accent-soft);
}

/* ---------- 頁首 ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 18px;
}

.page-head .title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-head .sub {
  color: var(--text-2);
  font-size: 13.5px;
  margin-top: 4px;
}

.page-head .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ---------- 分區標題 ---------- */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-2);
  text-transform: uppercase;
}

.section-title .right {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
  color: var(--accent);
}

/* ---------- 底部導覽 ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(calc(100% - 28px), 500px);
  height: var(--tab-h);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: center;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  z-index: 80;
  padding: 0 6px;
}

.tabbar[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--radius-pill);
  transition: color 0.2s var(--ease);
  position: relative;
}

.tab svg {
  width: 23px;
  height: 23px;
  stroke-width: 1.9;
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  z-index: -1;
}

.tab .badge {
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(16px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
}

/* ---------- 工具類 ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row.between {
  justify-content: space-between;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.muted {
  color: var(--text-2);
}
.tiny {
  font-size: 12.5px;
}
.mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.center {
  text-align: center;
}
.hidden {
  display: none !important;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-8 > * + * {
  margin-top: 8px;
}
.stack-12 > * + * {
  margin-top: 12px;
}
.stack-16 > * + * {
  margin-top: 16px;
}

/* 淡入 */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fade-up {
  animation: fadeUp 0.32s var(--ease) both;
}

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