/* 设计令牌 + reset + 通用组件。C、D 的样式只使用这里的令牌。 */

:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ebebf0;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --ok: #34c759;
  --ok-soft: rgba(52, 199, 89, 0.16);
  --bad: #ff3b30;
  --bad-soft: rgba(255, 59, 48, 0.12);
  --warn: #ff9f0a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --gutter: 16px;
  --content-max: 640px;
  --dur: 180ms;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, 0.18);
    --bad: #ff453a;
    --bad-soft: rgba(255, 69, 58, 0.18);
    --warn: #ff9f0a;
    --shadow: none;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none; /* iOS/安卓：不回弹、不下拉刷新 */
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

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

/* ---------- 布局 ---------- */
#app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
}

#views {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

#app[data-view="login"] #statusbar { display: none; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  transition: opacity var(--dur) var(--ease), background-color var(--dur) var(--ease);
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-plain { background: transparent; color: var(--accent); padding: 0 8px; }
.btn-block { width: 100%; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 16px; /* ≥16px，iOS 不会自动放大 */
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.segmented > button {
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.segmented > button[aria-pressed="true"],
.segmented > button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.tnum { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  /* 时间条是功能性的，不受影响 */
  *:not(#pr-timebar-fill), *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
