:root {
  color-scheme: dark;
  --bg: #12140e;
  --bg-elev: #191d13;
  --column: #202518;
  --card: #28301f;
  --card-hover: #303826;
  --line: #3c4632;
  --text: #f4f2e8;
  --muted: #a8ae99;
  --faint: #7c8370;
  --accent: #d6f25c;
  --accent-ink: #17200a;
  --accent-text: #d6f25c;
  --high: #ff7a59;
  --mid: #f0c14d;
  --low: #9ccc6a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --serif: Cambria, "Palatino Linotype", Georgia, serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ebe6da;
  --bg-elev: #f7f4ec;
  --column: #f3efe4;
  --card: #fffdf8;
  --card-hover: #ffffff;
  --line: #ddd4c3;
  --text: #1c1d16;
  --muted: #5c6154;
  --faint: #847f72;
  --accent-text: #4d7c0f;
  --high: #c2410c;
  --mid: #a16207;
  --low: #3f6212;
  --shadow: 0 16px 40px rgba(70, 55, 20, 0.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  background:
    radial-gradient(900px 380px at 8% -12%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    var(--bg);
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled { opacity: 0.35; cursor: default; }

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

::selection { background: var(--accent); color: var(--accent-ink); }

[hidden] { display: none !important; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 28px;
  height: 28px;
  color: var(--accent-text);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

#stats {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
}

.board-nav {
  width: 228px;
  flex: 0 0 228px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 2px 12px 16px 16px;
  border-right: 1px solid var(--line);
}

.board-nav-title {
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-today {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 700;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-alert {
  margin-left: auto;
  color: #ff3b30;
  font-weight: 800;
  line-height: 1;
}

.nav-today.is-on .nav-alert { color: #7f1d1d; }

.nav-today.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-bin { margin-top: 4px; }

.nav-version {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.nav-account {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

.nav-account small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.nav-account.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-account.is-on small { color: inherit; }

.user-create {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}

.user-create input,
.user-row input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.user-create input { flex: 1 1 180px; }

.profile-form {
  flex-direction: column;
  align-items: flex-start;
}

.profile-form input {
  flex: 0 0 auto;
  width: 220px;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 220px) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-row input { width: 100%; }

.user-meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 720px) {
  .user-row { grid-template-columns: 1fr; }
}

.nav-version.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.release { margin: 0 0 18px; }
.release h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.release.is-current h3 { color: var(--accent-text); }
.release-date {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.release ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.release li { margin: 0 0 4px; }

.board-row.drop-target {
  box-shadow: inset 0 0 0 2px var(--accent-text);
}

.today-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.today-head {
  padding: 0 18px 8px;
}

.today-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.today-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.today-nav h2 {
  flex: 1;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.today-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.today-scroll {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 0 16px 28px;
}

.today-board-toggle {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  text-align: left;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.today-board-toggle::before {
  content: "▾ ";
  color: var(--muted);
  font-size: 18px;
}

.today-section.is-collapsed .today-board-toggle::before { content: "▸ "; }
.today-section.is-collapsed .today-kanban { display: none; }

.today-column-title {
  cursor: text;
}

.today-kanban {
  display: flex;
  gap: 12px;
  align-items: stretch;
  overflow-x: auto;
  min-height: 460px;
  padding-bottom: 6px;
}

.today-kanban .column {
  flex: 0 0 300px;
  width: 300px;
  height: 460px;
  max-width: none;
}

.card-board {
  margin-top: 8px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.board-switch { display: contents; }

.board-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
  cursor: grab;
}

.board-row.is-current { background: var(--card); box-shadow: inset 3px 0 0 var(--accent-text); }
.board-row.is-ghost { opacity: 0.35; }
.board-row.drop-before { box-shadow: inset 0 2px 0 var(--accent-text); }
.board-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent-text); }
.board-row.is-current.drop-before { box-shadow: inset 3px 0 0 var(--accent-text), inset 0 2px 0 var(--accent-text); }
.board-row.is-current.drop-after { box-shadow: inset 3px 0 0 var(--accent-text), inset 0 -2px 0 var(--accent-text); }

.board-link {
  flex: 1;
  min-width: 0;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 8px 8px 8px 10px;
  border-radius: 10px;
}

.board-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-row.is-current .board-link { font-weight: 700; }

.board-count {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.board-more {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--muted);
}

.board-more:hover,
.board-link:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }

.board-rename {
  width: 100%;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--accent-text);
  border-radius: 8px;
  padding: 7px 8px;
}

.board-add {
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
}

.board-add:hover { background: var(--card); color: var(--text); }

.board-row.is-paused { opacity: 0.5; }
.board-row.is-paused .board-link { cursor: default; }

.vacation {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.vacation-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

.vacation-dates[hidden] { display: none; }

.vacation-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.vacation-date input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}

.vacation-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.menu-item.is-current { box-shadow: inset 3px 0 0 var(--accent-text); }

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1;
}

#search {
  width: min(280px, 46vw);
  background: var(--column);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.icon-btn, .text-btn, .btn-primary {
  height: 36px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 36px;
  display: grid;
  place-items: center;
  color: var(--text);
}

.icon-btn:hover:not(:disabled),
.text-btn:hover,
.menu-item:hover {
  background: var(--card);
}

.icon-btn svg { display: block; }

:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

.text-btn, .btn-primary {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--column);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}

.btn-primary:hover { filter: brightness(1.05); }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 16px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.column {
  flex: 1 1 300px;
  width: auto;
  min-width: 280px;
  max-width: 420px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--column);
  background: color-mix(in srgb, var(--column) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.column.drop-before { box-shadow: inset 3px 0 0 var(--accent-text); }
.column.drop-after { box-shadow: inset -3px 0 0 var(--accent-text); }
.column.is-done .column-title { color: var(--muted); }

.column-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 8px;
}

.grip {
  width: 22px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--faint);
  cursor: grab;
  flex: 0 0 auto;
  border-radius: 6px;
}

.grip:hover { color: var(--text); background: var(--card); }

.column-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 4px;
  border-radius: 6px;
}

.column-title:hover { background: var(--card); }

.rename-input {
  flex: 1;
  min-width: 0;
  font-weight: 650;
  background: var(--bg);
  border: 1px solid var(--accent-text);
  border-radius: 6px;
  padding: 4px 6px;
}

.count {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.icon-btn.tiny {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--muted);
}

.cards {
  flex: 1;
  min-height: 48px;
  overflow-y: auto;
  padding: 2px 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 10px 14px;
  margin-bottom: 8px;
  cursor: grab;
  user-select: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.card:hover {
  background: var(--card-hover);
  transform: translateY(-1px);
}

.card:focus-visible { outline-offset: 3px; }

.card.pri-high { box-shadow: inset 3px 0 0 var(--high); }
.card.pri-medium { box-shadow: inset 3px 0 0 var(--mid); }
.card.pri-low { box-shadow: inset 3px 0 0 var(--low); }

.card.is-ghost { opacity: 0.35; pointer-events: none; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  border: 1.5px solid var(--faint);
}

.card.pri-low .dot::before { background: var(--low); border-color: var(--low); }
.card.pri-medium .dot::before { background: var(--mid); border-color: var(--mid); }
.card.pri-high .dot::before { background: var(--high); border-color: var(--high); }

.due {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.due.overdue, .due.soon { font-weight: 650; }
.due.overdue { color: var(--high); }
.due.soon { color: var(--mid); }

.card-title {
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card.is-done .card-title,
.card.is-done .card-notes,
.inbox-item.is-done strong,
.cal-task.is-done,
.editor-title.is-done {
  text-decoration: line-through;
}

.card.is-done .card-title,
.inbox-item.is-done strong,
.editor-title.is-done {
  color: var(--muted);
}

.card-notes {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-link {
  display: block;
  margin-top: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-text);
  font-size: 12px;
  text-decoration: none;
}

.card-link:hover { text-decoration: underline; }

.card.is-done .card-link { color: var(--muted); }

.editor-url {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

a.text-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

a.text-btn[hidden] { display: none; }

.card-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.inbox {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 22px 28px;
  max-width: 760px;
}

.inbox-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.inbox-head p {
  margin: 6px 0 14px;
  color: var(--muted);
  max-width: 58ch;
}

.inbox-form { margin: 0 0 14px; }

.inbox-input,
.check-row input[type="text"],
.check-add {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.inbox-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.inbox-item strong { display: block; font-weight: 650; }

.inbox-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.bin-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bin-head-row h2 { margin: 0; }

.bin-group { margin: 18px 0 8px; color: var(--faint); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }

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

.bin-row .inbox-item { flex: 1; margin-bottom: 0; }

.bin-row .inbox-item.is-done strong { text-decoration: line-through; color: var(--muted); }

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-grip, .inbox-grip {
  flex: 0 0 auto;
  color: var(--faint);
  cursor: grab;
  display: flex;
}

.sub-open {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 8px;
}

.sub-open:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }

.check-row.is-ghost, .inbox-row.is-ghost { opacity: 0.35; pointer-events: none; }
.check-row.drop-into { box-shadow: inset 0 0 0 2px var(--accent-text); border-radius: 10px; }
.check-row.drop-before { box-shadow: inset 0 2px 0 var(--accent-text); }
.check-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent-text); }

.inbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.inbox-row .inbox-item { flex: 1; margin-bottom: 0; }
.habit-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}
.habit-nav strong {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 650;
}
.habit-nav .text-btn:disabled { opacity: 0.4; }
.habit-list { display: flex; flex-direction: column; gap: 4px; }
.habit-empty { margin: 8px 0; color: var(--muted); font-size: 13px; }
.habit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
}
.habit-row strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.habit-row.is-done strong { text-decoration: line-through; color: var(--muted); }
.habit-percent { font-weight: 700; color: var(--accent-text); font-size: 12px; white-space: nowrap; }
.habit-form { display: flex; flex-direction: column; gap: 8px; }
.habit-create { display: flex; align-items: center; gap: 10px; }
.habit-create input[type="number"] {
  width: 110px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.habit-open { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.habit-marks { display: flex; gap: 6px; }
.habit-mark {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
}
.habit-mark.is-yes { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.habit-mark.is-no { background: color-mix(in srgb, var(--high) 18%, transparent); color: var(--high); border-color: transparent; }
.inbox-row.drop-before { box-shadow: inset 0 2px 0 var(--accent-text); }
.inbox-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent-text); }

.check-row input[type="text"],
.check-add {
  flex: 1;
  min-width: 0;
  width: auto;
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--bg);
}

.check-row.is-done input[type="text"] {
  text-decoration: line-through;
  color: var(--muted);
}

.check-remove {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--muted);
}

.due-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.repeat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.repeat-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--bg);
}

.repeat-chip.is-on {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 700;
}

.due-row input[type="date"] { flex: 1; }

.url-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > .text-btn { align-self: flex-start; margin-top: 8px; }

.muted-line {
  margin: 8px 4px 12px;
  color: var(--faint);
  font-size: 13px;
}

.composer { margin: 0; padding: 0 8px 10px; }

.composer-input {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.composer-input::placeholder { color: var(--faint); }

.composer-input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--accent-text);
  background: var(--card);
}

.drop-slot {
  height: 8px;
  border-radius: 99px;
  background: var(--accent-text);
  margin: 0 2px 8px;
}

.drag-clone {
  position: fixed;
  z-index: 70;
  margin: 0;
  pointer-events: none;
  transform: rotate(1.5deg);
  box-shadow: var(--shadow);
  cursor: grabbing;
}

body.is-dragging { user-select: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.is-dragging .card { transition: none; }

@media (min-width: 860px) {
  body.editor-open .app { margin-right: 400px; }
}

.editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 100%);
  z-index: 30;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px 18px 28px;
  overflow: auto;
  scrollbar-width: thin;
}

.editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.editor-title {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.editor-notes {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.field span, .editor-kicker {
  color: var(--muted);
  font-size: 12px;
}

.field select, .field input[type="date"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.danger {
  color: var(--high);
}

.linkish {
  padding: 6px 8px;
  border-radius: 8px;
}

.popover {
  position: fixed;
  z-index: 40;
  min-width: 220px;
  max-width: 280px;
  max-height: min(70vh, 480px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-note {
  margin: 4px 10px 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.menu-field {
  width: 100%;
  margin: 2px 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 16px;
}

.toast {
  align-self: center;
  margin: 0 16px 10px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
}

.view-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--column);
}

.view-switch button {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
}

.view-switch button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.calendar {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 16px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-nav h2 {
  margin: 0;
  min-width: 190px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.cal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
}

.cal-grid {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-dow {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.cal-day,
.cal-loose {
  min-height: 0;
  background: var(--column);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.cal-day {
  display: flex;
  flex-direction: column;
  padding: 6px;
  overflow: hidden;
}

.cal-day.is-out { opacity: 0.48; }
.cal-day.is-today { border-color: var(--accent-text); }
.cal-day.drop,
.cal-loose.drop { box-shadow: inset 0 0 0 2px var(--accent-text); }

.cal-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.cal-num {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  border-radius: 99px;
}

.cal-day.is-today .cal-num {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.cal-day.has-overdue .cal-num { color: var(--high); font-weight: 700; }
.cal-day.is-today.has-overdue .cal-num { color: var(--accent-ink); }

.cal-count {
  color: var(--faint);
  font-size: 11px;
}

.cal-tasks {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}

.cal-task {
  display: block;
  width: 100%;
  margin-bottom: 4px;
  padding: 4px 6px;
  border-radius: 7px;
  background: var(--card);
  border-left: 3px solid transparent;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.3;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-task.pri-high { border-left-color: var(--high); }
.cal-task.pri-medium { border-left-color: var(--mid); }
.cal-task.pri-low { border-left-color: var(--low); }
.cal-task.is-done { opacity: 0.72; }
.cal-task.is-moved { font-style: italic; box-shadow: inset 3px 0 0 var(--mid); }
.card.is-moved { box-shadow: inset 3px 0 0 var(--mid); }
.cal-task.is-ghost { opacity: 0.35; pointer-events: none; }

.cal-add,
.cal-composer {
  width: 100%;
  margin-top: 2px;
  border-radius: 7px;
  font-size: 12px;
  text-align: left;
  color: var(--faint);
}

.cal-composer {
  padding: 4px 6px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--text);
}

.cal-composer:focus {
  outline: none;
  border-style: solid;
  border-color: var(--accent-text);
}

.cal-loose {
  width: 230px;
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.cal-loose h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.cal-loose p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover, .drag-clone { transform: none; }
}

@media (max-width: 900px) {
  @supports (height: 100dvh) {
    html, body, .app { height: 100dvh; }
  }
  .app { overflow: hidden; min-width: 0; max-width: 100%; }
  .shell, .stage, .board-nav, .top { min-width: 0; max-width: 100%; }
  .shell { flex-direction: column; min-height: 0; }
  .board-nav {
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-height: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    max-width: 100%;
  }
  .board-nav > * { flex: 0 0 auto; }
  .vacation, .vacation-dates, .vacation-date { min-width: 0; }
  .nav-today,
  .nav-version,
  .nav-account,
  .board-add {
    width: auto;
    white-space: nowrap;
  }
  .nav-account {
    margin: 0;
    max-width: none;
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }
  .nav-bin { margin-top: 0; }
  .board-nav-title {
    flex: 0 0 auto;
    margin: 0 2px;
  }
  .board-list {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    width: max-content;
    min-width: max-content;
    max-width: none;
    overflow: visible;
  }
  .board-row { flex: 0 0 auto; max-width: min(220px, 68vw); }
  .board-link { flex: 1 1 auto; min-width: 0; }
  .board-row.drop-before,
  .board-row.is-current.drop-before { box-shadow: inset 2px 0 0 var(--accent-text); }
  .board-row.drop-after,
  .board-row.is-current.drop-after { box-shadow: inset -2px 0 0 var(--accent-text); }
  .board-add { align-self: center; }
  .shell { padding-bottom: calc(54px + env(safe-area-inset-bottom)); }
  .board-switch {
    display: flex;
    position: fixed;
    z-index: 25;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding:
      6px
      max(10px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .board-switch .board-nav-title { display: none; }
  .board-switch .board-list {
    flex: 1 1 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    width: auto;
    min-width: 0;
    max-width: none;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
  }
  .board-switch .board-row { flex: 0 0 auto; max-width: min(180px, 46vw); }
  .board-switch .board-add { flex: 0 0 auto; align-self: center; }
  body.editor-open .board-switch { display: none; }
  body.editor-open .shell { padding-bottom: 0; }
  .vacation {
    margin-top: 0;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-top: 0;
    border-top: 0;
  }
  .vacation-dates { flex-direction: row; flex-wrap: nowrap; }
  .vacation-date { flex: 0 0 auto; width: auto; }
  .vacation-date input { width: auto; min-width: 9.5rem; }
  .vacation-note { flex: 0 0 auto; }
  .stage { min-height: 0; overflow: hidden; }
  .cal-body { flex-direction: column; min-height: 0; overflow: auto; }
  .cal-grid { min-height: min(560px, 62dvh); flex: 1 1 auto; }
  .cal-loose { width: auto; flex: 0 0 auto; max-height: min(220px, 30dvh); }
  .cal-nav { flex-wrap: wrap; }
  .cal-nav h2 { min-width: 0; flex: 1; font-size: 22px; }
}

@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .column {
    flex: 0 0 min(300px, 86vw);
    width: min(300px, 86vw);
    max-width: none;
  }
}

.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 28px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-family: var(--serif);
}

.auth-card p { margin: 0; color: var(--muted); }

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth-card input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.auth-card .btn-primary { align-self: stretch; }

.auth-error { color: var(--high); }

.analytics { max-width: 920px; }

.analytics-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.analytics-select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
}

.analytics-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.analytics-total {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  text-align: left;
  padding: 12px;
  background: var(--column);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.analytics-total.is-on { box-shadow: inset 0 0 0 2px var(--accent-text); }

.analytics-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-total strong {
  font-family: var(--serif);
  font-size: 32px;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.analytics-total small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.analytics-total small.is-up { color: var(--accent-text); }
.analytics-total small.is-down { color: var(--high); }

.analytics-block { margin: 0 0 22px; }

.analytics-block h3 {
  margin: 0;
  font-size: 16px;
}

.analytics-block > p {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  font-family: var(--font);
}

.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-bar { fill: color-mix(in srgb, var(--accent) 72%, var(--column)); }
.chart-bar.is-on { fill: var(--accent); }
.chart-shade { fill: var(--accent); opacity: 0.14; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-label, .chart-axis { fill: var(--muted); font-size: 11px; }
.chart-avg { fill: none; stroke: var(--mid); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line { fill: none; stroke: var(--accent-text); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: color-mix(in srgb, var(--accent) 30%, transparent); }
.chart-past { fill: none; stroke: var(--faint); stroke-width: 2; stroke-dasharray: 5 4; }

.analytics-share {
  display: grid;
  grid-template-columns: minmax(72px, 120px) 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
  font-size: 13px;
}

.analytics-track {
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.analytics-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.analytics-day {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.analytics-row {
  display: flex;
  width: 100%;
  gap: 12px;
  align-items: baseline;
  text-align: left;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.analytics-row strong { font-weight: 650; }
.analytics-row small { margin-left: auto; color: var(--muted); }

@media (max-width: 720px) {
  .analytics-totals { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .vacation-dates { flex-direction: column; }
  .vacation-date, .vacation-date input { width: 100%; min-width: 0; max-width: 100%; }
  .top {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding:
      max(8px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      8px
      max(12px, env(safe-area-inset-left));
  }
  .brand { width: 100%; min-width: 0; }
  .brand > div { min-width: 0; }
  h1 { font-size: 22px; }
  #stats {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .view-switch {
    flex: 1 1 100%;
    order: 1;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .view-switch button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #undo, #redo, #theme { order: 2; }
  #add-column { order: 3; margin-left: 8px; padding: 0 12px; }
  #search {
    order: 4;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .board, .today-scroll, .inbox, .calendar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .board, .today-kanban {
    scroll-snap-type: x proximity;
    scroll-padding-inline: 12px;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .cal-grid {
    min-height: 0;
    flex: 0 0 auto;
    align-items: start;
    align-content: start;
  }
  .cal-loose { max-height: none; flex: 0 0 auto; }
  .cal-day { height: auto; }
  .cal-tasks { flex: 0 1 auto; max-height: 64px; }
  .cal-add {
    font-size: 0;
    line-height: 1;
    text-align: center;
    min-height: 28px;
    padding: 2px 0;
  }
  .cal-add::before {
    content: "+";
    font-size: 18px;
    line-height: 1;
  }
  .board-nav .vacation-dates { flex-direction: row; flex-wrap: nowrap; }
  .board-nav .vacation-date,
  .board-nav .vacation-date input {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
  }
  .column {
    flex: 0 0 min(300px, 86vw);
    width: min(300px, 86vw);
    max-width: none;
    scroll-snap-align: start;
  }
  .today-head { padding-left: 0; padding-right: 0; }
  .today-head h2, .inbox-head h2 { font-size: 24px; }
  .today-head-row, .bin-head-row, .habit-nav, .habit-create { flex-wrap: wrap; }
  .today-board-toggle { font-size: 22px; }
  .today-kanban {
    min-height: 0;
    height: min(560px, 68dvh);
  }
  .today-kanban .column {
    flex: 0 0 min(300px, 86vw);
    width: min(300px, 86vw);
    height: 100%;
    scroll-snap-align: start;
  }
  .inbox {
    max-width: none;
    padding-top: 4px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .habit-row { flex-wrap: wrap; align-items: center; }
  .habit-row strong { flex: 1 1 8rem; }
  .habit-percent { flex: 1 1 100%; white-space: normal; }
  .habit-mark { min-height: 36px; padding: 6px 12px; }
  .bin-row { flex-wrap: wrap; }
  .bin-row .inbox-item { flex: 1 1 100%; min-width: 0; }
  .check-remove, .icon-btn.tiny, .board-more {
    width: 36px;
    height: 36px;
  }
  .grip { width: 32px; height: 36px; }
  .cal-num { width: 26px; height: 26px; font-size: 14px; }
  .menu-item { padding: 12px 10px; }
  .popover { max-width: min(280px, calc(100vw - 16px)); }
  .editor {
    width: 100%;
    border-left: 0;
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(22px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }
  .editor-title { font-size: 22px; }
  .editor .linkish {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  body.editor-open { overflow: hidden; }
  input, select, textarea,
  .profile-form input,
  .auth-card input,
  .composer-input,
  .check-row input[type="text"],
  .check-add {
    font-size: 16px;
    min-width: 0;
    max-width: 100%;
  }
  .profile-form input { width: min(220px, 100%); }
  .auth {
    min-height: 100dvh;
    place-items: start center;
    padding:
      max(28px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }
  .auth-card { padding: 22px 16px; }
  .analytics-total { padding: 10px; }
  .analytics-total strong { font-size: 26px; }
  #account-name {
    display: block;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (hover: none) {
  .card:hover { background: var(--card); transform: none; }
  .card, .cal-task, .board-row { touch-action: pan-x pan-y; }
}
