:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e3e6ef;
  --accent: #5b5bd6;
  --accent-dark: #4343b8;
  --danger: #b42318;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.who { color: var(--muted); font-size: .9rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-actions { display: flex; gap: .4rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; margin-bottom: .8rem; font-size: .9rem; color: var(--muted); }
input {
  display: block;
  width: 100%;
  margin-top: .25rem;
  padding: .55rem .7rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus { outline: 2px solid #c7c7f4; border-color: var(--accent); }

button, .button {
  display: inline-block;
  padding: .55rem .9rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-dark); text-decoration: none; }
button.secondary, .button.secondary {
  background: #fff;
  color: var(--accent);
  border-color: #cdd0e8;
}
button.secondary:hover, .button.secondary:hover { background: #f1f1fc; }
button.danger { background: #fff; color: var(--danger); border-color: #f3c9c5; }
button.danger:hover { background: #fdf3f2; }
button.danger.ghost { border-color: transparent; padding-left: 0; background: transparent; }
button.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 400;
  cursor: pointer;
}
form.inline { display: inline; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.req { color: var(--danger); }
.break { word-break: break-all; }

.flash {
  padding: .7rem .9rem;
  border-radius: 8px;
  margin: 0 0 1rem;
  font-size: .9rem;
}
.flash.error { background: #fdf1f0; color: #8c1d13; border: 1px solid #f3d1cd; }
.flash.success { background: #eef8f0; color: #1f6b36; border: 1px solid #cfe9d7; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head form { margin: 0; }

.wishlist-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .6rem; }
.wishlist-list .card { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.wishlist-list .row-actions { margin-top: 0; }

.pill { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: #eef0ff; color: var(--accent-dark); }
.muted-pill { background: #f1f2f6; color: var(--muted); }

section { margin-bottom: 1.5rem; }

.item-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .9rem;
}
.item { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #eef0f6; }
.thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #a9aecb;
}
.thumb.preview { max-width: 220px; border-radius: 8px; margin-bottom: .8rem; aspect-ratio: auto; }
.item-body { padding: .7rem .8rem .9rem; }
.item-body p { margin: 0 0 .25rem; }

/* Item name on the shared page is a button, never a raw link. */
.item-name {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.item-name:hover { background: none; color: var(--accent-dark); }

.share-box input { font-family: ui-monospace, monospace; font-size: .85rem; }
.share-box .row { flex-wrap: nowrap; }
.share-box .row input { margin-top: 0; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 30, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 1.3rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(10, 12, 25, .25);
}
.modal h2 { margin-bottom: .5rem; }
.modal-text { margin: 0 0 .4rem; }
.link-preview {
  margin: 0 0 .6rem;
  padding: .5rem .6rem;
  background: #f4f5fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: .8rem;
  word-break: break-all;
  max-height: 6.5rem;
  overflow: auto;
}
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
