:root {
  --bg: #6f7fe8;
  --bg-2: #7b88e2;
  --ink: #1f2a65;
  --muted: #7c84af;
  --card: #fff;
  --accent: #5e6de0;
  --danger: #e5485d;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: #fff;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { -webkit-appearance: none; appearance: none; }

.page-shell, .auth-shell { min-height: 100vh; }
.screen {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 12px calc(88px + var(--safe-bottom));
}

.auth-page { display: grid; place-items: center; padding: 24px; }
.login-card, .composer-card, .empty-card, .share-box {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 16px;
}
.login-card { max-width: 420px; }
.login-eyebrow, .crumb, .muted, .list-count, .hero p { color: rgba(255,255,255,.82); margin: 0; }
.login-card h1, .list-hero h1, .hero h1 {
  margin: 4px 0 6px;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: .95;
  font-weight: 800;
  letter-spacing: -.02em;
}
.login-copy { color: rgba(255,255,255,.92); margin: 0 0 20px; }
.google-btn, .primary-btn, .secondary-btn, .link-btn, .chip, .people-pill, .icon-btn {
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.google-btn, .primary-btn {
  background: #fff;
  color: #3240a8;
  font-weight: 700;
  width: 100%;
  padding: 14px 16px;
}
.secondary-btn, .link-btn, .icon-btn {
  background: rgba(255,255,255,.15);
  color: #fff;
  padding: 8px 12px;
}
.secondary-btn.danger { background: rgba(255, 96, 96, .18); }
.back-link {
  padding: 0;
  background: transparent;
  justify-content: flex-start;
  font-weight: 600;
  opacity: .92;
}
.google-mark {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #eef1ff;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  color: #4453c2;
}

.list-hero, .hero { padding: 2px 2px 6px; }
.list-hero-top, .hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
.hero-actions { display: flex; gap: 5px; align-items: center; }
.people-pill, .icon-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  background: rgba(255,255,255,.18);
  font-weight: 700;
}
.composer-card { display: grid; gap: 10px; margin: 10px 0 12px; }
.cards-stack { display: grid; gap: 8px; }

.list-card, .member-card {
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(42, 48, 101, .12);
}
.list-card { justify-content: space-between; }
.list-card strong { font-size: 1rem; }
.list-card .muted { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.pill {
  background: #eef1ff;
  color: #5563ca;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
}
.input, .store-select, .sheet-select {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap;
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  padding: 7px 11px;
  font-size: .85rem;
  font-weight: 600;
}
.chip.active { background: #fff; color: #4453c2; }

.item-list { display: grid; gap: 5px; }
.item-row {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.item-row.swipe-locked { touch-action: none; }
.item-swipe-bg {
  position: absolute;
  inset: 0;
  background: #2fbf71;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 18px;
  font-weight: 700;
  font-size: .9rem;
  opacity: 0;
}
.item-row.is-done .item-swipe-bg { background: #6b75c7; justify-content: flex-end; }
.item-row.swiping .item-swipe-bg,
.item-row.swipe-armed .item-swipe-bg { opacity: 1; }
.swipe-label { display: none; }
.item-row:not(.is-done) .swipe-label-done { display: inline; }
.item-row.is-done .swipe-label-undo { display: inline; }
.item-swipe-fg {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
  background: var(--card);
  color: var(--ink);
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(42, 48, 101, .10);
  transform: translate3d(0,0,0);
  will-change: transform;
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.item-row.swiping .item-swipe-fg { transition: none; }
.item-row.swipe-out .item-swipe-fg { transition: transform .18s ease-in; }
.item-row.is-done .item-title { text-decoration: line-through; color: #8a91b3; }
.item-row.is-done .item-swipe-fg { opacity: .88; }

.check-btn, .star-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 0;
  background: #eef1ff;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}
.check-btn { position: relative; }
.check-btn::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid currentColor;
  position: absolute;
  inset: 0;
  margin: auto;
}
.check-btn.is-on { background: var(--accent); color: #fff; }
.check-btn.is-on::after {
  content: '✓';
  border: 0;
  font-size: 14px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}
.star-btn { font-size: 16px; background: transparent; color: #c5cae4; }
.star-btn.is-on, .item-row.is-starred .star-btn { color: var(--accent); }

.item-main {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 2px 0;
  min-width: 0;
  cursor: pointer;
  display: grid;
  gap: 1px;
  outline: none;
}
.item-main:focus-visible { outline: 2px solid #aab4ff; outline-offset: 2px; border-radius: 8px; }
.item-title {
  color: #252d5f;
  font-size: .94rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.store-chip {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}

.completed-box { margin-top: 10px; }
.completed-box summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: rgba(84, 98, 188, .5);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
}
.completed-box summary::-webkit-details-marker { display: none; }
.completed-box .item-list { margin-top: 8px; }

.bottom-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(113,130,232,0) 0%, rgba(113,130,232,.95) 28%, rgba(113,130,232,.98) 100%);
}
.composer-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px;
  padding: 6px;
}
.composer-plus {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #3240a8;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}
.composer-input {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 10px 4px;
  min-width: 0;
}
.composer-input::placeholder { color: rgba(255,255,255,.72); }
.composer-store {
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  padding: 8px 8px;
  max-width: 110px;
}

.share-box { display: grid; gap: 8px; margin: 8px 0 12px; }
.member-card { justify-content: space-between; }
.flash {
  margin: 10px auto 0;
  max-width: 720px;
  padding: 10px 14px;
  border-radius: 12px;
}
.flash-ok { background: rgba(23, 176, 108, .2); }
.flash-warn { background: rgba(255, 190, 64, .2); }
.flash-error { background: rgba(255, 88, 88, .2); }

.item-sheet {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: none;
  width: 100vw;
  height: 100vh;
  background: transparent;
}
.item-sheet::backdrop { background: rgba(20, 24, 60, .45); }
.sheet-scrim {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  background: transparent;
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f4f6ff;
  color: var(--ink);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(20, 24, 60, .25);
  animation: sheet-up .2s ease;
}
.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #c9cfef;
  margin: 2px auto 12px;
}
.sheet-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}
.sheet-meta {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: .9rem;
}
.sheet-label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.sheet-btn, .sheet-close {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}
.sheet-btn { background: #e8ecff; color: var(--ink); }
.sheet-btn.danger { background: #ffe6ea; color: var(--danger); }
.sheet-close { margin-top: 8px; background: transparent; color: var(--muted); }

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

/* === DESKTOP SHELL === */



/* --- Mobile/desktop visibility --- */
.desk-only { display: none !important; }
.item-desk-actions { display: none; }

.desk-del-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b0b6d8;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
.desk-del-btn:hover { background: #ffe6ea; color: var(--danger); }


@media (min-width: 960px) {
  html, body {
    background: #e8ebf8;
    color: var(--ink);
  }

  .page-shell {
    min-height: 100vh;
    max-width: none;
    margin: 0;
  }

  .flash {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    max-width: 420px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(30, 36, 80, .2);
  }

  .mobile-only { display: none !important; }
  .desk-only { display: revert !important; }

  .desk-shell {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    min-height: 100vh;
    background:
      radial-gradient(1200px 600px at 10% -10%, rgba(111, 127, 232, .22), transparent 60%),
      radial-gradient(900px 500px at 100% 0%, rgba(95, 180, 255, .12), transparent 55%),
      #e8ebf8;
  }
  .desk-shell.is-detail-open {
    grid-template-columns: 268px minmax(0, 1fr) 340px;
  }

  /* Sidebar */
  .desk-sidebar {
    display: flex !important;
    flex-direction: column;
    gap: 14px;
    padding: 20px 16px;
    background: linear-gradient(180deg, #5f6fe0 0%, #6f7fe8 55%, #7a86e0 100%);
    color: #fff;
    border-right: 1px solid rgba(255,255,255,.12);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
  }
  .desk-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 8px;
  }
  .desk-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #fff;
    color: #4453c2;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.1rem;
  }
  .desk-brand strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: -.01em;
  }
  .desk-brand span {
    display: block;
    font-size: .78rem;
    opacity: .82;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .desk-new-list {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 8px;
  }
  .desk-new-input {
    border: 0;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,.16);
    color: #fff;
    outline: none;
  }
  .desk-new-input::placeholder { color: rgba(255,255,255,.7); }
  .desk-new-input:focus { background: rgba(255,255,255,.22); }
  .desk-new-btn {
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: #4453c2;
    font-weight: 800;
    font-size: 1.25rem;
    cursor: pointer;
  }
  .desk-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
    padding-right: 2px;
  }
  .desk-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,.92);
    transition: background .15s ease;
  }
  .desk-nav-item:hover { background: rgba(255,255,255,.12); }
  .desk-nav-item.is-active {
    background: #fff;
    color: #4453c2;
    font-weight: 700;
  }
  .desk-nav-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .desk-nav-meta {
    font-size: .75rem;
    font-weight: 700;
    opacity: .75;
    min-width: 1.5em;
    text-align: right;
  }
  .desk-nav-item.is-active .desk-nav-meta { opacity: 1; color: #6b75c7; }
  .desk-nav-empty {
    padding: 12px;
    opacity: .75;
    font-size: .9rem;
  }
  .desk-logout {
    margin-top: auto;
    padding-top: 8px;
  }
  .desk-logout button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 10px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
  }
  .desk-logout button:hover { background: rgba(255,255,255,.2); }

  /* Main */
  .desk-main {
    min-width: 0;
    min-height: 100vh;
  }
  .desk-main .screen {
    max-width: none;
    margin: 0;
    min-height: 100vh;
    padding: 28px 32px 48px;
    color: var(--ink);
  }
  .desk-main .muted,
  .desk-main .list-count,
  .desk-main .hero p { color: var(--muted); }

  .desk-hero {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
  }
  .desk-hero h1 {
    margin: 0 0 4px;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #1f2a65;
  }
  .desk-hero-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }
  .view-toggle {
    display: inline-flex;
    background: #fff;
    border-radius: 12px;
    padding: 3px;
    box-shadow: 0 2px 10px rgba(42, 48, 101, .08);
  }
  .view-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
  }
  .view-btn.is-active {
    background: #eef1ff;
    color: #4453c2;
  }
  .desk-hero-actions .secondary-btn {
    background: #fff;
    color: #4453c2;
    box-shadow: 0 2px 10px rgba(42, 48, 101, .08);
  }

  .desk-main .chip-row { padding-bottom: 14px; }
  .desk-main .chip {
    background: #fff;
    color: #5563ca;
    box-shadow: 0 2px 8px rgba(42, 48, 101, .06);
  }
  .desk-main .chip.active {
    background: #4453c2;
    color: #fff;
  }

  .desk-composer {
    display: block !important;
    margin-bottom: 20px;
  }
  .desk-composer-form {
    display: grid;
    grid-template-columns: 1fr 180px auto;
    gap: 10px;
    align-items: center;
    background: #fff;
    padding: 10px;
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(42, 48, 101, .08);
  }
  .desk-composer-input {
    border: 0;
    background: transparent;
    padding: 12px 14px;
  }
  .desk-composer-store {
    background: #f3f5ff;
  }
  .desk-add-btn {
    width: auto;
    padding: 12px 20px;
    border-radius: 12px;
    background: #4453c2;
    color: #fff;
  }

  /* Store boards */
  .store-boards {
    display: flex !important;
    gap: 14px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-snap-type: x proximity;
  }
  .store-col {
    flex: 0 0 300px;
    max-width: 300px;
    background: rgba(255,255,255,.55);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 16px;
    padding: 12px;
    scroll-snap-align: start;
    backdrop-filter: blur(8px);
  }
  .store-col-done {
    background: rgba(240, 242, 252, .7);
    opacity: .92;
  }
  .store-col-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 2px 4px;
  }
  .store-col-head h2 {
    margin: 0;
    font-size: .95rem;
    font-weight: 800;
    color: #1f2a65;
  }
  .store-col-head span {
    font-size: .75rem;
    font-weight: 700;
    color: #6b75c7;
    background: #eef1ff;
    border-radius: 999px;
    padding: 2px 8px;
  }
  .store-col-body { display: grid; gap: 6px; }
  .desk-empty {
    background: #fff;
    color: var(--muted);
    padding: 28px;
    border-radius: 16px;
    width: 100%;
  }

  .desk-shell[data-desk-view="list"] .store-boards { display: none !important; }
  .desk-shell:not([data-desk-view="list"]) .list-view-wrap { display: none; }
  .desk-shell[data-desk-view="list"] .list-view-wrap { display: block; }
  .desk-shell[data-desk-view="list"] #list-items {
    display: grid;
    gap: 6px;
    max-width: 720px;
  }

  /* Item row desktop */
  .item-swipe-fg {
    grid-template-columns: 32px 1fr auto;
    transition: transform .15s ease, box-shadow .15s ease;
  }
  .item-row { touch-action: auto; }
  .item-swipe-bg { display: none; }
  .star-btn-mobile { display: none !important; }
  .item-desk-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity .12s ease;
  }
  .item-row:hover .item-desk-actions,
  .item-row.is-selected .item-desk-actions,
  .item-row:focus-within .item-desk-actions { opacity: 1; }
  .item-row.is-selected .item-swipe-fg {
    box-shadow: 0 0 0 2px #aab4ff, 0 6px 18px rgba(42, 48, 101, .12);
  }
  .item-row:hover .item-swipe-fg {
    box-shadow: 0 6px 18px rgba(42, 48, 101, .14);
  }

  /* Detail panel */
  .desk-detail {
    display: flex !important;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid #e0e4f5;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 20px 20px 16px;
    box-shadow: -8px 0 28px rgba(42, 48, 101, .06);
    animation: desk-detail-in .18s ease;
  }
  .desk-detail[hidden] { display: none !important; }
  .desk-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }
  .desk-detail-head h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f2a65;
  }
  .desk-detail-head .icon-btn {
    background: #eef1ff;
    color: #4453c2;
  }
  .desk-detail-body {
    display: grid;
    gap: 6px;
    flex: 1;
    align-content: start;
  }
  .desk-detail-body .input,
  .desk-detail-body .store-select {
    margin-bottom: 10px;
    background: #f3f5ff;
  }
  .desk-detail-meta {
    margin: 8px 0 16px;
  }
  .desk-detail-meta strong {
    display: block;
    margin-top: 2px;
    color: #1f2a65;
  }
  .desk-detail-actions {
    display: grid;
    gap: 8px;
  }
  .desk-detail-actions .secondary-btn {
    background: #eef1ff;
    color: #4453c2;
    justify-content: flex-start;
    padding: 12px 14px;
  }
  .desk-detail-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #e8ebf8;
  }
  .desk-detail-foot .secondary-btn {
    width: 100%;
  }
  .desk-hint {
    margin: 10px 0 0;
    font-size: .75rem;
    color: var(--muted);
    text-align: center;
  }

  .desk-main .list-card {
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .desk-main .list-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(42, 48, 101, .14);
  }

  .desk-main .share-box,
  .desk-main .composer-card,
  .desk-main .empty-card {
    background: #fff;
    color: var(--ink);
    border: 0;
    box-shadow: 0 4px 18px rgba(42, 48, 101, .08);
  }
  .desk-main .hero h1,
  .desk-main .list-hero h1 { color: #1f2a65; }
  .desk-main .back-link { color: #4453c2; }
  .desk-main .completed-box summary {
    background: #e8ecff;
    color: #4453c2;
  }

  @keyframes desk-detail-in {
    from { opacity: .5; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
  }
}

@media (min-width: 1280px) {
  .store-col { flex-basis: 320px; max-width: 320px; }
  .desk-shell.is-detail-open {
    grid-template-columns: 280px minmax(0, 1fr) 360px;
  }
}
