/* Галерея генераций — облик Студии историй: светлый лист, волосяные линии, моно-подписи, серые плитки, один синий. У текста теней и свечения нет. */
@font-face { font-family: "Geist"; font-weight: 400; src: url(fonts/geist-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Geist"; font-weight: 400; src: url(fonts/geist-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 500; src: url(fonts/geist-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Geist"; font-weight: 500; src: url(fonts/geist-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 400; src: url(fonts/geist-mono-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Geist Mono"; font-weight: 400; src: url(fonts/geist-mono-latin-400-normal.woff2) format("woff2"); }

:root {
  --bg: #f2f2f0; --surface: #e8e8e5; --surface-2: #dcdcd8; --paper: #fbfbfa; --text: #1b2425; --muted: #70787a; --border: #cfd1cd;
  --accent: #1f3bff; --accent-soft: #e2e6ff; --danger: #b42318;
  --sans: "Geist", ui-sans-serif, system-ui, "Segoe UI", sans-serif; --mono: "Geist Mono", ui-monospace, Consolas, monospace;
  --tile: 200px; --ease: cubic-bezier(.2, .8, .2, 1); --top: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.cap { font: 11px/1.3 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.mono { font: 12.5px var(--mono); }
.num { font: 12px/1 var(--mono); }
.hidden { display: none !important; }
.only-m { display: none !important; }
body.guest .own { display: none !important; }
body:not(.guest) .guest-only { display: none !important; }

/* вход */
.login { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login p { color: var(--muted); margin: 6px 0 8px; font-size: 13.5px; }
.login .field { height: 44px; font-size: 16px; }
.login .btn { height: 44px; font-size: 15px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* шапка */
.top { height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 8px; font: 13px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.badge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--accent); color: #fff; font: 11px/16px var(--mono); text-align: center; }
.field { height: 32px; border: 0; border-radius: 8px; background: var(--surface); padding: 0 12px; font: inherit; color: var(--text); outline: none; width: 100%; }
.field:focus, textarea:focus { box-shadow: inset 0 0 0 1px var(--accent); }
.seg { display: inline-flex; background: var(--surface); border-radius: 8px; padding: 2px; flex: none; }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--paper); color: var(--text); }
.btn { display: inline-flex; align-items: center; border: 0; border-radius: 8px; padding: 7px 13px; background: var(--text); color: var(--paper); font-size: 13px; white-space: nowrap; transition: opacity .15s; cursor: pointer; }
.btn:hover { opacity: .85; }
.btn.ghost { background: var(--surface); color: var(--text); }
.btn.on { background: var(--accent); color: #fff; }
.link { border: 0; background: none; padding: 0 0 0 8px; color: var(--accent); font: inherit; text-transform: none; letter-spacing: 0; }

/* раскладка */
.layout { display: flex; height: calc(100% - var(--top)); position: relative; }
.sets { width: 300px; flex: none; overflow-y: auto; border-right: 1px solid var(--border); padding: 0 0 40px; background: var(--bg); }
.sets-top { position: sticky; top: 0; background: var(--bg); padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 8px; z-index: 2; border-bottom: 1px solid var(--border); }
.set { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 18px; position: relative; }
.set:hover { background: var(--surface); }
.set.on { background: var(--surface-2); }
.set .p { font: 10.5px/1.3 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set .n { display: flex; gap: 8px; align-items: baseline; }
.set .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.set .c { font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.set .f { font: 11px var(--mono); color: var(--accent); white-space: nowrap; }
.set .sh { font: 10px var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.set.old .t { color: var(--muted); }
.set.new::before, .tile.new .im::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.set.new::before { left: 7px; top: 27px; }
.scrim { display: none; }

.main { flex: 1; overflow-y: auto; padding: 0 24px 120px; min-width: 0; }
.set-head { display: flex; align-items: flex-end; gap: 16px; padding: 18px 0 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 3; }
.set-title { flex: 1; min-width: 0; }
.set-title h1 { margin: 4px 0 0; font-weight: 500; font-size: 22px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.size { display: flex; align-items: center; gap: 6px; }
.size input { width: 90px; accent-color: var(--text); }
.subdirs { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0 0; }
.subdirs button { border: 0; background: var(--surface); border-radius: 6px; padding: 4px 9px; font: 11.5px var(--mono); color: var(--muted); }
.subdirs button:hover { color: var(--text); }

/* сетка */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 14px 12px; padding-top: 16px; align-items: start; }
.tile { position: relative; cursor: pointer; }
.tile .im { position: relative; background: var(--surface); border-radius: 6px; overflow: hidden; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s; }
.tile .im::after { right: 8px; bottom: 8px; box-shadow: 0 0 0 2px var(--paper); }
.tile img, .tile video { display: block; width: 100%; height: auto; }
.tile.sel .im { outline-color: var(--text); }
.tile.fav .im { outline-color: var(--accent); }
.tile .lab { display: flex; gap: 6px; align-items: baseline; padding-top: 5px; font: 11px/1.3 var(--mono); color: var(--muted); }
.tile .lab b { font-weight: 400; color: var(--text); }
.tile .lab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tile .lab i { font-style: normal; color: var(--accent); white-space: nowrap; }
.tile .heart, .tile .plus { position: absolute; top: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(251,251,250,.92); font-size: 14px; line-height: 30px; text-align: center; padding: 0; opacity: 0; transition: opacity .15s; }
.tile .heart { right: 6px; color: var(--muted); }
.tile .plus { left: 6px; }
.tile:hover .heart, .tile:hover .plus { opacity: 1; }
.tile.fav .heart { opacity: 1; background: var(--accent); color: #fff; }
body.guest .tile .heart { pointer-events: none; }
body.guest .tile:not(.fav) .heart { display: none; }
.tile.cmp .plus { opacity: 1; background: var(--text); color: var(--paper); }
.more { padding: 30px 0; text-align: center; }
.empty { padding: 60px 0; color: var(--muted); }

/* боковые панели */
.panel { width: 400px; flex: none; overflow-y: auto; border-left: 1px solid var(--border); background: var(--paper); padding: 16px 18px 60px; position: relative; }
.panel h2 { margin: 4px 0 14px; font-weight: 500; font-size: 18px; overflow-wrap: anywhere; }
.insp-img { background: var(--surface); border-radius: 6px; overflow: hidden; margin-top: 26px; cursor: zoom-in; }
.insp-img img, .insp-img video { display: block; width: 100%; max-height: 52vh; object-fit: contain; }
.insp-name { display: flex; gap: 8px; align-items: baseline; padding: 10px 0 8px; }
.insp-name .cap { text-transform: none; overflow-wrap: anywhere; }
.insp-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.params { display: grid; grid-template-columns: 92px 1fr; margin: 0; }
.params dt, .params dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--border); }
.params dt { font: 11px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.params dd { font: 12.5px/1.5 var(--mono); overflow-wrap: anywhere; }
.params dd .lora { display: flex; gap: 8px; justify-content: space-between; }
.params dd .lora span { min-width: 0; overflow-wrap: anywhere; }
.params dd .lora b { flex: none; font-weight: 400; color: var(--accent); }
.txt { padding: 12px 0; border-bottom: 1px solid var(--border); }
.txt p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.txt summary { cursor: pointer; }
.x { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface); font-size: 18px; line-height: 32px; padding: 0; z-index: 3; }
.x.light { background: rgba(255,255,255,.12); color: #fff; }

/* комментарии */
.comm { padding: 12px 0; border-bottom: 1px solid var(--border); }
.clist { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.c { font-size: 13.5px; line-height: 1.45; }
.c .h { display: flex; gap: 8px; align-items: baseline; font: 11px var(--mono); color: var(--muted); }
.c .h b { font-weight: 400; color: var(--text); }
.c .h.g b { color: var(--accent); }
.c .h button { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0; font: 11px var(--mono); }
.c p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.c .att { display: block; margin-top: 6px; max-width: 160px; border-radius: 4px; cursor: zoom-in; }
.clist .none { color: var(--muted); font-size: 13px; }
.composer { display: flex; gap: 6px; align-items: flex-end; }
textarea { flex: 1; border: 0; border-radius: 8px; background: var(--surface); padding: 8px 10px; font: 14px/1.4 var(--sans); color: var(--text); resize: vertical; outline: none; min-height: 40px; width: 100%; }
.drop { margin-top: 18px; padding: 14px; border: 1px dashed var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; }
.drop p { margin: 0; color: var(--muted); font-size: 13px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .btn { align-self: flex-start; }

/* лоток сравнения */
.tray { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--paper); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.14); z-index: 20; }
.tray-items { display: flex; gap: 6px; }
.tray-items img { height: 54px; border-radius: 4px; display: block; cursor: pointer; }

/* оверлеи */
.overlay { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; flex-direction: column; }
.ov-head { height: 52px; flex: none; display: flex; align-items: center; padding: 0 60px 0 18px; border-bottom: 1px solid var(--border); position: relative; }
.ov-head .x { top: 10px; }
.cmp-cols { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 16px; padding: 16px 18px; overflow: auto; }
.cmp-col { min-width: 0; }
.cmp-col .pic { background: var(--surface); border-radius: 6px; height: 62vh; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: zoom-in; }
.cmp-col .pic img, .cmp-col .pic video { max-width: 100%; max-height: 100%; display: block; }
.cmp-col h3 { margin: 8px 0 4px; font: 12px var(--mono); font-weight: 400; overflow-wrap: anywhere; }
.cmp-col .heart { border: 0; background: var(--surface); border-radius: 6px; padding: 3px 8px; font-size: 12px; float: right; margin-top: 4px; }
.cmp-col .heart.on { background: var(--accent); color: #fff; }
.diff { position: relative; }
.diff::before { content: ""; position: absolute; left: -10px; top: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cmp-col .params, .cmp-col .txt { padding-left: 10px; }
.cmp-col u { text-decoration: none; background: var(--accent-soft); }

.feed-list { flex: 1; overflow-y: auto; padding: 8px 18px 60px; max-width: 860px; width: 100%; margin: 0 auto; }
.ev { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.ev:hover { background: var(--surface); }
.ev .w { font: 11px var(--mono); color: var(--muted); padding-top: 2px; }
.ev .p { font: 10.5px var(--mono); color: var(--muted); }
.ev .s { font-size: 14px; }
.ev .s b { font-weight: 500; }
.ev .thumbs { display: flex; gap: 4px; margin-top: 6px; }
.ev .thumbs img { height: 64px; border-radius: 4px; }
.ev blockquote { margin: 4px 0 0; padding: 0; font-size: 13.5px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }

.acc { flex: 1; overflow-y: auto; padding: 18px; max-width: 860px; width: 100%; margin: 0 auto; }
.acc .lead { color: var(--muted); margin: 0 0 18px; }
.acc-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: center; }
.acc-row > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.share-item { display: flex; gap: 8px; align-items: center; width: 100%; font: 12px var(--mono); }
.share-item span { flex: 1; overflow-wrap: anywhere; }
.log { font: 11px var(--mono); white-space: pre-wrap; background: var(--surface); padding: 10px; border-radius: 8px; color: var(--muted); }
.on-dot::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

/* просмотр */
.viewer { position: fixed; inset: 0; background: #121314; z-index: 50; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.viewer img, .viewer video { max-width: 100%; max-height: calc(100% - 52px); display: block; margin-bottom: 52px; user-select: none; -webkit-user-drag: none; }
.v-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 52px; padding-bottom: env(safe-area-inset-bottom); display: flex; align-items: center; gap: 10px; padding: 0 18px; color: #c9cccd; font: 12px var(--mono); }
.v-bar .num { color: #fff; }
.v-bar .v-keys { margin-left: auto; color: #7e8587; }
.v-bar .btn { padding: 5px 10px; font-size: 12px; background: #2a2c2e; color: #e6e8e9; }
.v-bar .btn.on { background: var(--accent); color: #fff; }
.viewer .x { z-index: 2; }
.v-info { position: absolute; right: 0; top: 0; bottom: 52px; width: 380px; overflow-y: auto; background: var(--paper); padding: 16px 18px; }

.toast { position: fixed; left: 50%; top: 64px; transform: translate(-50%, -10px); background: var(--text); color: var(--paper); padding: 8px 14px; border-radius: 8px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 120; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* сенсорные экраны: кнопки на плитках видны всегда */
@media (hover: none) {
  .tile .plus { opacity: .9; }
  body:not(.guest) .tile .heart { opacity: .9; }
}

/* телефон */
@media (max-width: 820px) {
  :root { --top: 50px; }
  body { font-size: 15px; }
  .only-m { display: inline-flex !important; }
  .hide-m { display: none !important; }
  .top { padding: 0 10px; gap: 8px; padding-top: env(safe-area-inset-top); }
  .top-r .btn { padding: 7px 10px; }
  .sets { position: fixed; z-index: 30; top: var(--top); bottom: 0; left: 0; width: min(86vw, 340px); transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: 0 0 40px rgba(0,0,0,.18); }
  body.drawer .sets { transform: none; }
  body.drawer .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 29; background: rgba(20,22,23,.3); }
  .set { padding: 11px 18px; }
  .main { padding: 0 12px 110px; }
  .set-head { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 0 10px; }
  .set-title h1 { font-size: 19px; white-space: normal; }
  .set-tools { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .set-tools::-webkit-scrollbar { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px 8px; }
  .panel { position: fixed; inset: var(--top) 0 0 0; width: auto; z-index: 35; border: 0; padding: 12px 14px calc(40px + env(safe-area-inset-bottom)); }
  .insp-img { margin-top: 34px; }
  .insp-img img, .insp-img video { max-height: 60vh; }
  .composer { flex-direction: column; align-items: stretch; }
  .composer .btn { justify-content: center; height: 40px; }
  textarea { font-size: 16px; }
  .cmp-cols { grid-auto-columns: 78vw; padding: 12px; }
  .cmp-col .pic { height: 55vh; }
  .ev { grid-template-columns: 1fr; gap: 2px; }
  .acc-row { grid-template-columns: 1fr; gap: 6px; }
  .v-info { width: auto; left: 0; top: 40%; }
  .tray { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .tray-items img { height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
