:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --grouped: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.16);
  --accent: #007aff;
  --danger: #ff3b30;
  --warn: #ff9f0a;
  --ok: #34c759;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --grouped: #1c1c1e;
    --text: #f2f2f7;
    --muted: #8e8e93;
    --line: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.28);
    --accent: #0a84ff;
    --danger: #ff453a;
    --warn: #ffd60a;
    --ok: #30d158;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.title-block { min-width: 0; }
h1, h2, p { margin-top: 0; }
h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}
h2 {
  margin-bottom: 2px;
  font-size: 22px;
  letter-spacing: 0;
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(36px + env(safe-area-inset-bottom));
}
.notice, .task-card, .empty {
  background: var(--surface);
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.notice { padding: 18px 16px; }
.notice.error { color: var(--danger); }
.section-head, .card-heading, .facts, .work-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-head { padding: 8px 4px 12px; }
.muted, .address { color: var(--muted); }
.counter, .badge {
  min-width: 28px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  padding: 4px 9px;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}
.badge { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  overflow: visible;
}
.filter, .tab, .icon-button, .back-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  padding: 10px 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}
.filter {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  white-space: normal;
  line-height: 1.15;
}
.filter-name { font-size: 12px; font-weight: 600; }
.filter-count { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.filter[hidden] { display: none; }
.search-box {
  display: block;
  margin: 0 0 12px;
}
.search-box input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.search-box input::placeholder { color: var(--muted); }
.action-row { grid-template-columns: 1fr; }
.action-sub { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filter.action { min-height: 48px; }
.filter.pick { outline: 2px solid var(--accent); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.inbox-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--text);
  font-size: 14px;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--fill);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chip.hot { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chip.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.filter.active, .tab.active {
  background: var(--accent);
  color: #fff;
}
.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 22px;
  font-size: 22px;
  line-height: 1;
}
.back-button {
  background: transparent;
  color: var(--accent);
  padding: 8px 0;
  font-size: 17px;
  font-weight: 500;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 0 12px;
  overflow: visible;
}
.tab { white-space: nowrap; }
.work-list { display: grid; gap: 12px; }
.task-card { padding: 16px; }
button.task-card { width: 100%; color: inherit; text-align: left; }
.task-card h3 { margin: 10px 0 6px; font-size: 20px; letter-spacing: -0.03em; }
.task-card .next { margin: 12px 0 0; color: var(--accent); font-weight: 600; }
.detail { margin-top: 8px; }
.facts { align-items: stretch; margin: 16px 0; }
.facts > div {
  flex: 1;
  padding: 12px;
  background: var(--fill);
  border-radius: 12px;
}
.facts span { display: block; color: var(--muted); font-size: 12px; }
.facts strong { display: block; margin-top: 4px; }
.portal-box { padding: 12px; border-radius: 12px; background: var(--fill); }
.portal-box.burnt { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.portal-box.safe { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tab-panel { padding-top: 8px; }
.target-confirm {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.target-confirm span { display: block; color: var(--muted); font-size: 12px; }
.file-picker, label { display: block; margin: 12px 0; }
.file-picker {
  padding: 18px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}
.file-picker input { display: none; }
select, input[type="text"], textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  color: var(--text);
  background: var(--fill);
  border: 0;
  border-radius: 12px;
}
.photo-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.photo-item img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
}
.group-title {
  margin: 8px 4px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.task-card.burnt { box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 35%, transparent); }
.primary {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.primary:disabled { opacity: .38; }
.result { margin-top: 10px; color: var(--ok); }
.material-row, .history-row, .estimate-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.estimate-box { padding: 12px; margin: 8px 0 12px; border-radius: 12px; background: var(--fill); }
.material-form { padding-top: 8px; }
.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  box-shadow: none;
}
