:root {
  color-scheme: light;
  --bg: #f4f6f0;
  --panel: #ffffff;
  --panel-2: #f8faf5;
  --panel-3: #eef4e9;
  --line: #d9e0d2;
  --text: #1b241c;
  --muted: #687565;
  --blue: #0f766e;
  --blue-2: #0b5f59;
  --green: #2f855a;
  --amber: #b7791f;
  --red: #c2413d;
  --shadow: 0 18px 46px rgba(29, 42, 28, 0.13);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(15, 118, 110, 0.26);
  --sidebar-width: 292px;
  font-family: "HK Grotesk", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: "HK Grotesk";
  src: url("../webfonts/hkgrotesk-regular-webfont.woff2") format("woff2");
  font-weight: 400;
}

@font-face {
  font-family: "HK Grotesk";
  src: url("../webfonts/hkgrotesk-semibold-webfont.woff2") format("woff2");
  font-weight: 700;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10150f;
  --panel: #171d17;
  --panel-2: #20281f;
  --panel-3: #243124;
  --line: #344035;
  --text: #f2f7ee;
  --muted: #a8b5a3;
  --blue: #0f766e;
  --blue-2: #5eead4;
  --green: #86c06a;
  --amber: #eab54f;
  --red: #fb7185;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 10px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 0;
}

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

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
}

.brand-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--blue-2);
}

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

.side-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0 8px;
}

.side-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 2px;
}

.list-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.list-line .icon-button {
  width: 32px;
  min-height: 32px;
}

.lists-section {
  min-height: 0;
  overflow: hidden;
}

.list-scroll {
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  display: grid;
  align-content: start;
  gap: 4px;
  padding-right: 2px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.72;
}

.sidebar-actions {
  display: grid;
  gap: 10px;
}

.sidebar-actions .primary-button,
.sidebar-actions .ghost-button {
  width: 100%;
}

.nav-button,
.list-button {
  min-height: 42px;
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 8px;
  text-align: left;
}

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

.nav-button:hover,
.list-button:hover,
.nav-button.active,
.list-button.active {
  background: var(--panel-3);
}

.nav-button.active,
.list-button.active {
  color: var(--blue-2);
  font-weight: 800;
}

.count-pill {
  min-width: 26px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.topbar-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topbar-title p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px;
  align-items: end;
  gap: 12px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, var(--panel));
}

.workspace {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 18px clamp(16px, 3vw, 32px) 116px;
}

.content-width {
  max-width: 1160px;
  margin: 0 auto;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 82%, var(--panel));
  opacity: 1;
}

.input[type="date"],
.input[type="datetime-local"],
.input[type="number"] {
  min-width: 0;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in srgb, var(--blue) 32%, var(--line));
}

.input.invalid,
.select.invalid,
.textarea.invalid {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 7%, var(--panel));
}

.search-field {
  position: relative;
}

.search-field > .icon {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search-field .input {
  padding-left: 40px;
  padding-right: 44px;
}

.search-clear {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 32px;
  min-height: 32px;
  height: 32px;
  color: var(--muted);
}

.search-clear .icon {
  width: 16px;
  height: 16px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label,
.field > span:first-child,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-error,
.field-hint {
  font-size: 12px;
  line-height: 1.35;
}

.field-error {
  color: var(--red);
  font-weight: 800;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.drawer-date-grid {
  grid-template-columns: minmax(0, 1fr);
}

.icon-button,
.primary-button,
.ghost-button,
.danger-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

.icon-button {
  width: 44px;
  padding: 0;
  position: relative;
}

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

.primary-button:hover {
  background: color-mix(in srgb, var(--blue) 88%, #000);
  border-color: color-mix(in srgb, var(--blue) 88%, #000);
}

.ghost-button:hover,
.icon-button:hover {
  background: var(--panel-2);
}

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

.danger-button:hover {
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

.icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

.badge .icon,
.bottom-nav .icon {
  width: 16px;
  height: 16px;
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--red);
}

.group {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 2px;
}

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

.task-row {
  min-height: 64px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.task-row:hover {
  background: color-mix(in srgb, var(--panel) 84%, var(--panel-3));
  border-color: color-mix(in srgb, var(--blue) 30%, var(--line));
}

.task-row.priority-high {
  border-left-color: var(--red);
}

.task-row.priority-medium {
  border-left-color: var(--amber);
}

.task-row.priority-low {
  border-left-color: var(--green);
}

.task-check {
  width: 24px;
  height: 24px;
  accent-color: var(--blue);
}

.task-main {
  min-width: 0;
  display: grid;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}

.task-main:hover .task-title {
  color: var(--blue-2);
}

.task-title {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.task-row.completed .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.task-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 2px 8px;
  background: var(--panel-2);
}

.badge.danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
}

.badge.soon {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 35%, var(--line));
}

.badge.scheduled {
  color: var(--blue-2);
}

.badge.running {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 34%, var(--line));
  background: color-mix(in srgb, var(--green) 8%, var(--panel));
}

.badge.paused {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 36%, var(--line));
  background: color-mix(in srgb, var(--amber) 8%, var(--panel));
}

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

.more-action {
  display: none;
}

.quick-capture {
  position: fixed;
  left: calc(var(--sidebar-width) + clamp(16px, 3vw, 32px));
  right: clamp(16px, 3vw, 32px);
  bottom: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  max-width: 1160px;
  margin: 0 auto;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.quick-submit {
  min-width: 74px;
}

.active-timer {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.active-timer.placed {
  left: var(--timer-x);
  top: var(--timer-y);
  right: auto;
  bottom: auto;
}

.active-timer.paused {
  border-color: color-mix(in srgb, var(--amber) 34%, var(--line));
}

.timer-title {
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 800;
}

.focus-overlay {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 30;
  width: min(420px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 44px 14px 14px;
  backdrop-filter: blur(14px);
}

.focus-overlay.placed {
  left: var(--timer-x);
  top: var(--timer-y);
  right: auto;
  bottom: auto;
}

.focus-overlay.overtime {
  border-color: color-mix(in srgb, var(--red) 38%, var(--line));
}

.focus-overlay.paused {
  border-color: color-mix(in srgb, var(--amber) 42%, var(--line));
}

.focus-overlay.dragging {
  user-select: none;
}

.focus-drag-handle {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
}

.focus-drag-handle:hover {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

.focus-drag-handle:active {
  cursor: grabbing;
}

.focus-ring {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.focus-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.focus-ring-track,
.focus-ring-meter {
  fill: none;
  stroke-width: 10;
}

.focus-ring-track {
  stroke: var(--panel-3);
}

.focus-ring-meter {
  stroke: var(--blue);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

.focus-overlay.overtime .focus-ring-meter {
  stroke: var(--red);
}

.focus-overlay.paused .focus-ring-meter {
  stroke: var(--amber);
}

.focus-clock {
  position: relative;
  z-index: 1;
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  color: var(--text);
}

.focus-caption {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.focus-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.focus-copy strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.focus-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.36);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(480px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.drawer-header,
.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.drawer-title {
  min-width: 0;
}

.drawer-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.drawer-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.drawer-body {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.sheet-section {
  display: grid;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}

.chip.active {
  border-color: var(--blue);
  color: var(--blue-2);
  font-weight: 800;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.toggle-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.toggle-row > .ghost-button,
.toggle-row > .switch {
  flex: 0 0 auto;
}

.switch {
  width: 48px;
  height: 28px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--muted);
  position: relative;
}

.switch::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.18s ease;
}

.switch:checked {
  background: var(--blue);
}

.switch:checked::before {
  transform: translateX(20px);
}

.empty-state,
.alert,
.toast,
.skeleton {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
}

.empty-state .icon {
  width: 32px;
  height: 32px;
  color: var(--blue-2);
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.empty-state span {
  max-width: 420px;
}

.alert {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 28%, var(--line));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.loading-strip {
  min-height: 38px;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--blue) 8%, var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, var(--blue) 22%, var(--line));
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.spinner.large {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.skeleton {
  min-height: 64px;
  overflow: hidden;
  position: relative;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--line) 45%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.notification-panel {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 70;
  width: min(380px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.mobile-menu-panel {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.42);
}

.modal {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-footer {
  justify-content: flex-end;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.choice-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.context-backdrop {
  position: fixed;
  inset: 0;
  z-index: 84;
  background: transparent;
}

.context-menu {
  position: fixed;
  z-index: 85;
  width: min(320px, calc(100vw - 24px));
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
}

.context-menu.top-left {
  top: 86px;
  left: max(12px, env(safe-area-inset-left));
}

.context-menu.top-right {
  top: 86px;
  right: max(12px, env(safe-area-inset-right));
}

.context-menu.bottom-left {
  left: max(12px, env(safe-area-inset-left));
  bottom: 92px;
}

.context-menu.bottom-right {
  right: max(12px, env(safe-area-inset-right));
  bottom: 92px;
}

.context-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 6px 8px;
  border-bottom: 1px solid var(--line);
}

.context-header strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.context-actions {
  display: grid;
  gap: 4px;
}

.context-actions button {
  min-height: 48px;
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.context-actions button:hover {
  background: var(--panel-2);
}

.context-actions button.danger {
  color: var(--red);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.38);
}

.busy-card {
  width: min(300px, 100%);
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.busy-card strong {
  font-size: 18px;
}

.busy-card span:last-child {
  color: var(--muted);
}

.notification-item {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.notification-item:last-child {
  border-bottom: 0;
}

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

.danger-text {
  color: var(--red);
}

.mobile-bar,
.bottom-nav {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-bar {
    min-height: 64px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }

  .mobile-bar h1 {
    margin: 0;
    font-size: 20px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .main {
    height: 100vh;
    height: 100dvh;
    grid-template-rows: auto auto 1fr auto;
  }

  .topbar {
    display: none;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(112px, 0.42fr);
    padding: 10px 12px;
  }

  .workspace {
    padding: 12px 12px 156px;
  }

  .quick-capture {
    left: 10px;
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr) 82px;
  }

  .quick-capture .ghost-button {
    display: none;
  }

  .quick-submit {
    min-width: 0;
    width: 100%;
  }

  .active-timer {
    left: 10px;
    right: 10px;
    bottom: calc(128px + env(safe-area-inset-bottom));
    justify-content: space-between;
  }

  .active-timer.placed {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(128px + env(safe-area-inset-bottom));
  }

  .focus-overlay {
    left: 10px;
    right: 10px;
    top: 82px;
    bottom: auto;
    width: auto;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 14px;
  }

  .focus-overlay.placed {
    left: 10px;
    right: 10px;
    top: 82px;
    bottom: auto;
  }

  .focus-drag-handle {
    display: none;
  }

  .focus-ring {
    width: 176px;
  }

  .focus-clock {
    font-size: 42px;
  }

  .focus-copy {
    justify-items: center;
    width: 100%;
  }

  .focus-copy strong {
    white-space: normal;
    text-align: center;
  }

  .focus-actions {
    justify-content: stretch;
    width: 100%;
  }

  .focus-actions .ghost-button,
  .focus-actions .danger-button {
    flex: 1 1 auto;
  }

  .bottom-nav {
    min-height: calc(64px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid var(--line);
  }

  .bottom-nav button {
    min-height: 52px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    display: grid;
    place-items: center;
    gap: 2px;
    font-size: 11px;
  }

  .bottom-nav button.active {
    color: var(--blue-2);
    background: var(--panel-2);
    font-weight: 800;
  }

  .task-row {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    min-height: 72px;
  }

  .task-actions .edit-action {
    display: none;
  }

  .task-actions .more-action {
    display: inline-flex;
  }

  .task-actions {
    gap: 6px;
  }

  .drawer {
    top: auto;
    bottom: 0;
    height: min(92vh, 760px);
    height: min(92dvh, 760px);
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
  }

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

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notification-panel {
    top: 68px;
    right: 12px;
  }

  .mobile-menu-panel {
    position: fixed;
    top: 68px;
    left: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 70;
    width: min(360px, calc(100vw - 24px));
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    display: grid;
    align-content: start;
    gap: 8px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .mobile-menu-panel .list-line {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .mobile-menu-panel .list-actions {
    opacity: 1;
  }

  .context-menu {
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    top: auto !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    width: auto;
  }

  .context-actions button {
    min-height: 52px;
  }

  .modal-footer,
  .drawer-footer {
    align-items: stretch;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .modal-footer button,
  .drawer-footer button {
    flex: 1 1 auto;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(144px + env(safe-area-inset-bottom));
    transform: none;
    justify-content: space-between;
  }
}

@media (max-width: 430px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .task-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 8px;
  }

  .task-actions {
    display: grid;
    gap: 6px;
  }

  .toast {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }
}

@media (hover: hover) and (pointer: fine) {
  .list-actions {
    opacity: 0.18;
    transition: opacity 0.16s ease;
  }

  .list-line:hover .list-actions,
  .list-line:focus-within .list-actions {
    opacity: 1;
  }
}
