:root {
  --bg: #f3f4f6;
  --fg: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #d1d5db;
  --top: #1f2937;
  --top-fg: #f9fafb;
  --accent: #2563eb;
  --running: #dbeafe;
  --background: #eef4ff;
  --permission: #ffdeb2;
  --done: #d1f5d6;
  --stopped: #f5f0e1;
  --ended: #ebebeb;
  --stale: #e1e1e1;
  --error: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --card: #1f2937;
    --line: #374151;
    --top: #030712;
    --accent: #60a5fa;
    --running: #1e3a5f;
    --background: #1c2a44;
    --permission: #6b3d12;
    --done: #14532d;
    --stopped: #3f3a2a;
    --ended: #2a2a2a;
    --stale: #333333;
    --error: #fca5a5;
  }
}

* { box-sizing: border-box; }
/* .btn などの display の指定より、hidden を強くする */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--top);
  color: var(--top-fg);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  border-bottom: 4px solid #6b7280;
}
body[data-alert="running"] .top { border-bottom-color: #2563eb; }
body[data-alert="done"] .top { border-bottom-color: #16a34a; }
body[data-alert="permission"] .top { border-bottom-color: #ea580c; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 17px; margin: 0; }
.summary { margin: 4px 0 0; font-size: 13px; opacity: 0.9; }

main { padding: 8px 16px 24px; max-width: 900px; margin: 0 auto; }

.btn {
  display: inline-block;
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.top .btn { background: transparent; color: var(--top-fg); border-color: #4b5563; }

.login { padding: 24px 0; }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--error); font-size: 13px; margin: 4px 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.sortbar { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; font-size: 13px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  cursor: pointer;
}
.line1, .line2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.badge { font-weight: 700; font-size: 13px; padding: 0 6px; border-radius: 4px; background: rgba(127, 127, 127, 0.15); }
.time, .pc { font-size: 13px; color: var(--muted); }
.pc { margin-left: auto; }
.proj { font-weight: 600; overflow-wrap: anywhere; }
.title { overflow-wrap: anywhere; }
.prompt { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.eff-running { border-left-color: #2563eb; }
.eff-running .card-head { background: var(--running); }
.eff-background { border-left-color: #60a5fa; }
.eff-background .card-head { background: var(--background); }
.eff-permission { border-left-color: #ea580c; }
.eff-permission .card-head { background: var(--permission); }
.eff-done { border-left-color: #16a34a; }
.eff-done .card-head { background: var(--done); }
.eff-permission .proj, .eff-done .proj { font-weight: 800; }
.eff-stopped .card-head { background: var(--stopped); }
.eff-ended .card-head { background: var(--ended); }
.eff-stale .card-head { background: var(--stale); }

.card-body { padding: 8px 10px 12px; border-top: 1px solid var(--line); }
.card-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0 0 8px; font-size: 13px; }
.card-body dt { color: var(--muted); }
.card-body dd { margin: 0; overflow-wrap: anywhere; }
.card-body h3 { font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
.card-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 14px;
  max-height: 50vh;
  overflow-y: auto;
}
.revive { font-size: 13px; padding: 6px 8px; border-radius: 6px; background: rgba(127, 127, 127, 0.12); margin: 6px 0; }
.revive-sent { background: var(--done); }
.revive-requested, .revive-working { background: var(--running); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.foot { margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.share-status { font-size: 12px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
