:root {
  color-scheme: light;
  --bg: #ffffff;
  --glass: #f7f7f5;
  --glass-strong: #ffffff;
  --panel-soft: #f7f7f5;
  --text: #2f2f2f;
  --muted: #787774;
  --line: #e3e2df;
  --line-dark: #d6d5d2;
  --accent: #2f6f9f;
  --accent-strong: #2f2f2f;
  --accent-soft: #e8f2fb;
  --done: #3f7f5f;
  --shadow: 0 1px 2px rgba(15, 15, 15, 0.08);
  --inner-highlight: none;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --glass: #151a20;
  --glass-strong: #1f2630;
  --panel-soft: #171d24;
  --text: #f2f3f5;
  --muted: #9ca3af;
  --line: #2d3540;
  --line-dark: #3f4958;
  --accent: #8ab4f8;
  --accent-strong: #f2f3f5;
  --accent-soft: rgba(79, 137, 201, 0.18);
  --done: #7bc59a;
  --shadow: none;
  --inner-highlight: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body[data-theme="dark"] {
  background: var(--bg);
}

.ambient {
  background: transparent;
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

body[data-theme="dark"] .ambient {
  background: transparent;
}

/* iOS Safari zooms any input whose font-size is below 16px on focus.
   Force the minimum on touch devices so it stops zooming. */
@media (pointer: coarse) {
  input,
  textarea,
  select {
    font-size: max(16px, 1em);
  }
}

button,
input {
  font: inherit;
}

.app {
  isolation: isolate;
  position: relative;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 28px;
  z-index: 1;
}

.archive-page,
.settings-page {
  display: none;
}

body[data-view="archive"] .today-view,
body[data-view="settings"] .today-view {
  display: none;
}

body[data-view="archive"] .archive-page {
  display: grid;
}

body[data-view="settings"] .settings-page {
  display: grid;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 86px;
}

.topbar > div:first-child {
  min-width: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

body[data-theme="dark"] .eyebrow {
  color: var(--muted);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.4rem, 3.2vw, 2.4rem);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1;
  margin-bottom: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] h1 {
  text-shadow: none;
}

h2 {
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 0;
}

.top-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.utility-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

/* Archive + theme live behind the "..." menu; settings stays visible. */
.utility-actions #archiveButton,
.utility-actions #themeToggle {
  display: none;
}

.top-more-button {
  display: inline-grid;
}

.scope-toggle {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}

.scope-toggle::-webkit-scrollbar {
  display: none;
}

.scope-add-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  flex-shrink: 0;
  height: 26px;
  justify-content: center;
  min-height: 26px;
  padding: 0;
  width: 26px;
}

.scope-add-button:hover {
  background: var(--glass-strong);
  color: var(--text);
}

.scope-add-button svg {
  height: 14px;
  width: 14px;
}

.scope-button {
  flex-shrink: 0;
}

.scope-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 500;
  min-height: 26px;
  padding: 0 9px;
}

.scope-button.is-active {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .scope-toggle {
  background: #111821;
  border-color: var(--line);
}

body[data-theme="dark"] .scope-button.is-active {
  background: #26303d;
}

.icon-button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 500;
  min-height: 28px;
  padding: 0 8px;
}

.icon-button:hover {
  background: var(--glass);
  color: var(--text);
}

.theme-toggle {
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  min-height: 28px;
  padding: 0 8px;
  transition: background 160ms ease, color 160ms ease;
}

.theme-toggle:hover {
  background: var(--glass);
  color: var(--text);
}

.top-icon-button {
  align-items: center;
  background: var(--glass);
  border: 1px solid var(--line);
  display: inline-grid;
  height: 34px;
  justify-content: center;
  min-height: 34px;
  padding: 0;
  width: 34px;
}

.top-icon-button svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.1;
  width: 18px;
}

body[data-theme="dark"] .top-icon-button {
  background: #151a20;
  border-color: var(--line);
}

body[data-theme="dark"] .focus-panel,
body[data-theme="dark"] .column,
body[data-theme="dark"] .task-entry input {
  border-color: var(--line);
}

body[data-theme="dark"] .column,
body[data-theme="dark"] .task-entry input {
  background: var(--glass-strong);
}

body[data-theme="dark"] .focus-panel {
  background: var(--glass-strong);
  border-color: var(--line-dark);
}

body[data-theme="dark"] .theme-toggle:hover {
  background: #1f2630;
}

.progress-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.progress-wrap {
  background: var(--line);
  border-radius: 999px;
  height: 6px;
  margin: 0;
  overflow: hidden;
  width: min(260px, 42vw);
}

.progress-bar {
  background: var(--accent);
  border-radius: inherit;
  height: 100%;
  transition: width 180ms ease;
  width: 0%;
}

body[data-theme="dark"] .progress-wrap {
  background: #25303d;
}

body[data-theme="dark"] .progress-bar {
  background: #8ab4f8;
}

.summary {
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  min-width: 0;
  padding: 0;
  text-align: left;
}

.summary span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}

.summary span + span::before {
  content: "/";
  color: var(--line-dark);
  margin-right: 6px;
}

.focus-panel {
  background: var(--glass-strong);
  border: 1.5px solid var(--line-dark);
  border-radius: 14px;
  box-shadow: none;
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
  padding: 14px;
}

.focus-panel label {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.focus-panel label::before {
  background: currentColor;
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 0.78em;
  margin-right: 6px;
  -webkit-mask: radial-gradient(circle at center, transparent 0 22%, #000 23% 38%, transparent 39% 55%, #000 56% 100%);
  mask: radial-gradient(circle at center, transparent 0 22%, #000 23% 38%, transparent 39% 55%, #000 56% 100%);
  vertical-align: -0.08em;
  width: 0.78em;
}

.focus-panel input,
.task-entry input,
.edit-field textarea,
.archive-search {
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  width: 100%;
}

.focus-panel input {
  background: transparent;
  border-color: transparent;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  font-weight: 650;
  min-height: 46px;
  padding: 8px 0 2px;
}

.focus-panel input::placeholder {
  color: var(--muted);
  font-weight: 400;
  opacity: 0.7;
}

.focus-panel input:focus,
.task-entry input:focus,
.edit-field textarea:focus,
.archive-search:focus {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(74, 92, 111, 0.28);
  box-shadow: 0 0 0 4px rgba(74, 92, 111, 0.08);
}

body[data-theme="dark"] .focus-panel input:focus,
body[data-theme="dark"] .task-entry input:focus,
body[data-theme="dark"] .edit-field textarea:focus,
body[data-theme="dark"] .archive-search:focus {
  background: #303a48;
  border-color: #69788d;
  box-shadow: 0 0 0 3px rgba(185, 197, 214, 0.12);
}

.task-entry form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 0.4fr) minmax(116px, 0.26fr) auto;
  margin-bottom: 12px;
}

.add-task-toggle {
  display: none;
}

.task-entry input {
  background: var(--glass-strong);
  min-height: 44px;
  padding: 9px 12px;
}

.project-field {
  min-width: 0;
  position: relative;
}

.project-menu {
  background: var(--glass-strong);
  border: 1px solid var(--line-dark);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 15, 15, 0.16);
  display: none;
  gap: 4px;
  left: 0;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.project-menu.is-open {
  display: grid;
}

body[data-theme="dark"] .project-menu {
  background: #1b2430;
  border-color: #3f4958;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.project-menu-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  min-height: 34px;
  padding: 5px 6px;
  text-align: left;
}

.project-menu-item:hover {
  background: var(--glass);
}

body[data-theme="dark"] .project-menu-item:hover {
  background: #111821;
}

.project-menu-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 9px 8px;
}

.task-entry form > button,
.column-header button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease;
}

.task-entry form > button {
  background: var(--accent-strong);
  box-shadow: none;
  color: white;
  min-height: 44px;
  padding: 0 18px;
}

body[data-theme="dark"] .task-entry form > button {
  background: #d6dee9;
  color: #111821;
}

.task-entry form > button:hover {
  background: var(--text);
  transform: none;
}

body[data-theme="dark"] .task-entry form > button:hover {
  background: #ffffff;
}

.active-filter {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 0;
}

.active-filter:empty {
  display: none;
}

.active-filter-tag {
  border: 0;
  cursor: pointer;
}

.active-filter-clear {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 7px;
}

.active-filter-clear:hover {
  background: var(--glass);
  color: var(--text);
}

.board {
  display: grid;
  align-items: start;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.column {
  background: var(--glass);
  border: 0;
  border-radius: 16px;
  box-shadow: none;
  min-height: 300px;
  padding: 12px;
}

.done-column {
  background: var(--glass);
}

body[data-theme="dark"] .done-column {
  background: #121922;
}

.column-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-height: 32px;
}

.column-header h2 {
  align-items: center;
  background: #e7e6e3;
  border-radius: 999px;
  color: #4f4e4b;
  display: inline-flex;
  gap: 7px;
  line-height: 1;
  padding: 6px 10px;
}

body[data-theme="dark"] .column-header h2 {
  background: #28313d;
  color: var(--text);
}

.status-dot {
  background: #9b9a97;
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.done-dot {
  background: #42a06b;
}

.column-count {
  color: var(--muted);
  font-weight: 500;
  margin-left: 6px;
}

.column-header button {
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 6px 8px;
}

.column-header button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.task-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 10px 0 0;
  min-height: 58px;
  padding: 0;
  transition: background 160ms ease, outline-color 160ms ease;
}

.task-list.is-drop-target {
  background: var(--accent-soft);
  border-radius: 12px;
  outline: 1px dashed var(--line-dark);
  outline-offset: 6px;
}

.task {
  align-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  min-height: 66px;
  padding: 12px;
  transition: background 160ms ease, border-color 160ms ease;
}

.task.is-next-up {
  border-color: rgba(47, 111, 159, 0.44);
}

.task.is-waiting {
  opacity: 0.62;
}

body[data-theme="dark"] .task {
  background: #202733;
  border-color: #343f4f;
  color: var(--text);
}

.task:active {
  cursor: grabbing;
}

.task:hover {
  background: #ffffff;
  border-color: var(--line-dark);
  transform: none;
}

body[data-theme="dark"] .task:hover {
  background: #26303d;
  border-color: #4a596b;
}

.task.is-dragging {
  opacity: 0.46;
}

.task label {
  align-items: start;
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 20px 1fr;
  min-width: 0;
}

.task-check {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 70% 70%;
  border: 1.5px solid var(--line-dark);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  height: 18px;
  margin: 0;
  margin-top: 1px;
  outline-offset: 2px;
  transition: background-color 140ms ease, border-color 140ms ease;
  width: 18px;
}

.task-check:hover {
  border-color: var(--accent);
}

.task-check:focus-visible {
  outline: 2px solid var(--accent);
}

.task-check:checked {
  background-color: var(--accent);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M4.5 10.5l3.5 3.5 7.5-8'/></svg>");
  border-color: var(--accent);
}

body[data-theme="dark"] .task-check:checked {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%230d1117' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M4.5 10.5l3.5 3.5 7.5-8'/></svg>");
}

.task-content {
  align-items: start;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.task-title {
  font-size: 0.94rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.task-description {
  color: var(--muted);
  display: none;
  font-size: 0.78rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-description a,
.archive-description a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.task-description:not(:empty) {
  display: block;
}

.task-project {
  align-items: center;
  background: var(--tag-bg, #dcebf7);
  border: 0;
  border-radius: 5px;
  color: var(--tag-text, #245077);
  display: none;
  font-size: 0.68rem;
  font-weight: 500;
  justify-self: start;
  line-height: 1;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 4px 7px;
  gap: 4px;
}

.task-project[role="button"] {
  cursor: pointer;
}

.task-project[role="button"]:hover {
  filter: brightness(0.96);
}

body[data-theme="dark"] .task-project {
  opacity: 0.92;
}

.tag-icon {
  display: inline-flex;
  height: 0.78rem;
  width: 0.78rem;
}

.tag-icon svg {
  display: block;
  fill: none;
  height: 100%;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 100%;
}

.settings-dialog {
  background: transparent;
  border: 0;
  color: var(--text);
  max-width: min(420px, calc(100vw - 32px));
  padding: 0;
  width: 100%;
}

.settings-dialog::backdrop {
  background: rgba(15, 15, 15, 0.28);
}

.settings-panel {
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 15, 15, 0.18);
  display: grid;
  gap: 14px;
  padding: 16px;
}

body[data-theme="dark"] .settings-panel {
  background: #1b2430;
  border-color: var(--line);
}

.settings-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.settings-header h2 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.settings-header p,
.settings-empty {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0;
}

.settings-list {
  display: grid;
  gap: 8px;
}

.settings-backup {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
}

.settings-backup h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.settings-backup p {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.settings-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.export-textarea {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  margin: 12px 0;
  min-height: 180px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
}

body[data-theme="dark"] .export-textarea {
  background: #151a20;
  border-color: var(--line-dark);
}

#syncButton {
  position: relative;
}

.sync-status-dot {
  background: transparent;
  border-radius: 50%;
  height: 8px;
  pointer-events: none;
  position: absolute;
  right: 4px;
  top: 4px;
  transition: background 160ms ease;
  width: 8px;
}

#syncButton[data-sync-state="off"] .sync-status-dot {
  background: transparent;
}

#syncButton[data-sync-state="ok"] .sync-status-dot {
  background: var(--done);
}

#syncButton[data-sync-state="pending"] .sync-status-dot {
  background: var(--accent);
}

#syncButton[data-sync-state="error"] .sync-status-dot {
  background: #c2453a;
}

.sync-section {
  display: grid;
  gap: 14px;
}

.sync-error {
  background: rgba(194, 69, 58, 0.1);
  border-radius: 8px;
  color: #b3372d;
  font-size: 0.84rem;
  margin: 0;
  padding: 8px 10px;
}

body[data-theme="dark"] .sync-error {
  background: rgba(194, 69, 58, 0.18);
  color: #f3a39c;
}

.sync-status-text {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.sync-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.settings-row {
  align-items: center;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 132px;
  padding: 8px;
}

body[data-theme="dark"] .settings-row {
  background: #111821;
}

.settings-tag-preview {
  display: inline-flex;
}

.settings-row select {
  background: var(--glass-strong);
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  min-height: 34px;
  padding: 0 8px;
}

.archive-list {
  display: grid;
  gap: 12px;
}

.archive-page {
  gap: 16px;
  padding-top: 6px;
}

.archive-topbar {
  align-items: start;
  display: grid;
  gap: 14px;
}

.archive-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  width: 100%;
}

.archive-topbar h1 {
  margin-bottom: 0;
}

.archive-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: -8px 0 0;
}

.archive-search {
  background: var(--glass-strong);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  outline: none;
  padding: 8px 10px;
  width: 100%;
}

.archive-search:focus {
  border-color: rgba(74, 92, 111, 0.28);
  box-shadow: 0 0 0 4px rgba(74, 92, 111, 0.08);
}

body[data-theme="dark"] .archive-search {
  background: #1f2630;
  border-color: var(--line);
}

.back-button {
  align-items: center;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  justify-self: start;
  padding: 0;
  width: 36px;
}

.back-button:hover {
  background: var(--glass-strong);
  border-color: var(--line-dark);
}

.task-fab {
  display: none;
}

@media (max-width: 740px) {
  .task-fab {
    align-items: center;
    background: var(--text);
    border: 0;
    border-radius: 999px;
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    box-shadow: 0 12px 30px rgba(15, 15, 15, 0.22);
    color: var(--bg);
    cursor: pointer;
    display: inline-flex;
    height: 56px;
    justify-content: center;
    padding: 0;
    position: fixed;
    right: calc(env(safe-area-inset-right) + 18px);
    transition: transform 180ms ease, box-shadow 180ms ease;
    width: 56px;
    z-index: 50;
  }

  body[data-theme="dark"] .task-fab {
    background: var(--accent);
    color: #0d1117;
  }

  .task-fab:active {
    transform: scale(0.94);
  }

  .task-fab-icon {
    fill: none;
    height: 24px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2.4;
    transition: transform 200ms ease;
    width: 24px;
  }

  body.is-adding-task .task-fab-icon {
    transform: rotate(45deg);
  }

  body[data-view="archive"] .task-fab,
  body[data-view="settings"] .task-fab {
    display: none;
  }

  /* On mobile the FAB replaces the inline toggle. */
  .add-task-toggle {
    display: none;
  }
}

.back-icon {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 18px;
}

/* ----- Slide-in task detail panel ----- */

.task-panel {
  background: transparent;
  border: 0;
  inset: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  position: fixed;
  z-index: 60;
}

.task-panel[aria-hidden="false"] {
  pointer-events: auto;
}

.task-panel-backdrop {
  background: rgba(15, 15, 15, 0.32);
  inset: 0;
  opacity: 0;
  position: absolute;
  transition: opacity 220ms ease;
}

.task-panel[aria-hidden="false"] .task-panel-backdrop {
  opacity: 1;
}

.task-panel-content {
  background: var(--glass-strong);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(15, 15, 15, 0.18);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 440px;
  position: absolute;
  right: 0;
  top: 0;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1);
  width: 100%;
}

.task-panel[aria-hidden="false"] .task-panel-content {
  transform: translateX(0);
}

body[data-theme="dark"] .task-panel-content {
  background: #1b2430;
  border-left-color: var(--line);
}

.task-panel-header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 16px) 6px calc(env(safe-area-inset-left) + 16px);
}

.task-panel-delete {
  align-items: center;
  border-radius: 999px;
  color: var(--muted);
  display: inline-grid;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  width: 36px;
}

.task-panel-delete svg {
  height: 18px;
  width: 18px;
}

.task-panel-delete:hover {
  background: rgba(194, 69, 58, 0.1);
  color: #b3372d;
}

.task-panel-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 4px calc(env(safe-area-inset-right) + 20px) 14px calc(env(safe-area-inset-left) + 20px);
}

.panel-title {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: text;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  outline: none;
  padding: 10px 12px;
  transition: border-color 140ms ease, background 140ms ease;
  width: 100%;
}

.panel-title:focus {
  background: var(--glass-strong);
  border-color: var(--line-dark);
}

.panel-title::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

.task-panel-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 20px);
}

.task-panel-footer .primary-button,
.task-panel-footer .secondary-button {
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 40px;
  padding: 0 20px;
}

.task-panel-footer .primary-button {
  background: var(--text);
  border: 0;
  color: var(--bg);
  cursor: pointer;
}

body[data-theme="dark"] .task-panel-footer .primary-button {
  background: var(--accent);
  color: #0d1117;
}

.task-panel-footer .secondary-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

.task-panel-footer .secondary-button:hover {
  background: var(--glass);
}

.panel-project-field {
  position: relative;
  width: 100%;
}

.panel-project {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.86rem;
  outline: none;
  padding: 8px 14px;
  width: 100%;
}

.panel-project:focus {
  border-color: var(--line-dark);
}

.panel-description {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  min-height: 56px;
  outline: none;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.panel-description:focus {
  border-color: var(--line-dark);
}

.panel-section {
  display: grid;
  gap: 4px;
  margin-top: 4px;
}

.panel-section-header {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 8px;
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: uppercase;
}

.panel-subtask-count {
  background: var(--glass);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  padding: 2px 8px;
  text-transform: none;
}

body[data-theme="dark"] .panel-subtask-count {
  background: #28313d;
}

.panel-subtask-list {
  display: grid;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.panel-subtask {
  align-items: center;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 20px 1fr 28px;
  padding: 8px 6px;
}

.panel-subtask:hover {
  background: var(--glass);
}

.panel-subtask-check {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 70% 70%;
  border: 1.5px solid var(--line-dark);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  height: 18px;
  margin: 0;
  outline-offset: 2px;
  transition: background-color 140ms ease, border-color 140ms ease;
  width: 18px;
}

.panel-subtask-check:checked {
  background-color: var(--accent);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M4.5 10.5l3.5 3.5 7.5-8'/></svg>");
  border-color: var(--accent);
}

.panel-subtask-text {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  padding: 4px 0;
  width: 100%;
}

.panel-subtask.is-done .panel-subtask-text {
  color: var(--muted);
  text-decoration: line-through;
}

.panel-subtask-remove {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  height: 28px;
  justify-content: center;
  opacity: 0;
  padding: 0;
  transition: opacity 140ms ease, background 140ms ease;
  width: 28px;
}

.panel-subtask:hover .panel-subtask-remove,
.panel-subtask:focus-within .panel-subtask-remove {
  opacity: 1;
}

.panel-subtask-remove:hover {
  background: rgba(194, 69, 58, 0.12);
  color: #b3372d;
}

.panel-subtask-remove svg {
  fill: none;
  height: 14px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.4;
  width: 14px;
}

.panel-subtask-input {
  background: var(--glass);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'><path d='M12 5v14'/><path d='M5 12h14'/></svg>");
  background-position: 10px center;
  background-repeat: no-repeat;
  background-size: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  padding: 8px 10px 8px 32px;
  transition: border-color 140ms ease, background-color 140ms ease;
  width: 100%;
}

.panel-subtask-input:focus {
  background-color: var(--glass-strong);
  border-color: var(--line-dark);
}

.panel-subtask-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* Counter pill on task cards */
.task-subtask-counter {
  background: var(--glass);
  border-radius: 999px;
  color: var(--muted);
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 8px;
  padding: 2px 7px;
  vertical-align: middle;
}

.task-subtask-counter:not(:empty) {
  display: inline-block;
}

body[data-theme="dark"] .task-subtask-counter {
  background: #28313d;
}

/* Make the task content clickable as a "tap to open" target */
.task-content {
  cursor: pointer;
}

/* Mobile: full width panel */
@media (max-width: 740px) {
  .task-panel-content {
    max-width: 100%;
  }

  .task-panel-body {
    padding: 8px calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 32px) calc(env(safe-area-inset-left) + 16px);
  }
}

@media (pointer: coarse), (max-width: 740px) {
  .back-button {
    height: 40px;
    width: 40px;
  }

  .back-icon {
    height: 20px;
    width: 20px;
  }
}

.settings-page {
  gap: 18px;
  padding-top: 6px;
}

.settings-page-topbar {
  align-items: start;
  display: grid;
  gap: 14px;
}

.settings-page-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  width: 100%;
}

.settings-page-topbar h1 {
  margin-bottom: 0;
}

.settings-page-body {
  display: grid;
  gap: 18px;
}

.settings-section {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

body[data-theme="dark"] .settings-section {
  background: #1b2430;
  border-color: var(--line);
}

.settings-section-header h2 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.settings-section-header p {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
}

.scope-settings-list {
  display: grid;
  gap: 6px;
  position: relative;
}

.scope-settings-row {
  align-items: center;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr auto auto;
  padding: 6px 8px 6px 4px;
}

body[data-theme="dark"] .scope-settings-row {
  background: #28313d;
}

/* While dragging, the original row collapses out of the layout. */
.scope-settings-row.is-hidden-source {
  display: none;
}

/* The cloned row that follows the pointer. */
.scope-settings-row.is-ghost {
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  opacity: 0.78;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  transform: scale(1.02);
  cursor: grabbing;
}

body[data-theme="dark"] .scope-settings-row.is-ghost {
  background: #28313d;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}

/* Insertion-point line shown while dragging. */
.scope-settings-drop-indicator {
  background: var(--accent, #2f8af9);
  border-radius: 999px;
  height: 3px;
  left: 0;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  box-shadow: 0 0 0 4px rgba(47, 138, 249, 0.15);
}

.scope-settings-handle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: grab;
  display: inline-grid;
  height: 32px;
  justify-content: center;
  padding: 0;
  touch-action: none;
  width: 28px;
}

.scope-settings-handle:hover {
  color: var(--text);
}

.scope-settings-handle:active {
  cursor: grabbing;
}

.scope-settings-handle svg {
  height: 16px;
  width: 16px;
}

.scope-settings-name {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  padding: 6px 0;
  width: 100%;
}

.scope-settings-action {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.scope-settings-action:hover {
  background: var(--glass);
  color: var(--text);
}

.scope-settings-action.is-destructive:hover {
  background: rgba(194, 69, 58, 0.12);
  color: #b3372d;
}

.scope-settings-action svg {
  height: 16px;
  width: 16px;
}

.scope-settings-add {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.scope-settings-add input {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  outline: none;
  padding: 8px 14px;
}

.scope-settings-add input:focus {
  border-color: var(--line-dark);
}

.archive-group {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

body[data-theme="dark"] .archive-group {
  background: #111821;
}

.archive-group-header {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.archive-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.archive-items {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-items li {
  align-items: start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 2px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-top: 7px;
}

.archive-title {
  font-size: 0.88rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.archive-description {
  color: var(--muted);
  font-size: 0.76rem;
  grid-column: 1 / -1;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.archive-meta {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.edit-field {
  display: grid;
  gap: 6px;
}

.edit-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.edit-field input {
  background: var(--glass);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 8px 10px;
}

.edit-field textarea {
  background: var(--glass);
  font: inherit;
  min-height: 78px;
  padding: 8px 10px;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.edit-actions button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  min-height: 38px;
  padding: 0 14px;
}

.edit-actions button[type="submit"] {
  background: var(--accent-strong);
  color: #ffffff;
}

body[data-theme="dark"] .edit-actions button[type="submit"] {
  background: #d6dee9;
  color: #111821;
}

.secondary-button {
  background: var(--glass);
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  min-height: 38px;
  padding: 0 14px;
}

.task-project:not(:empty) {
  display: inline-flex;
}

.task-actions {
  align-items: center;
  display: flex;
  gap: 4px;
}

.next-up-task,
.waiting-task,
.edit-task {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-grid;
  height: 30px;
  place-items: center;
  padding: 0;
  width: 30px;
}

.next-up-task {
  font-size: 0.86rem;
}

.waiting-task svg,
.edit-task svg,
.delete-task svg {
  fill: none;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 16px;
}

.waiting-task svg {
  height: 15px;
  width: 15px;
}

.delete-task svg {
  height: 17px;
  width: 17px;
}

.waiting-task,
.edit-task {
  font-size: 0.72rem;
  font-weight: 600;
}

.next-up-task {
  padding: 0;
  width: 30px;
}

.next-up-task.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.waiting-task.is-active {
  background: #eee9de;
  color: #665235;
}

body[data-theme="dark"] .waiting-task.is-active {
  background: #2a2a22;
  color: #d6c69a;
}

.next-up-task:hover,
.waiting-task:hover,
.edit-task:hover {
  background: rgba(28, 37, 34, 0.08);
  color: var(--text);
}

body[data-theme="dark"] .next-up-task:hover,
body[data-theme="dark"] .waiting-task:hover,
body[data-theme="dark"] .edit-task:hover {
  background: rgba(255, 255, 255, 0.08);
}

.task-actions button:not(.task-menu) {
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, background 160ms ease, color 160ms ease;
}

.task:hover .task-actions button,
.task:focus-within .task-actions button,
.task.is-next-up .next-up-task,
.task.is-waiting .waiting-task {
  opacity: 1;
  pointer-events: auto;
}

.task-timer {
  align-items: center;
  color: var(--muted);
  display: none;
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 3.8em;
}

.task.is-next-up .task-timer {
  display: inline-flex;
}

.delete-task {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  height: 30px;
  justify-content: center;
  line-height: 1;
  width: 30px;
}

.delete-task:hover {
  background: rgba(28, 37, 34, 0.08);
  color: var(--text);
}

body[data-theme="dark"] .delete-task:hover {
  background: rgba(255, 255, 255, 0.08);
}

.done-column .task {
  color: var(--muted);
}

.done-column .task-title {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.empty {
  background: transparent;
  border: 1px dashed var(--line-dark);
  border-radius: 12px;
  color: var(--muted);
  padding: 14px;
}

body[data-theme="dark"] .empty {
  border-color: #445164;
}

@media (max-width: 980px) {
  .app {
    width: min(100%, 900px);
    padding: 18px 24px;
  }

  .topbar {
    align-items: flex-start;
    min-height: auto;
  }

  .board {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.82fr);
  }

  .column {
    min-height: 240px;
    padding: 12px;
  }
}

@media (max-width: 740px) {
  .app {
    width: 100%;
    padding: 14px 18px;
  }

  .topbar {
    align-items: center;
    gap: 10px;
    min-height: auto;
  }

  .top-actions {
    align-items: center;
    flex-direction: row;
    gap: 6px;
  }

  .summary {
    min-width: 0;
    padding: 0;
  }

  .board {
    grid-template-columns: 1fr;
  }

  .task-entry form {
    grid-template-columns: minmax(0, 1fr) minmax(132px, 0.42fr);
  }

  .project-field {
    grid-column: 1 / -1;
  }

  .task-entry form > button {
    grid-column: 1 / -1;
  }

  .task-entry form > button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 10px;
    margin-bottom: 12px;
  }

  .topbar > div:first-child {
    flex: 1 1 auto;
    width: 100%;
  }

  .top-actions {
    align-items: center;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: space-between;
    padding-top: 2px;
    width: 100%;
  }

  .utility-actions {
    flex: 0 0 auto;
  }

  .summary {
    flex: 0 0 auto;
    text-align: left;
  }

  .theme-toggle {
    flex: 0 0 auto;
  }

  .focus-panel,
  .column {
    border-radius: 12px;
    padding: 10px;
  }

  .task-entry form {
    grid-template-columns: 1fr;
  }

  .task-entry form {
    display: none;
  }

  body.is-adding-task .task-entry form {
    display: grid;
  }

  .task-entry form > button {
    grid-column: auto;
  }

  h1 {
    font-size: clamp(1.85rem, 8vw, 2.45rem);
    line-height: 1.04;
    max-width: none;
  }
}

@media (max-width: 430px) {
  .app {
    width: 100%;
    padding: 12px 16px;
  }

  .eyebrow {
    font-size: 0.68rem;
    margin-bottom: 4px;
  }

  h1 {
    font-size: clamp(1.75rem, 8.6vw, 2.18rem);
    max-width: none;
  }

  .top-actions {
    align-items: center;
    justify-content: space-between;
  }

  .theme-toggle {
    font-size: 0.76rem;
    min-height: 28px;
    padding: 0 4px;
  }

  .icon-button {
    font-size: 0.72rem;
    padding: 0 4px;
  }

  .summary {
    flex: 0 1 auto;
    gap: 4px;
    padding: 0;
  }

  .summary span {
    font-size: 0.7rem;
  }

  .progress-wrap {
    height: 5px;
    flex: 1 1 auto;
    width: auto;
  }

  .focus-panel {
    gap: 7px;
    margin-bottom: 12px;
    padding: 12px;
  }

  .focus-panel label {
    font-size: 0.72rem;
  }

  .focus-panel input,
  .task-entry input {
    border-radius: 9px;
    font-size: 0.92rem;
    min-height: 40px;
    padding: 8px 10px;
  }

  .focus-panel input {
    font-size: 1.08rem;
    min-height: 34px;
    padding: 4px 0 0;
  }

  .task-entry form {
    gap: 7px;
    margin-bottom: 14px;
  }

  .task-entry {
    margin-bottom: 14px;
  }

  .task-entry form > button {
    border-radius: 999px;
    min-height: 40px;
  }

  .board {
    gap: 10px;
  }

  .column {
    min-height: 0;
  }

  .column-header h2 {
    font-size: 0.9rem;
    padding: 5px 9px;
  }

  .column-header button {
    font-size: 0.74rem;
    padding: 4px 6px;
  }

  .task-list {
    gap: 7px;
    margin-top: 8px;
    min-height: 48px;
  }

  .task {
    border-radius: 10px;
    gap: 6px;
    grid-template-columns: 1fr auto;
    min-height: 44px;
    padding: 8px;
  }

  .task label {
    gap: 10px;
    grid-template-columns: 20px 1fr;
  }

  .task-check {
    height: 18px;
    width: 18px;
  }

  .task-title {
    font-size: 0.86rem;
  }

  .task-project {
    font-size: 0.62rem;
    padding: 3px 6px;
  }

  .tag-icon {
    height: 0.7rem;
    width: 0.7rem;
  }

  .settings-row {
    grid-template-columns: 1fr;
  }

  .archive-items li {
    grid-template-columns: 1fr;
  }

  .archive-meta {
    white-space: normal;
  }

  .next-up-task,
  .waiting-task,
  .edit-task {
    font-size: 0.68rem;
    height: 26px;
    padding: 0;
    width: 26px;
  }

  .task-timer {
    font-size: 0.66rem;
    min-width: 3.5em;
  }

  .next-up-task {
    padding: 0;
    width: 26px;
  }

  .delete-task {
    height: 26px;
    width: 26px;
  }

  .waiting-task svg,
  .edit-task svg,
  .delete-task svg {
    height: 14px;
    width: 14px;
  }

  .empty {
    font-size: 0.86rem;
    padding: 12px;
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: clamp(1.6rem, 8vw, 1.95rem);
  }

  .top-actions {
    gap: 4px;
  }

  .summary span + span::before {
    margin-right: 4px;
  }

  .focus-panel,
  .column {
    padding: 8px;
  }

  .task {
    grid-template-columns: 1fr auto;
    padding: 7px;
  }
}

/* The 3-dot task menu button is touch-only. Desktop keeps the
   hover-revealed inline action buttons (faster on mouse). */
.task-menu {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: none;
  height: 40px;
  justify-content: center;
  padding: 0;
  width: 40px;
}

.task-menu svg {
  fill: currentColor;
  height: 22px;
  width: 22px;
}

.task-menu:hover {
  background: rgba(28, 37, 34, 0.08);
  color: var(--text);
}

body[data-theme="dark"] .task-menu:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Narrow viewports (phones, narrow windows, DevTools mobile emulators)
   swap the inline action icons for a single 3-dot menu that opens the
   bottom sheet. This is viewport-based (not hover-based) because DevTools
   emulators don't always toggle (hover: none). */
@media (max-width: 740px) {
  .task .next-up-task,
  .task .waiting-task,
  .task .edit-task,
  .task .delete-task {
    display: none;
  }
  .task-menu {
    display: inline-grid;
    opacity: 1;
    pointer-events: auto;
  }
}

/* Touch-target sizing: applied on narrow viewports (phones / mobile
   emulators) and on coarse pointers. Keeps DevTools previews matching
   the real phone UI. */
@media (max-width: 740px), (pointer: coarse) {
  .top-icon-button {
    height: 44px;
    min-height: 44px;
    width: 44px;
  }

  .top-icon-button svg {
    height: 22px;
    width: 22px;
  }

  .scope-button {
    min-height: 36px;
  }

  .task-menu {
    height: 44px;
    width: 44px;
  }

  /* Bigger checkbox for fingers, with column wide enough to fit it. */
  .task label {
    gap: 12px;
    grid-template-columns: 22px 1fr;
  }

  .task-check {
    height: 20px;
    margin-top: 0;
    width: 20px;
  }

  .add-task-toggle,
  .task-entry form > button {
    min-height: 44px;
  }
}

/* ----- Mobile bottom-sheet for task actions ----- */

.action-sheet {
  background: transparent;
  border: 0;
  inset: auto 0 0 0;
  margin: 0 auto;
  max-height: 100vh;
  max-width: min(560px, 100vw);
  padding: 0;
  width: 100%;
}

.action-sheet::backdrop {
  background: rgba(15, 15, 15, 0.42);
}

/* Desktop: the top-actions menu becomes a dropdown anchored to its button. */
@media (min-width: 741px) {
  #topActionsSheet {
    inset: auto;
    margin: 0;
    max-width: 240px;
    position: fixed;
    right: var(--top-actions-right, 20px);
    top: var(--top-actions-top, 64px);
    width: auto;
  }

  #topActionsSheet::backdrop {
    background: transparent;
  }

  #topActionsSheet .action-sheet-panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    gap: 2px;
    min-width: 200px;
    padding: 6px;
  }

  body[data-theme="dark"] #topActionsSheet .action-sheet-panel {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  }

  #topActionsSheet .action-sheet-handle,
  #topActionsSheet .action-sheet-title,
  #topActionsSheet .action-sheet-cancel {
    display: none;
  }

  #topActionsSheet .action-sheet-group {
    background: transparent;
    border-radius: 10px;
    padding: 0;
  }

  #topActionsSheet .action-sheet-item {
    border-radius: 8px;
    font-size: 0.9rem;
    gap: 10px;
    grid-template-columns: 22px 1fr;
    min-height: 38px;
    padding: 0 10px;
  }

  #topActionsSheet .action-sheet-item:hover {
    background: var(--glass);
  }

  body[data-theme="dark"] #topActionsSheet .action-sheet-item:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  #topActionsSheet .action-sheet-icon {
    height: 22px;
    width: 22px;
  }

  #topActionsSheet .action-sheet-icon svg {
    height: 18px;
    width: 18px;
  }
}

.action-sheet-panel {
  background: var(--glass-strong);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(15, 15, 15, 0.18);
  display: grid;
  gap: 6px;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
}

body[data-theme="dark"] .action-sheet-panel {
  background: #1b2430;
}

.action-sheet-handle {
  background: var(--line-dark);
  border-radius: 999px;
  height: 4px;
  justify-self: center;
  margin: 6px 0 4px;
  width: 36px;
}

.action-sheet-title {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0 0 4px;
  overflow: hidden;
  padding: 0 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-sheet-group {
  background: var(--glass);
  border-radius: 12px;
  display: grid;
  gap: 1px;
  overflow: hidden;
}

body[data-theme="dark"] .action-sheet-group {
  background: #151a20;
}

.action-sheet-group-destructive {
  margin-top: 6px;
}

.action-sheet-item {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: grid;
  font-size: 0.98rem;
  gap: 14px;
  grid-template-columns: 28px 1fr;
  min-height: 52px;
  padding: 0 16px;
  text-align: left;
  width: 100%;
}

.action-sheet-item:active {
  background: rgba(0, 0, 0, 0.06);
}

body[data-theme="dark"] .action-sheet-item:active {
  background: rgba(255, 255, 255, 0.06);
}

.action-sheet-icon {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.action-sheet-icon svg {
  height: 22px;
  width: 22px;
}

.action-sheet-item.is-active .action-sheet-icon {
  color: var(--accent);
}

.action-sheet-item-destructive {
  color: #c2453a;
}

body[data-theme="dark"] .action-sheet-item-destructive {
  color: #f3a39c;
}

.action-sheet-item-destructive .action-sheet-icon {
  color: inherit;
}

.action-sheet-cancel {
  background: var(--glass);
  border: 0;
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  margin-top: 8px;
  min-height: 52px;
  width: 100%;
}

body[data-theme="dark"] .action-sheet-cancel {
  background: #151a20;
}
