:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #1d1f1a;
  --muted: #5a5f52;
  --accent: #33533f;
  --accent-bright: #2f6b4a;
  --card: #ffffff;
  --shadow: 0 18px 40px rgba(28, 32, 24, 0.12);
  --radius: 22px;
  --radius-sm: 16px;
  --gap: 16px;
  --font: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  --mono: "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top, #fef9f0, var(--bg));
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.drag-lock {
  overflow: hidden;
  touch-action: none;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  opacity: 0.4;
  z-index: 0;
}

.orb-1 {
  width: 280px;
  height: 280px;
  background: #e6f0dd;
  top: -40px;
  left: -60px;
}

.orb-2 {
  width: 220px;
  height: 220px;
  background: #f3e4d0;
  bottom: 40px;
  right: -20px;
}

.orb-3 {
  width: 160px;
  height: 160px;
  background: #d9e6f2;
  top: 55%;
  left: 70%;
}

.app {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 28px;
  box-shadow: 0 10px 24px rgba(28, 32, 24, 0.12);
  padding: 24px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: liftIn 600ms ease;
}

@keyframes liftIn {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.title-block h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

.date {
  color: var(--muted);
  font-size: 0.95rem;
}

.pill {
  background: #f0f1ed;
  border: 1px solid #e0e3dc;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn.add-inline {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 12px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 0;
}

.mode-tab {
  border: 1px solid #e3e0d7;
  background: #f8f6f1;
  color: var(--ink);
  padding: 12px 10px;
  border-radius: 16px;
  font-size: 1rem;
  font-family: var(--font);
  cursor: pointer;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(47, 58, 36, 0.2);
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #f6f4ef;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 10px 0;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(36, 40, 32, 0.1);
}

.tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bottom-controls {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 240px;
}

.list-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.list-separator::before,
.list-separator::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #e5e0d6;
}

.card {
  border-radius: var(--radius);
  background: #faf9f6;
  border: 1px solid #ece9e1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-user-select: none;
  user-select: none;
}

.card.draggable {
  touch-action: pan-y;
}

.card.dragging {
  position: absolute;
  z-index: 30;
  opacity: 0.95;
  box-shadow: 0 18px 28px rgba(36, 40, 32, 0.2);
  pointer-events: none;
}

.card.placeholder {
  border: 2px dashed #d5d0c5;
  background: transparent;
}

.card.done {
  background: #f5f2ea;
  border-color: #e7e2d7;
}

.card-enter {
  animation: staggerIn 420ms ease;
}

@keyframes staggerIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.edit-input {
  width: 100%;
  border: 1px solid #d8d4c9;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 1rem;
  font-family: var(--font);
  background: #fff;
}

.card input {
  -webkit-user-select: text;
  user-select: text;
}

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

.badge {
  background: #eaf0e6;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
}

.status {
  font-size: 1rem;
  font-weight: 600;
}

.status.claimed {
  color: var(--accent);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 1px solid #e2ded5;
  background: #fff;
  color: var(--accent);
  border-radius: 14px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(36, 40, 32, 0.08);
}

.icon-btn.circle-outline {
  border-radius: 999px;
  border: 2px solid #c9c4b8;
  background: transparent;
  color: transparent;
  box-shadow: none;
}

.icon-btn.undo-check {
  border-radius: 999px;
  background: #2f7d32;
  color: #fff;
  border-color: #2f7d32;
  box-shadow: none;
}

.icon-btn.delete {
  border-color: #f2c7c7;
  color: #c94b4b;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  box-shadow: none;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 1.05rem;
  cursor: pointer;
  font-family: var(--font);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: #f2f2ee;
  color: var(--ink);
}

.btn.small {
  padding: 10px 14px;
  font-size: 0.95rem;
}

.footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.empty-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f241b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
}

.toast.clickable {
  cursor: pointer;
  pointer-events: auto;
}

.diagnostic {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #402222;
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  max-width: min(520px, 92vw);
  z-index: 11;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.debug {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 92vw);
  max-height: 35vh;
  overflow: auto;
  background: #111;
  color: #e8e8e8;
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 12;
  opacity: 0.9;
  pointer-events: none;
}

.debug-line {
  margin-bottom: 6px;
  word-break: break-word;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 15, 10, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 18px;
}

.modal#addModal {
  align-items: flex-start;
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
}

.modal#addModal .modal-card {
  margin-top: 0;
  max-height: min(86vh, 720px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 100%);
  background: #fffdf7;
  border-radius: 26px;
  padding: 22px;
  box-shadow: 0 10px 24px rgba(28, 32, 24, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: min(90vh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

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

.modal-kicker {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
}

.choice-grid {
  display: grid;
  gap: 12px;
}

.choice {
  border: 2px solid #e7e3d8;
  border-radius: 20px;
  background: #fff;
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.inline-toast {
  min-height: 1.1rem;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--accent);
}

.inline-toast.error {
  color: #c94b4b;
}

.inline-toast:empty {
  display: none;
}

.choice.active {
  border-color: var(--accent);
  box-shadow: 0 12px 24px rgba(51, 83, 63, 0.14);
}

.choice-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.choice-sub {
  color: var(--muted);
  font-size: 0.95rem;
}

.icon-btn {
  border: none;
  background: #f2f2ee;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}

input {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #e1e2da;
  font-size: 1rem;
  font-family: var(--font);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.seg {
  border: 1px solid #e3e2d7;
  border-radius: 999px;
  padding: 10px 0;
  background: #f4f3ee;
  cursor: pointer;
  font-size: 1rem;
}

.seg.active {
  background: var(--accent);
  color: #fff;
}

.pill-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.link {
  border: none;
  background: transparent;
  color: var(--accent);
  text-align: left;
  padding: 0;
  font-size: 0.98rem;
  cursor: pointer;
}

.pill-option {
  border: 1px solid #e3e2d7;
  border-radius: 999px;
  padding: 10px 0;
  background: #f4f3ee;
  cursor: pointer;
  font-size: 0.95rem;
}

.pill-option.active {
  background: var(--accent);
  color: #fff;
}

.help-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-title {
  font-weight: 600;
  font-size: 1rem;
}

.code-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.code {
  font-family: var(--mono);
  background: #f1eee6;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.code.link {
  letter-spacing: 0;
  word-break: break-all;
}

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

.toggle {
  width: 56px;
  height: 32px;
  background: #e1e4db;
  border-radius: 999px;
  border: none;
  position: relative;
  cursor: pointer;
}

.toggle::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 999px;
  top: 4px;
  left: 4px;
  transition: transform 180ms ease;
}

.toggle[aria-pressed="true"] {
  background: var(--accent);
}

.toggle[aria-pressed="true"]::after {
  transform: translateX(24px);
}

.confirm-body {
  color: var(--muted);
  font-size: 1rem;
}

@media (max-width: 520px) {
  body {
    padding: 12px;
  }

  .app {
    padding: 18px;
  }

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
