:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #e8e8ea;
  --muted: #9aa0ab;
  --accent: #4f9cff;
  --good: #5fd08a;
  --bad: #ff7a70;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 4px;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.35rem;
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px calc(96px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.card.ok {
  border-color: var(--good);
}

.card.bad {
  border-color: var(--bad);
}

p {
  margin: 0 0 10px;
}

ol {
  margin: 0;
  padding-left: 1.3em;
}

li + li {
  margin-top: 6px;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.good {
  color: var(--good);
}

.bad {
  color: var(--bad);
}

label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 10px 0 4px;
}

select,
button {
  font: inherit;
  min-height: 44px;
  border-radius: 10px;
}

select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 12px;
}

button {
  background: #252a35;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 16px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.quiet {
  background: transparent;
}

button:disabled {
  opacity: 0.5;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 8px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list > li {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.list > li:first-child {
  border-top: 0;
  padding-top: 0;
}

.list > li.off {
  opacity: 0.6;
}

.title {
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

.report {
  white-space: pre-wrap;
  word-break: break-word;
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  margin: 0 0 8px;
}

#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  background: #2b3140;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}

/* Tabs */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 10;
}

.tabbar[hidden] {
  display: none;
}

.tabbar a {
  flex: 1 1 0;
  max-width: 160px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.tabbar a.on {
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 2px 0 var(--accent);
}

/* Activity */
.toolbar {
  display: grid;
  gap: 8px;
}

input[type="search"] {
  font: inherit;
  min-height: 44px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 0 12px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chip {
  border-radius: 999px;
  white-space: nowrap;
  min-height: 40px;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

a.notice {
  display: block;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

a.notice.act {
  border-left-color: var(--accent);
}

a.notice.problem {
  border-left-color: var(--bad);
}

a.notice.unread .title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 4px;
}

a.notice.done {
  opacity: 0.6;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.level {
  font-weight: 600;
}

.level.act {
  color: var(--accent);
}

.level.problem {
  color: var(--bad);
}

.level.fyi {
  color: var(--muted);
}

.summary {
  color: var(--muted);
  font-size: 0.95rem;
}

.body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0;
}

.back {
  justify-self: start;
}

a.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #252a35;
  color: var(--text);
  text-decoration: none;
}

.formatted summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}

.formatted iframe {
  width: 100%;
  height: 60vh;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

/* Settings */
label.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text);
  font-size: 1rem;
  margin: 0;
}

li.kind {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Emails */
h2.section {
  margin: 12px 0 0;
}

li.email {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

li.email.blocked {
  border-left: 4px solid var(--bad);
}

li.email.focus {
  border-color: var(--accent);
}

label.pick {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--text);
  font-size: 1rem;
  margin: 0;
  cursor: pointer;
}

label.pick input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.email-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.email-head .tag {
  align-self: flex-start;
}

.email-head .to {
  word-break: break-all;
}

.goes {
  margin-top: 6px;
  color: var(--good);
}

.fix {
  margin-top: 6px;
  color: var(--bad);
}

details.read summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}

.row.acts {
  margin: 4px 0 0;
}

.at {
  margin: 8px 0;
}

input[type="datetime-local"],
textarea {
  font: inherit;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
}

input[type="datetime-local"] {
  min-height: 44px;
}

textarea.draft-text {
  min-height: 50vh;
  line-height: 1.45;
  resize: vertical;
  margin: 8px 0;
}

.approvebar {
  position: sticky;
  bottom: calc(64px + env(safe-area-inset-bottom));
  padding: 8px 0;
  z-index: 5;
}

.approvebar button {
  width: 100%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.approvebar button.warn {
  background: var(--bad);
  border-color: var(--bad);
}

a.button.quiet {
  background: transparent;
}
