:root {
  --paper: #f6f3ee;
  --card: #fffdf9;
  --ink: #1d1c1a;
  --muted: #6f6a62;
  --faint: #a39d93;
  --line: #e4ded4;
  --accent: #2f4a3a;
  --accent-ink: #f6f3ee;
  --warn: #9a5b13;
  --warn-bg: #f7ead6;
  --bad: #9b2c22;
  --bad-bg: #f6e1dd;
  --good: #2f6b45;
  --good-bg: #e2efe5;
  --run: #2b5d8a;
  --run-bg: #e1ebf4;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Inter", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141413; --card: #1c1b19; --ink: #ece8e1; --muted: #a29c92; --faint: #6f6a62; --line: #2d2b28;
    --accent: #9cc4a8; --accent-ink: #141413; --warn: #e3b36f; --warn-bg: #3a2d18; --bad: #ef9a8f; --bad-bg: #3d1f1b;
    --good: #93cfa4; --good-bg: #1d3325; --run: #9cc2e6; --run-bg: #1b2a38; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141413; --card: #1c1b19; --ink: #ece8e1; --muted: #a29c92; --faint: #6f6a62; --line: #2d2b28;
  --accent: #9cc4a8; --accent-ink: #141413; --warn: #e3b36f; --warn-bg: #3a2d18; --bad: #ef9a8f; --bad-bg: #3d1f1b;
  --good: #93cfa4; --good-bg: #1d3325; --run: #9cc2e6; --run-bg: #1b2a38; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); font-variant-numeric: lining-nums; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 17px; }

.shell { max-width: 1080px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.brand { font-family: var(--serif); font-size: 20px; text-decoration: none; }
.nav { display: flex; gap: 2px; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; font-size: 14px; }
.nav a.on { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.tabbar { display: none; }
@media (max-width: 720px) {
  .nav { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
  .tabbar a { text-decoration: none; text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); padding: 4px 0; }
  .tabbar a svg { display: block; margin: 0 auto 2px; width: 22px; height: 22px; }
  .tabbar a.on { color: var(--ink); }
  h1 { font-size: 26px; }
}

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }
.section { margin: 30px 0 0; }
.section > h2 { margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); text-decoration: none; min-height: 56px; }
.row:first-child { border-top: 0; }
a.row:active, a.row:hover { background: color-mix(in srgb, var(--paper) 55%, var(--card)); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { color: var(--muted); font-size: 13px; text-align: right; flex-shrink: 0; }
.empty { padding: 22px 16px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--paper); color: var(--muted); white-space: nowrap; }
.pill.run { background: var(--run-bg); color: var(--run); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.good { background: var(--good-bg); color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex-shrink: 0; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.run { background: var(--run); }
.dots { display: inline-flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.dots span { display: inline-flex; gap: 4px; align-items: center; }
@keyframes pulse { 50% { opacity: .35; } }
.pill.run .dot, .dot.run { animation: pulse 1.6s ease-in-out infinite; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h3 { margin-bottom: 4px; }
.mac { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); padding: 10px 16px; border-radius: 999px; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; justify-content: center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
label.field > small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 11px 12px; outline: none; font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { appearance: none; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 13px; cursor: pointer; text-align: left; min-height: 42px; }
.seg button.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button small { display: block; color: var(--muted); font-size: 12px; }
.seg button[disabled] { opacity: .45; }
.seg.stack { flex-direction: column; }
.check { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; }

.sheet { position: fixed; inset: 0; background: rgb(0 0 0 / .35); display: flex; align-items: flex-end; justify-content: center; z-index: 30; }
.sheet .panel { background: var(--paper); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 721px) { .sheet { align-items: center; } .sheet .panel { border-radius: 18px; } }
.sheet .panel h2 { margin-bottom: 14px; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.ev { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; }
.ev.message { border-color: var(--accent); white-space: pre-wrap; word-wrap: break-word; }
.ev.note { color: var(--muted); font-size: 13px; }
.ev.error { border-color: var(--bad); color: var(--bad); }
.ev details summary { cursor: pointer; font-family: var(--mono); font-size: 12.5px; color: var(--muted); list-style: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev details summary::-webkit-details-marker { display: none; }
.ev pre { margin: 6px 0 0; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 320px; overflow: auto; }
.ev.tool { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { white-space: pre-wrap; word-wrap: break-word; }
.banner { padding: 12px 14px; border-radius: 12px; margin: 0 0 16px; background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.good { background: var(--good-bg); color: var(--good); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40; max-width: calc(100% - 32px); }
.search { margin-bottom: 12px; }
.attach { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.attach img { max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--line); }
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { margin-bottom: 18px; }
.two { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

code { font-family: var(--mono); font-size: .88em; background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }
.run-title { font-size: 24px; }
