:root {
  --bg: #f4f1eb;
  --card: rgba(255,255,255,.78);
  --card-solid: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: rgba(17,24,39,.1);
  --primary: #111827;
  --primary-soft: #e8dfd1;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(17,24,39,.12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 10%, rgba(186, 154, 107, .28), transparent 28rem),
    radial-gradient(circle at 95% 0%, rgba(17, 24, 39, .14), transparent 28rem),
    linear-gradient(135deg, #f7f3eb 0%, #ece4d8 100%);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 2px 20px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 7vw, 48px); letter-spacing: -0.06em; }
h2 { font-size: clamp(24px, 5vw, 42px); letter-spacing: -0.05em; line-height: 1.02; }
h3 { font-size: 22px; letter-spacing: -0.03em; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .18em; font-weight: 800; margin-bottom: 6px; }

.hero-card, .search-card, .empty-state, .dialog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: clamp(22px, 5vw, 40px);
}

.hero-card p { color: var(--muted); margin-top: 12px; max-width: 680px; line-height: 1.55; }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .photo-btn, .icon-btn {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, opacity .15s ease;
}
.primary-btn:active, .secondary-btn:active, .ghost-btn:active, .danger-btn:active, .photo-btn:active, .icon-btn:active { transform: scale(.98); }
.primary-btn { background: var(--primary); color: white; }
.secondary-btn { background: #ede7dc; color: var(--text); }
.ghost-btn { background: rgba(255,255,255,.6); color: var(--text); border: 1px solid var(--border); }
.danger-btn { background: #fee4e2; color: var(--danger); }
.photo-btn { background: var(--primary-soft); color: var(--text); }
.icon-btn { width: 46px; padding: 0; font-size: 28px; background: #f2eee7; color: var(--text); }

.search-card {
  margin-top: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border-radius: 18px;
  padding: 0 14px;
  min-height: 54px;
  border: 1px solid var(--border);
}
.search-wrap span { color: var(--muted); font-size: 24px; }
.search-wrap input { border: 0; outline: 0; width: 100%; background: transparent; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stats span { background: #fff; border: 1px solid var(--border); padding: 9px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--muted); }

.items-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.item-card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(17,24,39,.09);
}
.item-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #ded6c9;
  display: block;
}
.item-body { padding: 16px; }
.item-body h3 { margin-bottom: 8px; }
.item-place { color: var(--text); font-weight: 800; margin-bottom: 8px; }
.item-notes { color: var(--muted); line-height: 1.45; min-height: 42px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tag { font-size: 12px; font-weight: 800; color: #4b5563; background: #f2eee7; border-radius: 999px; padding: 6px 9px; }
.card-actions { display: flex; gap: 8px; padding: 0 16px 16px; }
.card-actions button { flex: 1; min-height: 40px; }

.empty-state { margin-top: 16px; text-align: center; padding: 42px 18px; }
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-state p { color: var(--muted); margin: 8px auto 18px; max-width: 420px; }

.dialog, .viewer-dialog { border: 0; background: transparent; padding: 12px; width: min(760px, 100%); }
.dialog::backdrop, .viewer-dialog::backdrop { background: rgba(17,24,39,.5); backdrop-filter: blur(6px); }
.dialog-card { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 16px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 900; color: #374151; margin-top: 12px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: white;
  border-radius: 16px;
  padding: 14px;
  outline: none;
  color: var(--text);
}
textarea { resize: vertical; }
.photo-panel { margin-top: 14px; background: rgba(255,255,255,.62); border: 1px solid var(--border); border-radius: 20px; padding: 14px; }
.photo-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.photo-panel p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.photo-preview { margin-top: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.photo-tile { position: relative; border-radius: 16px; overflow: hidden; background: #ded6c9; aspect-ratio: 1; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile button { position: absolute; top: 6px; right: 6px; min-height: 30px; width: 30px; padding: 0; background: rgba(17,24,39,.8); color: #fff; border-radius: 999px; border: 0; }
.dialog-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.spacer { flex: 1; }

.viewer-dialog { width: min(980px, 100%); }
.viewer-card { position: relative; background: #111827; border-radius: 22px; padding: 12px; }
.viewer-card img { width: 100%; max-height: 82vh; object-fit: contain; display: block; border-radius: 16px; }
.viewer-close { position: absolute; top: 18px; right: 18px; z-index: 2; background: rgba(255,255,255,.9); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120px);
  background: #111827;
  color: #fff;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform .25s ease;
  z-index: 10;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 820px) {
  .hero-card, .search-card { grid-template-columns: 1fr; }
  .items-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .items-grid { grid-template-columns: 1fr; }
  .photo-preview { grid-template-columns: repeat(3, 1fr); }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions button, .dialog-actions .spacer { flex: 1 1 100%; }
  .topbar { align-items: start; }
}
