:root {
  --paper: #faf5ec;
  --ink: #241a17;
  --muted: #6b5c55;
  --accent: #b3274a;
  --accent-ink: #fff8f2;
  --blush: #f6e3e0;
  --card: #fffdf8;
  --line: #e9dccd;
  --radius: 18px;
  --font-serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --font-sans: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}
html:focus-within { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: clip;
  min-height: 100dvh;
}
h1, h2, h3 {
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
  line-height: 1.12;
}
img { max-width: 100%; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 50;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: top 0.2s ease-out;
}
.skip:focus { top: 12px; }
.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  padding: 12px clamp(14px, 4vw, 22px);
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 10;
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand strong {
  display: block;
  font-size: 20px;
  font-family: var(--font-serif);
  line-height: 1.1;
}
.brand span { font-size: 12.5px; color: var(--muted); display: block; }
.session {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.session span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px clamp(14px, 4vw, 24px) 88px;
  min-width: 0;
}
.panel {
  width: min(100%, 460px);
  margin: 4vh auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px 20px;
}
.panel h1 { font-size: 30px; line-height: 1.08; margin: 0 0 10px; }
.lede { color: var(--muted); margin-top: 0; font-size: 15.5px; line-height: 1.6; }
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0; }
input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  margin-top: 6px;
}
input::placeholder { color: var(--muted); opacity: 1; }
input:disabled { background: var(--paper); color: var(--muted); }
.row { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  cursor: pointer;
  font-size: 15.5px;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 0.2s ease-out, background-color 0.2s ease-out;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: transparent; border: 1.5px solid #e5a9b6; color: var(--accent); }
.btn.small { padding: 10px 18px; min-height: 44px; font-size: 14.5px; }
.row .btn { width: 100%; }
.error { color: var(--accent); min-height: 1.4em; font-size: 14px; margin: 8px 0 0; }
.lists-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.lists-head h2 { margin: 0; font-size: 26px; }
.inline-form { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.inline-form .btn { width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 22px; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14.5px;
  line-height: 1.2;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.detail { border-top: 1px solid var(--line); padding-top: 16px; }
.detail-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.detail-head h3 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 16px; }
.masonry { columns: 1; column-gap: 14px; }
.tile {
  break-inside: avoid;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 14px;
}
.tile img {
  width: 100%;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--blush);
}
.tile .noimg {
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  background: var(--blush);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 14px;
  text-align: center;
  line-height: 1.5;
}
.tile .body { padding: 14px 14px 12px; }
.store {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--blush);
  border-radius: 999px;
  padding: 5px 12px;
  min-height: 28px;
  margin-bottom: 8px;
}
.tile h4 { margin: 0 0 4px; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.tile a.url {
  display: block;
  padding-block: 13px;
  min-height: 44px;
  font-size: 13.5px;
  color: var(--muted);
  word-break: break-all;
  text-underline-offset: 3px;
}
.tile a.url:hover { color: var(--accent); }
.note { font-size: 14.5px; color: #4c3f39; margin: 8px 0 0; line-height: 1.6; overflow-wrap: anywhere; }
.tile .actions {
  display: flex;
  gap: 4px 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.linklike {
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-underline-offset: 3px;
}
.linklike:hover { text-decoration: underline; }
.purchased-mark { font-size: 13px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }
.imgpreview img { width: 100%; display: block; border-radius: 12px; margin-top: 8px; aspect-ratio: 4/3; object-fit: cover; background: var(--blush); }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(36, 26, 23, 0.45); display: grid; align-items: end; justify-items: stretch; z-index: 40; padding: 0; }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px; margin: 0 auto; max-height: 88dvh; overflow: auto; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.sheet label { margin: 10px 0; }
.sheet .imgpreview img { margin-top: 4px; }
.sheet-row { display: flex; gap: 8px; margin-top: 12px; }
.sheet-row .btn { flex: 1; }

@media (min-width: 480px) {
  .row { flex-direction: row; }
  .row .btn { width: auto; flex: 1; }
}

@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; justify-items: center; padding: 20px; }
  .sheet { border-radius: 18px; }
  .brand strong { font-size: 22px; }
  .panel { padding: 28px; }
  .panel h1 { font-size: 34px; }
  .lists-head { flex-direction: row; align-items: end; justify-content: space-between; }
  .inline-form { flex-direction: row; align-items: center; }
  .inline-form input { flex: 1; }
  .inline-form .btn { width: auto; flex-shrink: 0; }
  .detail-head { flex-direction: row; justify-content: space-between; align-items: center; }
  .session span { max-width: none; }
}

@media (min-width: 700px) {
  .masonry { columns: 2; }
}

@media (min-width: 1100px) {
  .masonry { columns: 3; }
}

@media (prefers-reduced-motion: reduce) {
  html, html:focus-within { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .btn:hover, .chip { transform: none; }
}
