:root {
  --bg: #faf7f2; --card: #ffffff; --fg: #1d1b19; --muted: #77716a; --line: #ebe5dc;
  --accent: #d9481e; --accent-fg: #fff; --ok: #1f8a4c; --warn: #b4581a; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(60,40,20,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312; --card: #1d1c1a; --fg: #f1ece5; --muted: #a39b91; --line: #2c2a27;
    --accent: #ff7a4d; --accent-fg: #1a0d07; --ok: #4fc483; --warn: #e79a5c; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141312; --card: #1d1c1a; --fg: #f1ece5; --muted: #a39b91; --line: #2c2a27;
  --accent: #ff7a4d; --accent-fg: #1a0d07; --ok: #4fc483; --warn: #e79a5c; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  max-width: 1180px; margin: 0 auto; padding: 18px 16px; }
.brand { text-decoration: none; font-weight: 650; font-size: 18px; letter-spacing: -.01em; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.top nav a { color: var(--muted); text-decoration: none; }
.theme { border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }

.intro { padding: 28px 0 32px; max-width: 680px; }
.intro.narrow { max-width: 560px; margin: 0 auto; }
.intro h1 { font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05; letter-spacing: -.02em; margin: 0 0 14px; }
.intro p { color: var(--muted); margin: 0 0 12px; }
.empty { color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card { background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: transform .2s ease; }
.card:hover { transform: translateY(-2px); }
.card .pic { position: relative; display: block; aspect-ratio: 1; background: #fff; }
.card .pic img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.card .ph { display: grid; place-items: center; height: 100%; font-size: 56px; background: var(--line); }
.card.taken .pic img, .card.taken .ph { opacity: .35; filter: grayscale(1); }
.badge { position: absolute; left: 12px; top: 12px; background: var(--fg); color: var(--bg);
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h2 { font-size: 15px; font-weight: 550; line-height: 1.35; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card h2 a { text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.price { color: var(--fg); font-size: 17px; font-weight: 700; }
.down { color: var(--ok); } .up { color: var(--warn); } .warn { color: var(--warn); } .muted { color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin: 0; }
.reserve { margin-top: auto; }
.reserve summary { list-style: none; cursor: pointer; text-align: center; font-weight: 600; font-size: 14px;
  padding: 9px; border-radius: 12px; background: var(--accent); color: var(--accent-fg); }
.reserve summary::-webkit-details-marker { display: none; }
.reserve[open] summary { background: transparent; color: var(--muted); padding: 4px; }
.reserve form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
input { font: inherit; font-size: 14px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); min-width: 0; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: 9px 14px; background: var(--accent); color: var(--accent-fg); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; }

.resv { display: flex; gap: 16px; align-items: center; background: var(--card); padding: 14px; border-radius: 16px;
  box-shadow: var(--shadow); margin: 8px 0 18px; }
.resv img { width: 96px; height: 96px; object-fit: contain; background: #fff; border-radius: 10px; }
.copy input { width: 100%; }

/* /me */
.add { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; margin: 8px 0 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 22px; }
.group { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 8px; }
.group span { font-weight: 400; }
.rows { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.rows li { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li:target { outline: 2px solid var(--accent); border-radius: 12px; }
.rows li.private .thumb { opacity: .55; }
.thumb { width: 64px; height: 64px; border-radius: 10px; background: #fff; display: grid; place-items: center; overflow: hidden; text-decoration: none; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.info { min-width: 0; }
.info summary { list-style: none; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info summary::-webkit-details-marker { display: none; }
.info b { font-weight: 550; }
.edit { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.edit input { flex: 1 1 200px; }
.acts { display: flex; gap: 4px; }
.acts button { background: transparent; color: var(--fg); border: 1px solid var(--line); padding: 6px 9px; font-size: 14px; }
.acts button:hover { background: var(--bg); }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card .body { padding: 10px 12px 12px; }
  .card h2 { font-size: 14px; }
  .add { grid-template-columns: 1fr; }
  .rows li { grid-template-columns: 48px 1fr; }
  .thumb { width: 48px; height: 48px; }
  .acts { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---- /me: плавність ---- */
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(*), ::view-transition-new(*) { animation-duration: .3s; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
.acts button, .add button, .edit button { transition: transform .15s ease, background-color .2s ease, opacity .2s ease, border-color .2s ease; }
.acts button:hover { border-color: var(--accent); transform: translateY(-1px); }
.acts button:active, .add button:active, .edit button:active { transform: scale(.92); }
button.busy { opacity: .55; pointer-events: none; }
.acts button[value="refresh"].busy { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rows li { transition: background-color .4s ease; }
.rows li.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
.info details[open] .edit { animation: drop .25s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.thumb img { transition: transform .3s ease; }
.rows li:hover .thumb img { transform: scale(1.06); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--fg); color: var(--bg); padding: 10px 14px 10px 16px; border-radius: 12px; font-size: 14px;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  transition: opacity .25s ease, transform .3s cubic-bezier(.22, 1, .36, 1); z-index: 10; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: transparent; color: var(--accent); padding: 0; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .rows li.flash, #toast { animation: none; transition: none; }
}

/* ---- /me/triage ---- */
.navbtn { color: var(--accent) !important; font-weight: 600; }
.tri { max-width: 520px; margin: 0 auto; }
.tri-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.bar { flex: 1 1 100%; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .45s cubic-bezier(.22,1,.36,1); }
.count { font-size: 13px; color: var(--muted); }
.only { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.stage { position: relative; height: min(560px, 68vh); margin-bottom: 18px; touch-action: none; }
.stage > div[class^="hint"] { position: absolute; font-size: 13px; font-weight: 700; color: var(--muted); opacity: .0;
  transition: opacity .2s, color .2s; pointer-events: none; z-index: 0; }
.hint-l { left: -4px; top: 45%; } .hint-r { right: -4px; top: 45%; } .hint-u { top: -22px; left: 50%; transform: translateX(-50%); }
.hint-d { bottom: -22px; left: 50%; transform: translateX(-50%); }
.stage[data-dir="l"] .hint-l, .stage[data-dir="r"] .hint-r, .stage[data-dir="u"] .hint-u, .stage[data-dir="d"] .hint-d { opacity: 1; color: var(--accent); }
.tcard { position: absolute; inset: 0; background: var(--card); border-radius: 22px; box-shadow: 0 12px 40px rgba(40,25,10,.14);
  display: flex; flex-direction: column; overflow: hidden; cursor: grab; user-select: none; z-index: 2;
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .3s; will-change: transform; }
.tcard:active { cursor: grabbing; }
.tcard.behind { --d: 1; transform: translateY(calc(var(--d) * 12px)) scale(calc(1 - var(--d) * .04)); opacity: calc(1 - var(--d) * .3);
  z-index: 1; pointer-events: none; filter: saturate(.8); }
.tpic { position: relative; flex: 1 1 58%; min-height: 0; background: #fff; display: grid; place-items: center; }
.tpic img { width: 100%; height: 100%; object-fit: contain; padding: 18px; pointer-events: none; }
.tpic > span:not(.tstate) { font-size: 80px; }
.tstate { position: absolute; left: 14px; top: 14px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px;
  background: rgba(0,0,0,.06); color: #333; }
.tbody { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 8px; }
.tbody h2 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 650; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tmeta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); align-items: baseline; }
.tmeta b { font-size: 20px; color: var(--fg); }
.tnote { margin: 0; font-size: 13px; color: var(--muted); }
.tlink { font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 600; align-self: flex-start; }
.stamp { position: absolute; z-index: 3; font-style: normal; font-weight: 800; font-size: 22px; padding: 6px 14px; border: 3px solid;
  border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .1s; text-transform: uppercase; letter-spacing: .04em; }
.s-r { left: 22px; top: 26px; color: #1f8a4c; transform: rotate(-12deg); } .s-r::after { content: "показувати"; }
.s-l { right: 22px; top: 26px; color: #6b5cff; transform: rotate(12deg); } .s-l::after { content: "лише мені"; }
.s-u { left: 50%; bottom: 46%; color: #0e7fa8; transform: translateX(-50%); } .s-u::after { content: "купив"; }
.s-d { left: 50%; top: 30%; color: #8a6d3b; transform: translateX(-50%); } .s-d::after { content: "архів"; }
.tcard[data-dir="r"] .s-r, .tcard[data-dir="l"] .s-l, .tcard[data-dir="u"] .s-u, .tcard[data-dir="d"] .s-d { opacity: var(--k, 0); }
.tcard.go-public .s-r, .tcard.go-private .s-l, .tcard.go-bought .s-u, .tcard.go-archived .s-d { opacity: 1; }
.tri-acts { display: flex; justify-content: center; gap: 10px; }
.tri-acts button { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; padding: 10px 4px 8px;
  border-radius: 16px; background: var(--card); color: var(--fg); border: 1px solid var(--line); font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05); transition: transform .15s ease, border-color .2s, box-shadow .2s; }
.tri-acts button span { font-size: 11px; font-weight: 600; color: var(--muted); }
.tri-acts button:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.tri-acts button:active { transform: scale(.92); }
.tri-acts .b-pub { border-color: #1f8a4c55; } .tri-acts .b-priv { border-color: #6b5cff55; }
.tri-acts .b-skip { width: 60px; font-size: 18px; }
.keys { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.done { text-align: center; padding: 40px 0; }
.done .big { font-size: 64px; animation: pop .6s cubic-bezier(.22,1.6,.36,1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.done h2 { font-family: Georgia, serif; font-weight: 400; font-size: 36px; margin: 6px 0; }
.done p { color: var(--muted); }
.btn { display: inline-block; padding: 10px 16px; border-radius: 12px; background: var(--accent); color: var(--accent-fg); text-decoration: none; font-weight: 600; margin: 4px; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
@media (max-width: 640px) {
  .stage { height: 62vh; }
  .tri-acts { gap: 6px; } .tri-acts button { width: 62px; }
  .keys { display: none; }
}
/* виправлення: фото не налазить на текст, підписи вміщаються */
.tpic { display: block; overflow: hidden; flex: 1 1 auto; }
.tpic img { position: absolute; inset: 0; }
.tpic > span:not(.tstate) { position: absolute; inset: 0; display: grid; place-items: center; }
.tbody { flex: none; background: var(--card); position: relative; }
.tri-acts button { width: 86px; }
.tri-acts .b-skip { width: 74px; }
.tri-acts button span { font-size: 11px; white-space: nowrap; }
@media (max-width: 640px) {
  .tri-acts button, .tri-acts .b-skip { width: auto; flex: 1 1 0; min-width: 0; padding: 9px 2px 7px; }
  .tri-acts button span { font-size: 10px; }
}
