:root {
  --paper: #eef0e8;
  --card: #f8f9f4;
  --ink: #1f2622;
  --muted: #5e6862;
  --line: #d3d8cc;
  --accent: #c9472e;
  --accent-text: #a8361f;
  --accent-ink: #fff;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
  color-scheme: light;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
#view, .faq, .legal { scroll-margin-top: 130px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--body); min-height: 100dvh;
  display: flex; flex-direction: column; overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px clamp(14px, 4vw, 40px);
}
.mark { font: 800 26px/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: -0.03em; }
.mark span { color: var(--accent); }
.views { display: flex; gap: 2px; margin-left: auto; background: #e1e5da; padding: 3px; border-radius: 999px; }
.views button {
  border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--muted);
  min-height: 36px;
}
.views button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; min-height: 44px;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #b23d26; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { color: #a3301c; }
.btn.big { font-size: 18px; padding: 12px 26px; min-height: 52px; }
.linkish {
  background: none; border: 0; padding: 4px 0; color: var(--ink); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line); cursor: pointer; font-size: 14px;
}
.linkish:hover { text-decoration-color: var(--accent); }

/* ---------- main ---------- */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px clamp(14px, 4vw, 40px) 40px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 100%; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px;
  font-size: 14px; cursor: pointer; min-height: 34px; display: inline-flex; align-items: center; gap: 6px;
}
.chip .n { color: var(--muted); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip[aria-pressed="true"] .n { color: #b9c1b8; }
.chip.static { cursor: default; min-height: 0; }
.minrate { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.minrate select {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 8px; min-height: 36px; color: var(--ink);
}

/* stars: base row + clipped fill row */
.stars { position: relative; display: inline-block; line-height: 1; letter-spacing: 1px; font-size: 18px; white-space: nowrap; }
.stars .base { color: #c3c9bc; }
.stars .fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--accent); }
.stars.sm { font-size: 13px; }
.stars.lg { font-size: 36px; letter-spacing: 4px; }
.stars.input { display: flex; align-items: center; gap: 12px; cursor: pointer; touch-action: manipulation; padding: 4px 0; }
.stars.input::after { content: attr(data-label); font-size: 14px; color: var(--muted); }

/* ---------- grid ---------- */
.posters {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 22px 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.posters li { min-width: 0; }
.poster {
  position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; padding: 0; border: 0; border-radius: 6px;
  overflow: hidden; background: #dde2d5; cursor: pointer;
  box-shadow: 0 1px 0 rgb(0 0 0 / .06), 0 6px 16px -10px rgb(31 38 34 / .45);
  transition: transform .15s ease, box-shadow .15s ease;
}
.poster:hover { transform: translateY(-2px); box-shadow: 0 1px 0 rgb(0 0 0 / .06), 0 12px 22px -12px rgb(31 38 34 / .55); }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.noimg {
  display: grid; place-items: center; width: 100%; height: 100%; padding: 12px; text-align: center;
  font: 700 20px/1.1 var(--display); color: var(--muted); background: repeating-linear-gradient(135deg, #e3e7dc 0 10px, #dde2d5 10px 20px);
}
.noimg.sm { width: 56px; height: 56px; font-size: 22px; border-radius: 6px; flex: none; padding: 0; }
.again {
  position: absolute; top: 8px; right: 8px; background: var(--ink); color: var(--paper);
  font: 700 13px/1 var(--display); padding: 5px 8px; border-radius: 999px;
}
.pname { margin: 8px 0 3px; font-weight: 600; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- list ---------- */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li { border-bottom: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 4px; background: none; border: 0;
  text-align: left; cursor: pointer;
}
.row:hover { background: var(--card); }
.row img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.rmain { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtags { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.rmeta { color: var(--muted); font-size: 12px; }

/* ---------- diary ---------- */
.diary { display: grid; gap: 32px; }
.month header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.month h2 { font-size: clamp(24px, 4vw, 32px); }
.mstats { margin: 0; color: var(--muted); font-size: 14px; }
.month ol { list-style: none; margin: 0; padding: 0; }
.month li { border-bottom: 1px solid var(--line); }
.drow {
  display: grid; grid-template-columns: 44px 56px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 10px 4px; background: none; border: 0; text-align: left; cursor: pointer;
}
.drow:hover { background: var(--card); }
.drow img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }
.day { font: 700 24px/1 var(--display); text-align: center; display: flex; flex-direction: column; }
.day small { font: 500 11px/1.4 var(--body); color: var(--muted); }
.dname { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tag-again { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--accent-text); border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; vertical-align: 1px; }

/* ---------- empty ---------- */
.empty { max-width: 560px; margin: 8vh auto 0; text-align: center; display: grid; gap: 16px; justify-items: center; }
.empty h1 { font-size: clamp(34px, 7vw, 56px); font-weight: 800; letter-spacing: -0.03em; }
.empty p { margin: 0; color: var(--muted); font-size: 17px; }
.nothing { text-align: center; color: var(--muted); padding: 40px 0; display: grid; gap: 12px; justify-items: center; }
.small { font-size: 13px; color: var(--muted); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 18px clamp(14px, 4vw, 40px) 28px; max-width: 1240px; width: 100%; margin: 0 auto; }
.foot p { margin: 4px 0; font-size: 14px; }
#trialNote { color: var(--ink); }
.foot-actions { display: flex; flex-wrap: wrap; gap: 6px 20px; }
#payLink { color: var(--accent-text); font-weight: 600; text-decoration-color: currentColor; }

/* ---------- dialogs (bottom sheet on phones) ---------- */
dialog {
  border: 0; padding: 0; background: var(--card); color: var(--ink); border-radius: 16px;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .45);
}
dialog::backdrop { background: rgb(24 30 26 / .55); }
.sheet { padding: 18px 20px 22px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 24px; overflow-wrap: anywhere; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; width: 44px; height: 44px; cursor: pointer; border-radius: 999px; flex: none; color: var(--muted); }
.x:hover { background: #e6e9e0; color: var(--ink); }
.sheet label, .field { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.sheet input:not([type="file"]), .sheet textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; font-weight: 400; font-size: 16px;
}
.sheet textarea { resize: vertical; }
.hint { font-size: 13px; font-weight: 400; color: var(--muted); margin: 0; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding-top: 4px; }

.photo-drop {
  position: relative; display: grid !important; place-items: center; min-height: 160px; border: 2px dashed var(--line);
  border-radius: 12px; cursor: pointer; overflow: hidden; background: #fff; text-align: center;
}
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.photo-drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo-drop img { width: 100%; max-height: 300px; object-fit: cover; }
#photoHint { display: grid; font-weight: 600; color: var(--ink); }
#photoHint small { font-weight: 400; color: var(--muted); }
.photo-drop.has { border-style: solid; }
.photo-drop.has #photoHint {
  position: absolute; bottom: 10px; right: 10px; background: rgb(31 38 34 / .8); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 13px;
}

.detail .dphoto { width: 100%; max-height: 52vh; object-fit: cover; border-radius: 10px; }
.dmeta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dmeta .stars { font-size: 24px; }
.count { color: var(--muted); font-size: 14px; }
.nexttime { background: #fdf0e9; border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 8px 8px 0; }
.nexttime h3 { font-size: 15px; margin-bottom: 2px; }
.nexttime p, .notes { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dtags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.againbox { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.againbox input { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; min-height: 44px; }
.history summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.history ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.history li { display: flex; gap: 12px; align-items: baseline; }
.detail .sheet-actions { justify-content: flex-start; }

.themes { display: flex; flex-wrap: wrap; gap: 8px; }
.theme {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 12px 4px 4px; cursor: pointer; min-height: 40px; font-size: 14px;
}
.theme small { color: var(--muted); font-size: 11px; }
.theme[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sw { width: 30px; height: 30px; border-radius: 999px; flex: none; }
.card-preview { width: 100%; max-width: 360px; margin: 0 auto; border-radius: 8px; box-shadow: 0 8px 24px -14px rgb(0 0 0 / .5); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 50;
  transition: transform .25s ease, opacity .25s ease, visibility .25s; pointer-events: none; text-align: center; opacity: 0; visibility: hidden;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

@media (max-width: 560px) {
  .top { gap: 8px; padding-inline: 12px; flex-wrap: wrap; }
  .mark { font-size: 22px; }
  .views { order: 3; margin-left: 0; flex: 1 1 100%; justify-content: stretch; }
  .views button { flex: 1; }
  #addBtn { margin-left: auto; padding: 8px 14px; }
  .posters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .drow { grid-template-columns: 36px 48px 1fr; }
  .drow .stars { grid-column: 3; justify-self: start; margin-top: -6px; }
  .drow img, .drow .noimg.sm { width: 48px; height: 48px; grid-row: span 2; }
  .day { grid-row: span 2; }
  .rside .rmeta { display: none; }
}
@media (min-width: 1100px) {
  .posters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.detail a:not(.btn) { color: var(--accent-text); font-weight: 600; text-underline-offset: 3px; }

/* FAQ + legal footer (ship) */
.faq { max-width: 720px; margin: 8px auto 0; padding: 0 16px 8px; font-size: 14px; color: var(--ink); }
.faq h2 { font: 700 18px/1.2 var(--display); margin: 16px 0 8px; }
.faq h3 { font-size: 14px; margin: 14px 0 4px; }
.faq p { margin: 0; color: var(--muted); line-height: 1.5; }
.legal { max-width: 720px; margin: 0 auto; padding: 16px 16px 32px; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
