:root {
  --ink: #152029;
  --muted: #5a6b78;
  --paper: rgba(255, 252, 247, 0.92);
  --card: #fffdf9;
  --line: rgba(21, 32, 41, 0.12);
  --accent: #c45c26;
  --accent-deep: #9a3f12;
  --teal: #1f6f6a;
  --list: rgba(255, 255, 255, 0.55);
  --shadow: 0 18px 50px rgba(21, 32, 41, 0.14);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: #d7e3e1;
  min-height: 100%;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(196, 92, 38, 0.28), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(31, 111, 106, 0.35), transparent 50%),
    linear-gradient(160deg, #cfdcd8 0%, #e8ebe4 40%, #b9cdc8 100%);
}
.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.hidden { display: none !important; }

/* Login */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.gate-panel {
  width: min(440px, 100%);
  padding: 2.4rem 2rem 2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.55s ease both;
}
.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 600;
}
.brand {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--display);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.lede {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.45;
}
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
input[type="password"],
input[type="text"],
.board-title,
#card-title,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
button, .file-btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
button:hover, .file-btn:hover { background: var(--accent-deep); }
#login-form button { width: 100%; margin-top: 0.85rem; }
.error { color: #b42318; margin-top: 0.75rem; font-size: 0.9rem; }

/* App shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  background: rgba(215, 227, 225, 0.72);
  border-bottom: 1px solid var(--line);
  animation: fade 0.4s ease both;
}
.top-brand { display: flex; align-items: center; gap: 0.85rem; min-width: 0; flex: 1; }
.mark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  white-space: nowrap;
}
.board-title {
  max-width: 320px;
  background: transparent;
  border-color: transparent;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.4rem 0.55rem;
}
.board-title:hover, .board-title:focus {
  background: rgba(255,255,255,0.7);
  border-color: var(--line);
  outline: none;
}
.top-actions { display: flex; gap: 0.45rem; }
.ghost {
  background: rgba(255,255,255,0.55);
  color: var(--ink);
  border: 1px solid var(--line);
}
.ghost:hover { background: #fff; }

.board {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  overflow-x: auto;
  align-items: flex-start;
  flex: 1;
  scroll-snap-type: x proximity;
}

.list {
  width: min(300px, 82vw);
  flex: 0 0 auto;
  background: var(--list);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  backdrop-filter: blur(8px);
  scroll-snap-align: start;
  animation: rise 0.45s ease both;
}
.list-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.list-title {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}
.list-title:focus { background: #fff; border-color: var(--line); outline: none; }
.list-del {
  background: transparent;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
}
.list-del:hover { background: rgba(180,35,24,0.1); color: #b42318; }
.cards {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 24px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: grab;
  box-shadow: 0 6px 18px rgba(21,32,41,0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(21,32,41,0.12);
}
.card.dragging { opacity: 0.45; cursor: grabbing; }
.card-cover {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: #dfe8e6;
}
.card-body { padding: 0.7rem 0.75rem 0.8rem; }
.card-labels { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.35rem; }
.chip {
  height: 8px;
  width: 36px;
  border-radius: 999px;
  display: inline-block;
}
.chip.teal { background: #1f6f6a; }
.chip.copper { background: #c45c26; }
.chip.ink { background: #152029; }
.chip.moss { background: #5d7a3a; }
.chip.sky { background: #3d7ea6; }
.card-title { margin: 0; font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
.add-card {
  width: 100%;
  margin-top: 0.65rem;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.add-card:hover { background: rgba(255,255,255,0.65); color: var(--ink); }

.add-list-col {
  width: min(280px, 80vw);
  flex: 0 0 auto;
}

/* Modal */
.modal {
  border: none;
  border-radius: 22px;
  padding: 0;
  width: min(560px, calc(100vw - 1.5rem));
  background: transparent;
  box-shadow: none;
}
.modal::backdrop {
  background: rgba(21, 32, 41, 0.45);
  backdrop-filter: blur(4px);
}
.modal-inner {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
#card-title {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  border-color: transparent;
  background: transparent;
  padding-left: 0;
}
#card-title:focus { background: #fff; border-color: var(--line); }
.icon-close {
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.55rem;
}
.modal-cover { margin-bottom: 0.85rem; border-radius: 14px; overflow: hidden; }
.modal-cover img { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.mini {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.labels-row { margin: 0.85rem 0; }
.label-picks { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.label-picks button {
  width: 42px;
  height: 18px;
  border-radius: 999px;
  padding: 0;
  opacity: 0.45;
  border: 2px solid transparent;
}
.label-picks button.on { opacity: 1; border-color: var(--ink); }
.images-block { margin-top: 0.5rem; }
.images-head { display: flex; justify-content: space-between; align-items: center; }
.file-btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  background: rgba(31,111,106,0.12);
  color: var(--teal);
}
.file-btn:hover { background: rgba(31,111,106,0.22); }
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.image-grid figure {
  margin: 0;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 1;
}
.image-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-grid .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(21,32,41,0.7);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
}
.modal-foot {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.primary { background: var(--teal); }
.primary:hover { background: #165652; }
.danger {
  background: transparent;
  color: #b42318;
  border: 1px solid rgba(180,35,24,0.35);
  margin-left: auto;
}
.danger:hover { background: rgba(180,35,24,0.08); }

/* Compose (add card / list) */
.compose-inner { animation: rise 0.28s ease both; }
.compose-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 700;
}
.compose-heading {
  margin: 0.35rem 0 0.25rem;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.compose-sub {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.compose-extra { margin-top: 0.85rem; }
.compose-extra .opt { font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.compose-foot { margin-top: 1.15rem; }
.compose-foot .primary { min-width: 7.5rem; }
.compose-foot .ghost { background: rgba(255,255,255,0.7); }

/* Inline add composer inside a list */
.composer {
  margin-top: 0.55rem;
  padding: 0.65rem;
  background: rgba(255, 253, 249, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(21, 32, 41, 0.1);
  animation: rise 0.2s ease both;
}
.composer textarea {
  width: 100%;
  min-height: 72px;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0.65rem 0.7rem;
  font: inherit;
  resize: vertical;
  background: #fff;
}
.composer textarea:focus {
  outline: 2px solid rgba(31, 111, 106, 0.35);
  border-color: var(--teal);
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.composer-actions .primary {
  background: var(--teal);
  padding: 0.55rem 0.95rem;
  font-size: 0.9rem;
}
.composer-actions .primary:hover { background: #165652; }
.composer-actions .ghost {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 640px) {
  .mark { display: none; }
  .topbar { padding: 0.75rem; }
  .board { padding: 0.85rem; }
}
