:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #24272a;
  --muted: #6f7275;
  --line: #e4e0d7;
  --accent: #415a4c;
  --accent-soft: #e5ebe6;
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(1240px, 100% - 40px); margin-inline: auto; }

.eyebrow {
  display: block; margin: 0; font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- шапка ---------- */
.top { padding: 28px 0 8px; }
.top-inner { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.brand { display: grid; gap: 2px; }
.brand-title { font: 400 34px/1.1 var(--serif); letter-spacing: -.01em; }
.link-btn {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  color: var(--muted); font-size: 14px;
}
.link-btn:hover { color: var(--text); }

.search { position: relative; margin-top: 28px; }
.search svg {
  position: absolute; left: 16px; top: 50%; width: 20px; height: 20px; translate: 0 -50%;
  fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; pointer-events: none;
}
.search input {
  width: 100%; height: 52px; padding: 0 18px 0 46px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 17px; transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: #9a9c9e; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
/* ---------- фильтры ---------- */
.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 20px; }
.frow { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.flabel { flex: none; width: 104px; padding-top: 6px; color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; white-space: nowrap; transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .n { color: rgb(255 255 255 / .75); }
.chip.zero { opacity: .45; }
.frow.sub .chip { height: 28px; padding: 0 10px; font-size: 13px; }
.more-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.more-filters > summary {
  justify-self: start; cursor: pointer; color: var(--accent); font-size: 14px; padding: 2px 0;
  list-style: none;
}
.more-filters > summary::-webkit-details-marker { display: none; }
.more-filters > summary::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 0 3px 8px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; rotate: 45deg; transition: rotate .15s;
}
.more-filters[open] > summary::after { rotate: -135deg; margin-bottom: -1px; }
.more-filters[open] > summary { margin-bottom: 2px; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.afilter {
  display: inline-flex; align-items: center; gap: 2px; padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px;
}
.afilter .ico { width: 15px; height: 15px; }
.afilter:hover { background: #d8e2da; }
.reset { margin-left: 4px; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.reset:hover { color: var(--text); }
.feed { transition: opacity .2s; }
.feed.is-loading { opacity: .45; }
.empty a { color: var(--accent); text-decoration: underline; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.count { margin: 0 4px; color: var(--muted); font-size: 14px; min-height: 21px; }
.search-note:not(:empty) { margin-left: 10px; padding-left: 10px; border-left: 1px solid var(--line); color: var(--accent); }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.view-toggle { display: inline-flex; padding: 3px; gap: 2px; background: var(--line); border-radius: 999px; }
.view-toggle button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 14px; cursor: pointer;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.icon-btn, .copy-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
  border-radius: 8px; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn { width: 34px; height: 34px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.copy-btn { height: 34px; padding: 0 12px; border-color: var(--line); background: var(--surface); color: var(--text); font-size: 14px; }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn-quiet { background: none; color: var(--muted); }
.copy-btn .narrow { display: none; }
.is-copied, .is-copied:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- лента ---------- */
.feed { padding: 20px 0 96px; }
.feed-grid {
  display: grid; gap: 36px 24px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card { display: grid; gap: 10px; align-content: start; min-width: 0; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius); background: var(--line);
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .4s ease, opacity .2s;
}
.thumb::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .06);
}
.card:hover .thumb img { transform: scale(1.03); }
.badge {
  position: absolute; left: 10px; bottom: 10px; padding: 2px 8px; border-radius: 999px;
  background: rgb(255 255 255 / .92); font-size: 12px; font-weight: 500;
}
.card .title {
  font-size: 16px; line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .title:hover, .card:has(.thumb:hover) .title { color: var(--accent); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: -6px; min-height: 32px; }
.date { color: var(--muted); font-size: 14px; }
.card-meta .icon-btn { margin-left: auto; }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- список ---------- */
.month {
  position: sticky; top: 0; z-index: 2; margin: 0; padding: 22px 0 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font: 500 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.feed-list > .month:first-child, .feed-list > .js-total + .month { padding-top: 4px; }
.row {
  display: grid; grid-template-columns: 28px 30px minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:has(.pick input:checked) { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.pick { display: grid; place-items: center; width: 28px; height: 28px; cursor: pointer; }
.pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.day { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-title { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.row-title:hover { color: var(--accent); }
.tag { padding: 1px 6px; border-radius: 999px; background: var(--line); font-size: 11px; vertical-align: 2px; }
.row-link {
  justify-self: start; color: var(--muted); font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.row-link:hover { color: var(--accent); text-decoration: underline; }
.row-actions { display: flex; align-items: center; gap: 4px; }

.row-sub { color: var(--muted); font-size: 13px; }
.group-title { font-weight: 500; }
.group-head { border-bottom: 0; padding-bottom: 6px; }
.row.sub { padding: 6px 0; border-bottom: 0; }
.row.sub .row-main { border-left: 2px solid var(--line); padding-left: 14px; }
.row.sub .row-title { font-size: 15px; }
.group { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.group:has(.pick-all:checked) .group-head { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }

.collection {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 16px; padding: 12px 18px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent); font-size: 15px;
}
.collection a { font-weight: 500; }
.collection a:hover { text-decoration: underline; }

/* ---------- выбранные ---------- */
.selbar {
  position: fixed; left: 50%; bottom: 20px; translate: -50% 0; z-index: 5;
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 18px;
  background: var(--text); color: #fff; border-radius: 999px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .18); font-size: 15px; white-space: nowrap;
}
.selbar[hidden] { display: none; }
.selcount { margin-right: 6px; }
.selbar button { height: 36px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer; font-size: 14px; }
.selbar-copy { background: #fff; color: var(--text); font-weight: 500; }
.selbar-link { background: rgb(255 255 255 / .14); color: #fff; }
.selbar-link:hover { background: rgb(255 255 255 / .22); }
.selbar .narrow { display: none; }
.selbar-clear { background: none; color: rgb(255 255 255 / .75); }
.selbar-clear:hover { color: #fff; }

.toast {
  position: fixed; left: 50%; top: 20px; translate: -50% -12px; z-index: 10;
  padding: 10px 18px; border-radius: 999px; background: var(--text); color: #fff; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: -50% 0; }

.more { grid-column: 1 / -1; display: flex; justify-content: center; padding: 8px 0; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { rotate: 1turn; } }

/* ---------- плеер ---------- */
dialog#player {
  width: min(1100px, 100% - 32px); max-width: none; max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  overflow: auto;
}
dialog#player::backdrop { background: rgb(20 22 24 / .72); backdrop-filter: blur(3px); }
.player-box { position: relative; }
.frame { aspect-ratio: 16 / 9; background: #000; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; }
dialog.short .frame { aspect-ratio: 9 / 16; max-height: calc(100dvh - 170px); margin-inline: auto; }
dialog.short { width: min(480px, 100% - 32px); }
.player-meta { padding: 18px 22px 22px; }
.player-title { margin: 0; font: 400 22px/1.3 var(--serif); }
.player-sub { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; }
.player-yt { color: var(--accent); }
.player-yt:hover { text-decoration: underline; }
.close {
  position: absolute; top: 10px; right: 10px; z-index: 1; width: 38px; height: 38px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgb(255 255 255 / .9); font-size: 24px; line-height: 1;
}
.close:hover { background: #fff; }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 10px; padding: 40px 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.login-card h1 { margin: 0 0 18px; font: 400 32px/1.1 var(--serif); }
.login-card label { font-size: 14px; color: var(--muted); }
.login-card input {
  height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card button {
  margin-top: 10px; height: 48px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 500;
}
.login-card button:hover { filter: brightness(1.08); }
.error { margin: 0; color: #a3412f; font-size: 14px; }

@media (max-width: 600px) {
  .wrap { width: calc(100% - 28px); }
  .top { padding-top: 20px; }
  .brand-title { font-size: 28px; }
  .search { margin-top: 20px; }
  .feed-grid { gap: 28px; grid-template-columns: 1fr; }
  .frow { flex-direction: column; gap: 6px; }
  .flabel { width: auto; padding: 0; }
  .chips {
    flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 28px); margin-inline: -14px; padding: 0 14px 2px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
  .view-toggle button span { display: none; }
  .view-toggle button { padding: 0 10px; }
  .row { grid-template-columns: 28px 24px minmax(0, 1fr); }
  .row-actions { grid-column: 3; }
  .copy-btn { height: 32px; padding: 0 10px; }
  .copy-btn .wide { display: none; }
  .copy-btn .narrow { display: inline; }
  .selbar { left: 12px; right: 12px; translate: none; padding-left: 14px; font-size: 14px; }
  .selbar button { padding: 0 12px; }
  .selbar .wide { display: none; }
  .selbar .narrow { display: inline; }
  .selbar .ico.narrow { display: block; }
  .selbar-clear { padding: 0 10px; }
  .row.sub .row-main { padding-left: 10px; }
  dialog#player { width: 100%; max-height: 100dvh; border-radius: 0; margin: auto 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 2s !important; }
}
