
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d6dae1;
  --text: #16181d;
  --muted: #5b6270;
  --brand: #2563eb;
  --brand-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #15803d;
  --ok-bg: #e8f6ee;
  --warn: #a15c07;
  --warn-bg: #fff3e0;
  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #24282f;
    --border: #363b44;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --brand: #6c9bff;
    --brand-text: #0d1117;
    --danger: #ff9c8f;
    --danger-bg: #3a1d1a;
    --ok: #7bd7a1;
    --ok-bg: #163026;
    --warn: #f0b467;
    --warn-bg: #35270f;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom, 0px));
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 14px;
}

.topbar-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.35;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ------------------------------------------------------------- cards */
.card {
  margin: 0 0 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  min-width: 0;
}

.card-head h2 { margin: 0; }

#device-meta,
#device-title { overflow-wrap: anywhere; }

/* ------------------------------------------------------------- form */
.field {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field:first-of-type { margin-top: 4px; }

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px; /* iOS 上 <16px 会触发聚集缩放 */
  line-height: 1.4;
  overflow-wrap: anywhere;
}

textarea.input {
  resize: vertical;
  min-height: calc(var(--tap) + 30px);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

select.input { appearance: none; -webkit-appearance: none; }

.input:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
.check input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.input[aria-invalid="true"] { border-color: var(--danger); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: 13px;
  color: var(--muted);
}

.check input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 10px 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  margin-top: 14px;
  color: var(--brand-text);
  background: var(--brand);
  border-color: var(--brand);
}

.btn-block { width: 100%; }

.btn-quiet {
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.btn-danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--border);
  font-size: 14px;
}

/* ------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
}

.tab {
  flex: 1 1 0;
  min-height: var(--tap);
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.tab.is-active {
  color: var(--brand-text);
  background: var(--brand);
  border-color: var(--brand);
}

/* ------------------------------------------------------------- messages */
.error,
.ok,
.banner {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.error { color: var(--danger); background: var(--danger-bg); }
.ok { color: var(--ok); background: var(--ok-bg); }
.banner {
  margin: 0 0 14px;
  color: var(--warn);
  background: var(--warn-bg);
}

.note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ------------------------------------------------------------- lists */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list > li + li { margin-top: 10px; }

.item {
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}

.tag-status-queued { color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.tag-status-running { color: var(--brand); background: var(--surface); border: 1px solid var(--brand); }
.tag-status-completed { color: var(--ok); background: var(--ok-bg); }
.tag-status-failed { color: var(--danger); background: var(--danger-bg); }
.tag-status-canceled { color: var(--warn); background: var(--warn-bg); }

.tag-target { color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.tag-danger { color: var(--danger); background: var(--danger-bg); }

.meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meta-line {
  display: block;
  overflow-wrap: anywhere;
}

.cmd {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 12em;
  overflow-y: auto;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

details.output { margin-top: 8px; }

details.output > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  list-style: none;
}

details.output > summary::-webkit-details-marker { display: none; }

details.output > summary::before {
  content: "▸ ";
  margin-right: 2px;
}

details.output[open] > summary::before { content: "▾ "; }

pre.output {
  margin: 4px 0 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-height: 18em;
  overflow: auto;
}

.notice {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notice-text { overflow-wrap: anywhere; white-space: pre-wrap; }

/* ------------------------------------------------------------- 桌面 */
@media (min-width: 560px) {
  .wrap { padding: 24px 20px 40px; }
  .card { padding: 18px; }
  .row { flex-direction: row; gap: 12px; }
  .row .col { flex: 1 1 0; min-width: 0; }
  .topbar { padding-bottom: 18px; }
  .btn-primary { max-width: 240px; }
}

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