:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e3e3e6;
  --text: #16171a;
  --text-dim: #6b6f76;
  --accent: #2f6fed;
  --green: #1f9d55;
  --yellow: #b7822e;
  --red: #d0342c;
  --gray: #9aa0a8;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1c1d21;
    --border: #2c2d31;
    --text: #f0f0f2;
    --text-dim: #9a9ea6;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.brand { font-weight: 700; }
.product { color: var(--text-dim); font-size: 13px; }

#app {
  padding: 12px 12px 84px;
  max-width: 720px;
  margin: 0 auto;
}

.screen h2 { font-size: 16px; margin: 4px 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.muted { color: var(--text-dim); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.status-idle { background: var(--green); }
.status-working { background: var(--accent); }
.status-waiting_approval { background: var(--yellow); }
.status-stopped { background: var(--gray); }
.status-error { background: var(--red); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { background: var(--red); border-color: var(--red); color: white; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.msg { padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: var(--surface); border: 1px solid var(--border); }
.msg .from { font-weight: 600; }
.msg.type-challenge { border-left: 3px solid var(--yellow); }
.msg.type-answer { border-left: 3px solid var(--accent); }
.msg.type-alert { border-left: 3px solid var(--red); }
.msg.type-approval_request { border-left: 3px solid var(--green); }

.filters { display: flex; gap: 8px; margin-bottom: 10px; overflow-x: auto; padding-bottom: 2px; }
.filters select, .filters input {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 13px;
}

.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.kanban-col { min-width: 220px; flex: 0 0 auto; }
.kanban-col h3 { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.kanban-col .card { margin-bottom: 8px; }

.bar-bg { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-fill.alert { background: var(--yellow); }
.bar-fill.pause { background: var(--red); }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  padding: 10px 2px 8px;
  cursor: pointer;
  position: relative;
}
.tab.active { color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: 2px; right: 18%;
  background: var(--red); color: white; border-radius: 999px;
  font-size: 10px; padding: 1px 5px;
}

.empty { color: var(--text-dim); text-align: center; padding: 24px 0; }
