@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #fdfbf7;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --border: #e7e2d9;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 12px 32px -10px rgba(0,0,0,0.08);
  --shadow-lg: 0 24px 60px -16px rgba(0,0,0,0.14);
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --accent: #d97706;
  --accent-ink: #92400e;
  --success: #10b981;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.hero {
  position: relative;
  padding: 40px 32px 32px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff8f2 0%, #f3ebe2 100%);
  margin-bottom: 40px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(217,119,6,0.10) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo-icon {
  width: 52px;
  height: 52px;
  color: var(--accent);
  stroke-width: 1.8;
}

.title-lockup h1 {
  font-family: var(--font-display);
  font-size: 2.75rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.title-lockup p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.progress-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  padding: 16px 22px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 180px;
}

.progress-ring {
  width: 72px;
  height: 72px;
  position: relative;
  flex-shrink: 0;
}

.progress-ring svg {
  transform: rotate(-90deg);
  width: 72px;
  height: 72px;
}

.progress-ring circle {
  fill: none;
  stroke-width: 6;
}

.progress-ring .track {
  stroke: #e7e2d9;
}

.progress-ring .bar {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-ring .percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.progress-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#progressText {
  font-weight: 600;
  font-size: 1.15rem;
}

.progress-muted {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trip-input {
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.trip-input label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

#tripTitle {
  width: 100%;
  max-width: 440px;
  font-family: var(--font-display);
  font-size: 1.75rem;
  border: 0;
  border-bottom: 2px solid var(--border);
  background: transparent;
  color: var(--ink);
  outline: none;
  transition: border-color 0.3s, color 0.3s;
  padding: 4px 0;
}

#tripTitle:focus {
  border-color: var(--accent);
}

#tripTitle::placeholder {
  color: #b9b0a4;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  margin: 0 0 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.category-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 48px;
}

.category-card {
  position: relative;
  border: 0;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  background-color: #e7e2d9;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s, border-color 0.3s, filter 0.3s;
  outline: none;
  padding: 0;
  opacity: 0;
  transform: translateY(22px);
  animation: cardEnter 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--i) * 70ms);
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}

@keyframes cardEnter {
  to { opacity: 1; transform: none; }
}

.category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 42%, rgba(0,0,0,0.55) 100%);
  transition: background 0.3s;
}

.category-card:hover,
.category-card:focus-visible {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.category-card.selected {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 28px 70px -16px rgba(0,0,0,0.18), 0 0 0 3px color-mix(in srgb, var(--cat-color) 35%, transparent);
  border-color: var(--cat-color);
}

.category-card.selected::after {
  background: linear-gradient(180deg, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.68) 100%);
}

.category-card .card-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(0.85) brightness(0.95);
  transition: filter 0.35s, transform 0.7s ease;
}

.category-card.selected .card-image,
.category-card:hover .card-image {
  filter: saturate(1.15) brightness(1.05);
  transform: scale(1.06);
}

.category-card-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
  color: #fff;
  pointer-events: none;
}

.category-card-icon {
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  stroke-width: 2.2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

.category-card-label {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.15;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.category-card-count {
  font-size: 0.78rem;
  opacity: 0.82;
  margin-top: 3px;
}

.check-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  background: var(--cat-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transform: scale(0);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 3;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}

.check-badge .icon {
  width: 22px;
  height: 22px;
  stroke-width: 3;
}

.category-card.selected .check-badge {
  transform: scale(1);
}

.list-section {
  max-width: 920px;
  margin: 0 auto;
}

.checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px -4px rgba(0,0,0,0.15);
}

.btn:hover {
  background: #000;
}

.btn:active {
  transform: scale(0.96);
}

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: #f7f5f2;
}

.btn .icon {
  width: 18px;
  height: 18px;
}

.empty-state,
.all-packed {
  text-align: center;
  padding: 56px 24px;
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.empty-state {
  color: var(--muted);
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px dashed var(--border);
}

.empty-state .icon {
  width: 68px;
  height: 68px;
  color: #d6cfc5;
  margin-bottom: 18px;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--ink);
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
}

.all-packed {
  display: none;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  color: #065f46;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.all-packed:not(.hidden) {
  display: block;
  animation: bannerPop 0.5s ease;
}

@keyframes bannerPop {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: opacity 0.35s, transform 0.35s;
  opacity: 1;
  transform: none;
}

.group.hidden {
  display: none;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.group-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
  stroke-width: 2.2;
}

.group-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0;
  flex: 1;
  font-weight: 700;
}

.group-count {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.group-progress {
  width: 90px;
  height: 7px;
  background: #e7e2d9;
  border-radius: 999px;
  overflow: hidden;
  margin-left: 8px;
}

.group-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.item:last-child {
  border-bottom: 0;
}

.item:hover {
  background: rgba(243, 237, 230, 0.35);
  border-radius: 10px;
  margin: 0 -10px;
  padding-left: 10px;
  padding-right: 10px;
}

.item:hover + .item,
.item:has(+ .item:hover) {
  border-color: transparent;
}

.item.checked .item-name {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

@keyframes itemEnter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.item.entering {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item.entering.in {
  opacity: 1;
  transform: none;
}

.item.leaving {
  animation: itemLeave 0.32s ease forwards;
}

@keyframes itemLeave {
  to { opacity: 0; transform: translateX(-24px); }
}

.item-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.item-checkbox {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.item-box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.22s, border-color 0.22s, transform 0.22s;
  flex-shrink: 0;
  background: var(--surface);
}

.item-box .icon {
  width: 15px;
  height: 15px;
  opacity: 0;
  transform: scale(0.4) rotate(-10deg);
  transition: opacity 0.22s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item-checkbox:checked + .item-box {
  background: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  transform: scale(1.08);
}

.item-checkbox:checked + .item-box .icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.item:focus-within .item-box {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat-color, var(--accent)) 25%, transparent);
}

.item-name {
  font-size: 1rem;
  font-weight: 500;
  transition: color 0.2s;
}

.remove-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 9px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s, transform 0.15s;
}

.item:hover .remove-btn,
.item:focus-within .remove-btn,
.remove-btn:focus-visible {
  opacity: 1;
}

.remove-btn:hover {
  color: var(--danger);
  background: #fef2f2;
  transform: scale(1.05);
}

.remove-btn .icon {
  width: 18px;
  height: 18px;
}

.add-item-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1.5px dashed var(--border);
  align-items: center;
}

.custom-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
  color: var(--ink);
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.custom-input::placeholder {
  color: #b0a89c;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: #000;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

/* Print layer hidden on screen */
#printLayer {
  display: none;
}

/* Responsive */
@media (max-width: 640px) {
  .app-shell { padding: 16px 16px 60px; }
  .hero { padding: 28px 22px; }
  .hero-top { flex-direction: column; align-items: stretch; }
  .title-lockup { gap: 14px; }
  .title-lockup h1 { font-size: 2.1rem; }
  .progress-card { align-self: flex-start; }
  #tripTitle { font-size: 1.45rem; max-width: 100%; }
  .category-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .category-card { aspect-ratio: 1 / 1.15; }
  .category-card-label { font-size: 1.15rem; }
  .checklist-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .actions { width: 100%; }
  .btn { flex: 1; justify-content: center; }
  .group { padding: 18px; }
  .item:hover { margin: 0; padding-left: 0; padding-right: 0; }
  .remove-btn { opacity: 1; }
}

@media (max-width: 400px) {
  .category-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .btn { padding: 10px 12px; font-size: 0.9rem; }
  .btn .icon { width: 16px; height: 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
