:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --teal: #0f766e;
  --teal-soft: #dff5f3;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d1d5db;
  --done: #64748b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #e5fffb, var(--bg) 40%);
}

.hero {
  padding: 1.5rem 1rem 1rem;
  text-align: center;
}

.hero h1 {
  margin: 0;
}

.hero p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

#sync-status {
  display: inline-block;
  margin-top: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

#sync-status[data-state="ok"] {
  color: #065f46;
  background: #d1fae5;
}

#sync-status[data-state="warn"] {
  color: #92400e;
  background: #fef3c7;
}

#sync-status[data-state="sync"] {
  color: #1e3a8a;
  background: #dbeafe;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(15, 118, 110, 0.08);
}

.form-card {
  padding: 1rem;
  margin-bottom: 1rem;
}

#new-item-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

.print-button {
  background: #0b5d57;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 1rem;
}

#new-item-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

button {
  padding: 0.6rem 0.9rem;
  border: none;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.8rem;
}

.column {
  padding: 0.75rem;
}

.column h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 180px;
  display: grid;
  gap: 0.45rem;
}

.items.drag-over {
  background: var(--teal-soft);
  border-radius: 10px;
}

.items.drop-target {
  background: var(--teal-soft);
  border-radius: 10px;
  outline: 2px dashed #0f766e;
}

.item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0.45rem 0.5rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.item.dragging-active {
  opacity: 0.9;
  background: #dcfce7;
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.35);
}

.item.drag-source-hidden {
  opacity: 0.2;
}

.touch-ghost {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  width: min(86vw, 420px);
  z-index: 9999;
  pointer-events: none;
  opacity: 0.95;
  background: #dcfce7;
  border-color: #16a34a;
  box-shadow: 0 10px 28px rgba(22, 163, 74, 0.35);
  transform: translate(-9999px, -9999px);
}

.item label {
  display: flex;
  gap: 0.5rem;
  align-items: start;
}

.item.done .item-text {
  text-decoration: line-through;
  color: #166534;
}

.item.done {
  background: #dcfce7;
  border-color: #22c55e;
}

@media (max-width: 720px) {
  #new-item-form {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .print-button {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .hero {
    padding: 0 0 0.5rem;
  }

  #sync-status,
  .form-card,
  .top-actions,
  .item-check,
  .item-delete {
    display: none !important;
  }

  main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .board {
    display: block;
  }

  .column {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #cbd5e1;
    box-shadow: none;
    margin: 0 0 0.6rem;
  }

  .column h3 {
    margin: 0 0 0.4rem;
    color: #000;
  }

  .items {
    min-height: 0;
    gap: 0.25rem;
  }

  .item,
  .item.done {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #000;
    box-shadow: none;
  }

  .item.done .item-text {
    color: #000;
    text-decoration: line-through;
  }
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.item-delete {
  background: transparent;
  color: #dc2626;
  border: none;
  border-radius: 999px;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  line-height: 1;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.item-delete:hover {
  background: rgba(220, 38, 38, 0.12);
}
