:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #5f5f66;
  --line: #dcdcd6;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --focus: #1a5fd0;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111112;
    --surface: #1c1c1e;
    --text: #f0f0ee;
    --muted: #a5a5ab;
    --line: #38383c;
    --accent: #6fc196;
    --accent-text: #0d2018;
    --danger: #ff8a80;
    --focus: #8ab4ff;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 8px;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 10;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.brand a {
  color: var(--text);
  text-decoration: none;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 26px;
  margin: 8px 0 12px;
}

h2 {
  font-size: 19px;
  margin: 20px 0 8px;
}

h3 {
  font-size: 16px;
  margin: 12px 0 6px;
}

p {
  margin: 0 0 12px;
}

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

.small {
  font-size: 14px;
}

.notice {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.status:empty {
  display: none;
}

.status {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.card {
  margin-top: 32px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Controls */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  max-width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: none;
}

textarea {
  width: 100%;
  resize: vertical;
}

button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

button.apple {
  width: 100%;
  margin-bottom: 8px;
}

button.danger {
  color: var(--danger);
  border-color: var(--danger);
}

.link-button {
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
}

.icon-button {
  min-width: 44px;
  font-size: 22px;
  line-height: 1;
  border: 0;
  background: none;
  color: var(--muted);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adv {
  display: contents;
}

body[data-mode="simple"] .adv {
  display: none;
}

/* Quick add */

.quick-add {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quick-add input[type="text"] {
  width: 100%;
  font-size: 18px;
}

/* Tabs */

.tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 8px;
  overflow-x: auto;
}

.tabs [role="tab"] {
  flex: 1 0 auto;
  border-radius: 999px;
}

.tabs [role="tab"][aria-selected="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

[role="tabpanel"]:focus-visible {
  outline-offset: 4px;
}

/* Lists */

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

.list.sub {
  flex-basis: 100%;
  padding-left: 30px;
}

.list.compact li {
  padding: 4px 0;
}

.item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.item > input[type="checkbox"] {
  margin-top: 11px;
}

.item-body {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.item-title {
  border: 0;
  background: none;
  padding: 8px 0;
  min-height: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.meta.overdue {
  color: var(--danger);
}

.done .item-title,
li.done {
  color: var(--muted);
  text-decoration: line-through;
}

.links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.steps li {
  margin-bottom: 8px;
}

.copy-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.copy-box code {
  flex: 1 1 200px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

/* Dialogs and toast */

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.actions {
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
}

.toast[hidden] {
  display: none;
}

.toast button {
  background: var(--bg);
  color: var(--text);
  border: 0;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}
