:root {
  --bg: #0b0d12;
  --bg-elev: #131722;
  --bg-elev-2: #1c2230;
  --border: #252b3a;
  --text: #e6e9f0;
  --text-dim: #9aa3b8;
  --text-faint: #6b7388;
  --accent: #f5c518;
  --accent-dim: #b58f0e;
  --conf-high: #16a34a;
  --conf-medium: #ca8a04;
  --conf-questionable: #f97316;
  --conf-uncertain: #dc2626;
  --conf-speculation: #9333ea;
  --conf-null: #6b7388;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(var(--bg) 70%, rgba(11, 13, 18, 0.95));
  backdrop-filter: blur(8px);
  padding: 12px 14px 8px;
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}

.site-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted { color: var(--text-dim); font-weight: 500; }

.subtitle {
  margin: 4px 0 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.fav-only {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.fav-only .star { font-size: 16px; line-height: 1; }
.fav-only .count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 1ch;
}

.fav-only[aria-pressed="true"] {
  background: var(--accent);
  color: #1a1300;
  border-color: var(--accent);
}
.fav-only[aria-pressed="true"] .star::before { content: "★"; }
.fav-only[aria-pressed="true"] .star { font-size: 0; }
.fav-only[aria-pressed="true"] .star::before { font-size: 16px; }

.search {
  position: relative;
  margin-bottom: 8px;
}
.search input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 32px 9px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent-dim); }
.search input::placeholder { color: var(--text-faint); }
#search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 20px;
  width: 28px; height: 28px;
  cursor: pointer;
  line-height: 1;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -14px;
  padding: 4px 14px 8px;
}
.chips::-webkit-scrollbar { display: none; }
.chips--confidence { padding-bottom: 4px; }

.chip {
  flex: 0 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--bg-elev-2);
  border-color: var(--accent-dim);
  color: var(--text);
}
.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.chip--new {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.chip--new[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1300;
}

.list { padding: 0 14px 24px; }

.day-header {
  position: sticky;
  top: 168px;
  z-index: 5;
  background: var(--bg);
  margin: 18px -14px 4px;
  padding: 8px 14px 6px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.day-header .day-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0;
  text-transform: none;
}

.act {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.act:hover { background: rgba(255, 255, 255, 0.02); }
.act:active { background: rgba(255, 255, 255, 0.04); }
.act.is-cancelled .act-name {
  text-decoration: line-through;
  color: var(--text-dim);
}
.act.is-fav .star-btn { color: var(--accent); }
.act.is-fav .star-btn::before { content: "★"; }
.act .star-btn::before { content: "☆"; }

.star-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-size: 22px;
  line-height: 1;
  width: 32px; height: 32px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.12s, background 0.12s, transform 0.1s;
}
.star-btn:hover { color: var(--accent); background: rgba(245, 197, 24, 0.08); }
.star-btn:active { transform: scale(0.88); }

.act-body { flex: 1 1 auto; min-width: 0; }

.act-line1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.act-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
  word-break: break-word;
}
.conf-dot {
  flex: 0 0 auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
  vertical-align: 1px;
}

.act-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
}
.act-meta .sep { color: var(--text-faint); }
.act-meta .source {
  color: var(--text-faint);
  font-size: 11px;
}
.act-meta .stage { font-weight: 500; color: var(--text); }
.act-meta .time { font-variant-numeric: tabular-nums; }

.act-notes {
  margin-top: 4px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
  line-height: 1.35;
}

.spec-badge,
.cancel-badge,
.new-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: 2px;
}
.spec-badge { background: rgba(147, 51, 234, 0.18); color: #c084fc; }
.cancel-badge { background: rgba(220, 38, 38, 0.18); color: #f87171; }
.new-badge { background: rgba(245, 197, 24, 0.22); color: var(--accent); }

.act-meta .added {
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14px;
}

.site-footer {
  padding: 20px 14px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.site-footer p { margin: 0 0 8px; }
.footer-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}
.link {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
}
.link:hover { color: var(--text); }

@media (min-width: 720px) {
  .site-header, .list, .site-footer {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
  .day-header { top: 168px; }
  h1 { font-size: 22px; }
}

/* -- Export modal ------------------------------------------------------ */

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  padding: 16px 16px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}
@media (min-width: 640px) {
  .modal { align-items: center; padding: 20px; }
  .modal__dialog {
    border-radius: 14px;
    border: 1px solid var(--border);
    padding-bottom: 20px;
  }
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.modal__header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.modal__close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 26px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.12s, color 0.12s;
}
.modal__close:hover { color: var(--text); background: var(--bg-elev-2); }
.modal__lead {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 8px;
}
body.modal-open { overflow: hidden; }

.export-row {
  border-top: 1px solid var(--border);
  padding: 12px 0 10px;
}
.export-row h3 {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.export-help {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.4;
}
.export-row__action {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.export-row__action input[type="text"] {
  flex: 1 1 220px;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  outline: none;
}
.export-row__action input[type="text"]:focus { border-color: var(--accent-dim); }
.export-row__action button {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.export-row__action button:hover:not(:disabled) {
  background: var(--border);
  border-color: var(--accent-dim);
}
.export-row__action button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* -- Print stylesheet -------------------------------------------------- */

@media print {
  :root {
    --bg: #fff;
    --bg-elev: #fff;
    --bg-elev-2: #fff;
    --border: #d1d5db;
    --text: #0b0d12;
    --text-dim: #4b5563;
    --text-faint: #6b7280;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
  }
  .site-header .search,
  .site-header .chips,
  .site-header__row .fav-only,
  .site-footer,
  .modal,
  .star-btn { display: none !important; }
  .site-header {
    position: static;
    backdrop-filter: none;
    background: #fff;
    border-bottom: 2px solid #000;
    padding: 0 0 6px;
    margin-bottom: 6px;
  }
  h1 { font-size: 14pt; }
  .subtitle { display: block; font-size: 9pt; color: #444; }
  .day-header {
    position: static;
    background: transparent !important;
    color: #000 !important;
    border-top: 1px solid #999;
    border-bottom: 0;
    padding: 4px 0 2px;
    margin: 10px 0 2px;
    font-size: 10pt;
  }
  .day-header .day-count { color: #555; }
  .list { padding: 0; }
  .act {
    border-bottom: 1px solid #ddd;
    padding: 4px 0;
    break-inside: avoid;
    page-break-inside: avoid;
    cursor: default;
    gap: 0;
  }
  .act-name { color: #000; font-size: 10pt; }
  .act-meta, .act-notes { color: #333; font-size: 8.5pt; }
  .act-meta .source { color: #666; }
  .act-meta .stage { color: #000; }
  .conf-dot { border: 1px solid #555; }
  .spec-badge, .cancel-badge {
    background: transparent !important;
    border: 1px solid #000;
    color: #000 !important;
  }
  @page { margin: 12mm 10mm; }
}
