:root,
[data-theme="white"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #111111;
  --muted: #6b7280;
  --line: #eceef2;
  --accent: #111111;
  --accent-soft: #f3f4f6;
  --danger: #dc2626;
  --ok: #16a34a;
  --save: #0d9488;
  --save-bg: #ccfbf1;
  --cancel: #e11d48;
  --cancel-bg: #ffe4e6;
  --shadow: 0 12px 40px rgba(17, 17, 17, 0.06);
  --hover: #fafafa;
  --current: #f4f5f7;
  --current-hover: #eceef2;
  --badge: #eceef2;
  --badge-on: #111111;
  --badge-on-fg: #ffffff;
  --num: #e6e8ec;
  --num-fg: #6b7280;
  --overlay: rgba(17, 17, 17, 0.4);
  --new: #0d9488;
  --new-hover: #0f766e;
  --new-fg: #ffffff;
}

[data-theme="black"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0d0d0d;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --line: #222222;
  --accent: #f5f5f5;
  --accent-soft: #1a1a1a;
  --danger: #f87171;
  --ok: #4ade80;
  --save: #2dd4bf;
  --save-bg: #134e4a;
  --cancel: #fb7185;
  --cancel-bg: #4c0519;
  --shadow: none;
  --hover: #141414;
  --current: #223344;
  --current-hover: #2c4258;
  --badge: #262626;
  --badge-on: #f5f5f5;
  --badge-on-fg: #111111;
  --num: #2a2a2a;
  --num-fg: #a3a3a3;
  --overlay: rgba(0, 0, 0, 0.65);
  --new: #2dd4bf;
  --new-hover: #5eead4;
  --new-fg: #042f2e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

#app {
  min-height: 100dvh;
}

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

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--surface);
  display: grid;
  place-items: center;
}

.login h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.login p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.google-btn:hover {
  background: var(--hover);
}

.hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.shell {
  width: min(640px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

.new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--new);
  color: var(--new-fg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.new-plus {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.new-btn:hover {
  background: var(--new-hover);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 2px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.tab {
  display: inline-flex;
  align-items: center;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="black"] .tab.active {
  background: #2a2a2a;
  box-shadow: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--badge);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tab.active .badge {
  background: var(--badge-on);
  color: var(--badge-on-fg);
}

.toolbar-spacer {
  flex: 1;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 999px;
}

.icon-btn:hover {
  background: var(--accent-soft);
}

.list {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 24px;
}

.list.reorderable .task {
  touch-action: none;
}

.task {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}

.list.reorderable .task {
  cursor: grab;
}

.list.reorderable .task:active {
  cursor: grabbing;
}

.task:hover {
  background: var(--hover);
}

.task.current {
  background: var(--current);
}

.task.current:hover {
  background: var(--current-hover);
}

.task:focus {
  outline: none;
}

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

.task-num {
  width: 28px;
  height: 28px;
  margin: 6px 0;
  border-radius: 50%;
  background: var(--num);
  color: var(--num-fg);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: grid;
  place-items: center;
  line-height: 1;
  pointer-events: none;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.task.done .task-num {
  opacity: 0.72;
}

.task-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.title-display {
  border: 0;
  background: transparent;
  width: 100%;
  padding: 10px 4px;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.meta {
  margin: -4px 4px 2px;
  color: var(--muted);
  font-size: 12px;
}

.task.done {
  padding: 4px 16px 4px 6px;
}

.task.done .task-num {
  margin: 4px 0;
}

.task.done .title-display {
  padding: 4px 4px 0;
}

.task.done .meta {
  margin: 0 4px 2px;
}

.done-split {
  height: 1px;
  margin: 6px 20px;
  background: var(--line);
}

.task-leaving {
  pointer-events: none;
  overflow: hidden;
  max-height: var(--task-h);
  will-change: transform, opacity, max-height;
}

.task-leaving.leave-right {
  animation: task-leave-right 0.96s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.task-leaving.leave-left {
  animation: task-leave-left 0.96s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.task-leaving.leave-right .task-num {
  transform: scale(1.08);
}

.task-leaving.leave-left .task-num {
  transform: scale(0.92);
}

@keyframes task-leave-right {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
    max-height: var(--task-h);
  }
  58% {
    transform: translateX(112%) rotate(5deg);
    opacity: 0;
    max-height: var(--task-h);
  }
  100% {
    transform: translateX(112%) rotate(5deg);
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-width: 0;
  }
}

@keyframes task-leave-left {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
    max-height: var(--task-h);
  }
  58% {
    transform: translateX(-112%) rotate(-5deg);
    opacity: 0;
    max-height: var(--task-h);
  }
  100% {
    transform: translateX(-112%) rotate(-5deg);
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-leaving.leave-right,
  .task-leaving.leave-left {
    animation: none;
  }
}

.task-cancel,
.task-save {
  grid-column: 3;
  grid-row: 1;
  width: 36px;
  height: 36px;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 999px;
}

.task-cancel {
  grid-column: 1;
  background: var(--cancel);
  color: white;
}

.task-save {
  background: var(--save);
  color: white;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
}

.composer-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 6px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--hover);
  border-radius: 0;
}

.composer-row input {
  flex: 1;
  border: 0;
  background: transparent;
  width: 100%;
  padding: 10px 4px;
  color: inherit;
}

.composer-row input:focus {
  outline: none;
  background: var(--accent-soft);
  border-radius: 8px;
  padding-left: 8px;
}

.composer-row .task-cancel {
  grid-column: 1;
}

.composer-row .task-save {
  grid-column: 3;
}

.sortable-ghost {
  opacity: 0.5;
}

.sortable-fallback {
  opacity: 0.95;
  cursor: grabbing;
}

@media (max-width: 700px) {
  .shell {
    box-shadow: none;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(6px);
}

.confirm-overlay {
  z-index: 70;
}

.task-dialog-overlay {
  padding: 20px;
  animation: overlay-in 0.16s ease;
}

@keyframes overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .task-dialog-overlay {
    animation: none;
  }
}

.modal {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 24px 16px;
  box-shadow: var(--shadow);
}

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

.modal p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

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

.modal-cancel,
.modal-confirm {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.modal-cancel {
  background: transparent;
  color: var(--muted);
}

.modal-cancel:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.modal-confirm {
  background: var(--danger);
  color: white;
}

.task-dialog {
  width: min(640px, 100%);
  max-width: 640px;
  max-height: min(640px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
  border-radius: 20px;
}

.task-dialog:focus {
  outline: none;
}

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

.task-dialog-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.task-dialog-created {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-dialog-top .task-num {
  margin: 0;
  width: 32px;
  height: 32px;
  font-size: 13px;
  flex: 0 0 auto;
  opacity: 1;
}

.task-dialog-x {
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: var(--num);
  color: var(--num-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.task-dialog-x:hover {
  filter: brightness(0.96);
}

.task-dialog-text,
.task-dialog-editor {
  display: block;
  width: 100%;
  min-height: 96px;
  max-height: min(360px, 46dvh);
  margin: 0;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 16px 18px;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-y: auto;
}

.task-dialog-text {
  background: var(--accent-soft);
  cursor: pointer;
}

.task-dialog-text:hover {
  background: var(--current);
}

.task-dialog-text:focus-visible {
  outline: 2px solid var(--save);
  outline-offset: 2px;
}

.task-dialog-editor {
  background: var(--surface);
  border-color: var(--save);
  resize: none;
  cursor: text;
  user-select: text;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--save) 22%, transparent);
}

.task-dialog-editor:focus {
  outline: none;
}

.task-dialog-editor::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.task-dialog-meta {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.task-dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.task-dialog-actions.view {
  justify-content: space-between;
}

.task-dialog-actions.edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.task-dlg-btn.delete.icon-only {
  width: 44px;
  flex: 0 0 44px;
  padding: 0;
  display: grid;
  place-items: center;
}

.task-dlg-btn.done {
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 14px 0 10px;
  font-weight: 700;
  white-space: nowrap;
}

.task-dlg-btn.done:not(:has(svg)) {
  padding-left: 14px;
}

.task-dlg-btn.done svg {
  width: 18.4px;
  height: 18.4px;
  display: block;
  flex-shrink: 0;
  overflow: visible;
  stroke-width: 3.2;
}

.task-dlg-btn {
  height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.task-dlg-btn:focus-visible {
  outline: 2px solid var(--save);
  outline-offset: 2px;
}

.task-dlg-btn.close {
  background: var(--accent-soft);
  color: var(--text);
}

.task-dlg-btn.close:hover {
  background: var(--current);
}

.task-dlg-btn.delete,
.task-dlg-btn.discard {
  background: var(--cancel-bg);
  color: var(--cancel);
}

[data-theme="black"] .task-dlg-btn.delete {
  color: #ffffff;
}

.task-dlg-btn.delete:hover,
.task-dlg-btn.discard:hover {
  filter: brightness(0.97);
}

.task-dlg-btn.done,
.task-dlg-btn.save {
  background: var(--new);
  color: var(--new-fg);
}

.task-dlg-btn.done:hover,
.task-dlg-btn.save:hover {
  background: var(--new-hover);
}

.task-dlg-btn.save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.task-dlg-btn.save:disabled:hover {
  background: var(--new);
}

@media (max-width: 380px) {
  .task-dlg-btn {
    font-size: 13px;
    padding: 0 8px;
  }
}

.settings-modal {
  width: min(420px, 100%);
}

.settings-section {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.theme-pick {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}

.theme-pick.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.theme-swatch {
  height: 44px;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
}

.theme-swatch.white {
  background: linear-gradient(135deg, #fff 50%, #f3f4f6 50%);
}

.theme-swatch.black {
  background: linear-gradient(135deg, #111 50%, #000 50%);
}

.theme-pick b {
  display: block;
  font-size: 14px;
}

.logout-row {
  width: 100%;
  margin-top: 20px;
  height: 44px;
  border: 1px solid var(--danger);
  background: transparent;
  color: var(--danger);
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.logout-row:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
