:root {
  --bg: #f4f5f7;
  --bg-soft: #eceef2;
  --card: #ffffff;
  --fg: #111827;
  --fg-2: #4b5563;
  --muted: #8b93a1;
  --line: #e3e6eb;
  --line-strong: #d2d7df;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --test: #2563eb;
  --prod: #dc2626;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --log-bg: #0d1117;
  --log-fg: #c9d1d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --bg-soft: #151a22;
    --card: #161b23;
    --fg: #e6edf3;
    --fg-2: #b3bcc8;
    --muted: #7d8794;
    --line: #242b35;
    --line-strong: #333c48;
    --accent: #60a5fa;
    --accent-soft: #17233a;
    --test: #60a5fa;
    --prod: #f87171;
    --ok: #4ade80;
    --ok-soft: #122a1c;
    --warn: #fbbf24;
    --warn-soft: #2c2210;
    --err: #f87171;
    --err-soft: #2e1616;
    --log-bg: #0a0d12;
    --log-fg: #c9d1d9;
    --shadow: none;
  }
}

:root[data-theme='light'] {
  --bg: #f4f5f7; --bg-soft: #eceef2; --card: #fff; --fg: #111827; --fg-2: #4b5563;
  --muted: #8b93a1; --line: #e3e6eb; --line-strong: #d2d7df; --accent: #2563eb;
  --accent-soft: #e8efff; --test: #2563eb; --prod: #dc2626; --ok: #15803d;
  --ok-soft: #e6f6ec; --warn: #b45309; --warn-soft: #fdf3e3; --err: #b91c1c;
  --err-soft: #fdecec; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
}

:root[data-theme='dark'] {
  --bg: #0e1117; --bg-soft: #151a22; --card: #161b23; --fg: #e6edf3; --fg-2: #b3bcc8;
  --muted: #7d8794; --line: #242b35; --line-strong: #333c48; --accent: #60a5fa;
  --accent-soft: #17233a; --test: #60a5fa; --prod: #f87171; --ok: #4ade80;
  --ok-soft: #122a1c; --warn: #fbbf24; --warn-soft: #2c2210; --err: #f87171;
  --err-soft: #2e1616; --shadow: none;
}

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

/* 作者样式里的 display 会覆盖 UA 的 [hidden]{display:none}，这里统一兜底 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { min-height: 100dvh; }

.app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-title { flex: 1; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.top-actions { display: flex; gap: 6px; }
/* hidden 属性会被 display:flex 覆盖，必须显式兜底 */
.topbar[hidden] { display: none; }

.icon-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; background: transparent; color: var(--fg);
  font-size: 20px; line-height: 1;
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn[hidden] { display: none; }
.icon-btn.text-btn { font-size: 14px; font-weight: 600; padding: 0 12px; border-radius: 9px; }

.view { flex: 1; padding: 12px 12px calc(76px + var(--safe-b)); }

/* ── 底部 tab ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 6px 0 calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; min-height: 44px;
  color: var(--muted); text-decoration: none; font-size: 11px;
}
.tab-ico { font-size: 17px; line-height: 1; }
.tab.active { color: var(--accent); }

/* ── 卡片 ── */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 14px; margin-bottom: 10px;
}
.card.plain { padding: 0; overflow: hidden; }

.section-title {
  display: flex; align-items: center; gap: 6px;
  margin: 16px 2px 8px; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .6px;
}
.section-title:first-child { margin-top: 4px; }
.section-title .dot { width: 7px; height: 7px; border-radius: 50%; }

/* ── 任务卡 ── */
.task {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 13px 14px 13px 16px; margin-bottom: 10px;
  overflow: hidden;
}
.task::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--test);
}
.task.prod::before { background: var(--prod); }
.task.disabled { opacity: .55; }
.task-main { flex: 1; min-width: 0; }
.task-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.task-sub { color: var(--muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.test { color: var(--test); background: var(--accent-soft); }
.badge.prod { color: var(--prod); background: var(--err-soft); }
.badge.kind { color: var(--fg-2); background: var(--bg-soft); }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.err { color: var(--err); background: var(--err-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.muted { color: var(--muted); background: var(--bg-soft); }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--fg);
  font-size: 15px; font-weight: 600; font-family: inherit;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--prod); border-color: var(--prod); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

/* ── 运行中横幅 ── */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--fg); text-decoration: none;
}
.banner .spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.banner-text { flex: 1; font-size: 14px; }
.banner-text b { font-weight: 600; }
.banner-meta { color: var(--fg-2); font-size: 12px; }

/* ── 表单 ── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--fg); font-size: 16px; font-family: inherit;
  appearance: none;
}
textarea { min-height: 76px; resize: vertical; font-size: 14px; }
.input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--line-strong); border-radius: 999px; position: relative; transition: background .15s; }
.switch input:checked { background: var(--accent); }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked::after { transform: translateX(18px); }

/* ── 登录 ── */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-b)); max-width: 420px; margin: 0 auto;
}
.auth-logo { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.auth h1 { font-size: 22px; margin: 0 0 4px; }
.auth p.sub { color: var(--muted); margin: 0 0 26px; font-size: 13px; }
.auth .btn { margin-top: 6px; }
.auth-foot { margin-top: 26px; text-align: center; color: var(--muted); font-size: 11px; }

/* ── 运行详情 ── */
.run-head { padding: 2px 2px 10px; }
.run-status { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 650; }
.run-meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.run-meta b { color: var(--fg-2); font-weight: 500; }

.logbox {
  position: relative; background: var(--log-bg); border-radius: 12px;
  border: 1px solid #1f2630; overflow: hidden;
}
.log-scroll {
  height: clamp(240px, 52dvh, 560px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 12px calc(12px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 12px; line-height: 1.55; color: var(--log-fg);
  white-space: pre-wrap; word-break: break-all;
}
.log-line { min-height: 1.55em; }
.log-line.err { color: #ff9d9d; }
.log-line.warn { color: #ffd479; }
.log-line.ok { color: #7ee787; }
.log-line.sys { color: #7aa2f7; font-style: italic; }
.log-empty { color: #6b7280; }

.log-foot {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b));
  border-top: 1px solid #1f2630; background: #0a0e14;
}
.log-foot .btn { flex: 1; background: #161d27; border-color: #2a3441; color: #d6dde6; }
.log-foot .btn.danger { background: #5a1a1a; border-color: #7f2626; color: #ffd7d7; }
.log-foot .btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

.jump {
  position: absolute; right: 12px; bottom: 12px;
  padding: 8px 12px; border-radius: 999px; border: 1px solid #2a3441;
  background: #161d27cc; color: #d6dde6; font-size: 12px; backdrop-filter: blur(6px);
}
.jump[hidden] { display: none; }

.judge { margin-top: 10px; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); background: var(--card); }
.judge.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.judge.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); }
.judge.err { border-color: color-mix(in srgb, var(--err) 40%, transparent); background: var(--err-soft); }
.judge h3 { margin: 0 0 6px; font-size: 14px; }
.judge ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--fg-2); }
.judge li { margin: 3px 0; }

.checks { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; }
.checks li { display: flex; gap: 8px; padding: 3px 0; color: var(--fg-2); }
.checks .ic { width: 14px; flex: none; text-align: center; }
.checks .ic.ok { color: var(--ok); }
.checks .ic.warn { color: var(--warn); }
.checks .ic.fail { color: var(--err); }
.checks .ic.skip { color: var(--muted); }

/* ── 列表 ── */
.list { border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); overflow: hidden; box-shadow: var(--shadow); }
.item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 56px;
}
.item:last-child { border-bottom: none; }
.item:active { background: var(--bg-soft); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 18px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; min-height: 36px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--fg-2);
  font-size: 13px; font-family: inherit;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: none; }
.kv .v { text-align: right; overflow-wrap: anywhere; }

.empty { text-align: center; color: var(--muted); padding: 36px 20px; font-size: 13px; }

/* ── toast / sheet ── */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  max-width: min(88vw, 420px); padding: 10px 16px; border-radius: 10px; z-index: 90;
  background: rgba(17, 24, 39, .93); color: #fff; font-size: 13px; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }
.toast[hidden] { display: none; }

.sheet-mask {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end;
  background: rgba(8, 12, 20, .48); animation: fade .15s ease-out;
}
.sheet-mask[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(18px + var(--safe-b));
  animation: slideUp .22s cubic-bezier(.2,.8,.2,1);
  overscroll-behavior: contain;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 6px auto 14px; }
.sheet h2 { font-size: 17px; margin: 0 0 4px; }
.sheet .sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.danger-note {
  display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: var(--err-soft); color: var(--err); font-size: 12px; line-height: 1.45;
  border: 1px solid color-mix(in srgb, var(--err) 25%, transparent); margin-bottom: 12px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.hidden { display: none !important; }

@media (min-width: 720px) {
  .view { max-width: 720px; margin: 0 auto; width: 100%; }
  .tabbar { max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0; }
  .auth { max-width: 420px; }
}
