/* theme.css — 训练计划页设计系统（移动优先，深/浅色自适应，无外部依赖） */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --line: #dde5ec;
  --ink: #16202c;
  --ink-2: #5a6b7d;
  --ink-3: #8996a5;
  --accent: #e0562f;
  --accent-ink: #ffffff;
  --accent-soft: #fdece7;
  --ok: #2f7d5d;
  --ok-soft: #e6f4ee;
  --warn: #a86a00;
  --warn-soft: #fdf3e0;

  /* 图解配色 */
  --fig-ink: #1f2937;
  --fig-ghost: #a9b6c5;
  --fig-far: #c3ccd8;
  --fig-prop: #c3ccd8;
  --fig-equip: #111827;
  --fig-arrow: #e0562f;

  --radius: 14px;
  --radius-sm: 9px;
  --tabh: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b;
    --surface: #18202a;
    --surface-2: #1f2937;
    --line: #2b3746;
    --ink: #e8eef5;
    --ink-2: #a2b1c1;
    --ink-3: #74849a;
    --accent: #ff7a52;
    --accent-ink: #1a1005;
    --accent-soft: #33221c;
    --ok: #6ed3a8;
    --ok-soft: #1b2f28;
    --warn: #e8b062;
    --warn-soft: #302719;

    --fig-ink: #e8eef5;
    --fig-ghost: #56657a;
    --fig-far: #3c4a5c;
    --fig-prop: #3c4a5c;
    --fig-equip: #e8eef5;
    --fig-arrow: #ff7a52;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

/* ——— 布局骨架 ——— */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.topbar .sub { margin-left: auto; font-size: 12px; color: var(--ink-3); }

main {
  padding: 14px 14px calc(var(--tabh) + var(--safe-b) + 26px);
  max-width: 760px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabh) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  appearance: none; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 11px; font-family: inherit; padding: 0;
  touch-action: manipulation;
}
.tabbar button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-selected="true"] { color: var(--accent); font-weight: 600; }

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* ——— 通用块 ——— */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 15px; margin: 0 0 12px;
}
.card > h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.card > h2:last-child { margin-bottom: 0; }

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 4px 9px;
}
.section-title:first-child { margin-top: 4px; }

.subhead {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .07em;
  color: var(--ink-3); margin: 18px 0 2px;
}
.subhead::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#dayview .subhead:first-of-type { margin-top: 12px; }

p { margin: 0 0 9px; }
p:last-child { margin-bottom: 0; }
ul { margin: 0 0 9px; padding-left: 19px; }
li { margin: 3px 0; }
li::marker { color: var(--ink-3); }
b, strong { font-weight: 650; }
small { color: var(--ink-2); }

.muted { color: var(--ink-2); }
.tiny { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); }

.tip {
  background: var(--accent-soft); color: var(--ink);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 10px;
  font-size: 13px; line-height: 1.62;
}
.tip b { color: var(--accent); }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.75;
  background: var(--surface-2); color: var(--ink-2);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 11px; }
.kv .k { font-size: 11.5px; color: var(--ink-3); }
.kv .v { font-size: 16px; font-weight: 650; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ——— 折叠卡片 ——— */

details.card { padding: 0; overflow: hidden; }
details.card > summary {
  list-style: none; cursor: pointer; padding: 13px 15px;
  display: flex; align-items: center; gap: 10px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; flex: none;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .18s;
}
details.card[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
details.card[open] > summary { border-bottom: 1px solid var(--line); }
details.card .body { padding: 4px 15px 15px; }

.daytag {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.daytag.rest { background: var(--surface-2); color: var(--ink-3); }
.sumwrap { display: flex; flex-direction: column; min-width: 0; }
.summary-title { display: block; font-weight: 650; font-size: 14.5px; }
.summary-sub { display: block; font-size: 12px; color: var(--ink-3); }

/* ——— 按日期的课表 ——— */

.daymeta {
  font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}
.daymeta b { color: var(--accent); }

details.week > .body { padding: 2px 15px 12px; }

.dayrow {
  display: grid; grid-template-columns: 50px 34px 1fr; gap: 8px; align-items: center;
  width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-top: 1px solid var(--line);
  padding: 12px 0; font: inherit; color: inherit;
  touch-action: manipulation;
}
.dayrow:first-child { border-top: 0; }
.dayrow .dd { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; }
.dayrow .dw { font-size: 12px; color: var(--ink-3); }
.dayrow .dn { font-size: 13.5px; min-width: 0; }
.dayrow.rest .dn { color: var(--ink-3); }
.dayrow.past { opacity: .45; }
.dayrow[aria-current="true"] .dd,
.dayrow[aria-current="true"] .dn { color: var(--accent); font-weight: 700; }

/* ——— 动作条目 ——— */

.ex { display: grid; grid-template-columns: 106px 1fr; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); }
.ex:first-of-type { border-top: 0; }
.ex > div:last-child { min-width: 0; }
.ex-name { font-weight: 640; font-size: 14px; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0 0; }
.ex-cues { margin: 7px 0 0; font-size: 13px; color: var(--ink-2); }
.ex-cues li { margin: 2px 0; }

.fig {
  width: 100%; height: auto; display: block;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.fig .fp { stroke: var(--fig-prop); fill: none; }
.fig .fe { stroke: var(--fig-equip); fill: none; }
.fig .fa { stroke: var(--fig-arrow); fill: none; }
.fig .fa-head { fill: var(--fig-arrow); stroke: none; }
.fig .ghost .fb-t { stroke: var(--fig-ghost); fill: none; stroke-dasharray: 4 3; }
.fig .ghost .fb-l { stroke: var(--fig-ghost); fill: none; stroke-dasharray: 4 3; }
.fig .ghost .fl { stroke: var(--fig-ghost); fill: none; stroke-dasharray: 4 3; opacity: .55; }
.fig .ghost .fe { stroke: var(--fig-ghost); }
.fig .solid .fb-t { stroke: var(--fig-ink); fill: none; }
.fig .solid .fb-l { stroke: var(--fig-ink); fill: none; }
.fig .solid .fl { stroke: var(--fig-far); fill: none; }

.exlist.compact .ex { grid-template-columns: 84px 1fr; }

/* ——— 记录页 ——— */

/* 动作名独占一行，三个输入框平分下面一行。
   这样输入框有足够宽度，字号就能提到 16px（见下方注释）。 */
.logrow {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  align-items: center; padding: 11px 0; border-top: 1px solid var(--line);
}
.logrow:first-child { border-top: 0; }
.logrow .n { grid-column: 1 / -1; font-size: 14px; line-height: 1.4; min-width: 0; }
.logrow .n .tiny { display: inline; margin-left: 4px; }
.logrow input { padding: 9px 6px; text-align: center; }

/* ⚠️ 表单控件字号必须是 16px。
   iOS Safari 在聚焦字号 < 16px 的输入框时会自动放大整个页面，
   而且放大后不会自己缩回来。调小字号会重新触发这个 bug。
   不要用 user-scalable=no 去绕——那会同时禁掉用户的双指缩放，
   对视力不好的使用者是伤害，Apple 从 iOS 10 起也直接忽略了它。 */
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; line-height: 1.35; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 9px; min-width: 0;
  -webkit-appearance: none; appearance: none;
  touch-action: manipulation;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
textarea { resize: vertical; min-height: 62px; }

.btn {
  appearance: none; font: inherit; font-weight: 600; font-size: 15px;
  border-radius: 10px; padding: 12px 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); cursor: pointer; width: 100%;
  touch-action: manipulation;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn:active { transform: scale(.985); }

.chipline { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip {
  appearance: none; font: inherit; font-size: 13.5px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 13px;
  touch-action: manipulation;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

pre.out {
  white-space: pre-wrap; word-break: break-word; margin: 10px 0 0;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 11px;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 300px; overflow: auto; color: var(--ink-2);
}

.empty { text-align: center; color: var(--ink-3); padding: 34px 12px; font-size: 13.5px; }

@media print {
  .tabbar, .topbar { display: none; }
  main { padding: 0; }
  .view { display: block !important; }
}
