/* Nano Studio в белой дизайн-системе из КП «Зуммервунд»: Inter Tight, белый + серые карточки,
   оранжевый акцент #F05A00, тёмные и серые «таблетки», заголовки строчными с плотным трекингом */

:root {
  --bg: #FFFFFF;
  --surface: #F2F2F2;       /* карточки и подложки */
  --surface2: #E8E8E8;      /* наведение по серому */
  --line: #E3E3E3;
  --dash: #BDBDBD;          /* пунктир «место под …» */
  --text: #111111;
  --body: #4A4A4A;
  --muted: #6B6B6B;
  --accent: #F05A00;
  --accent-hover: #D94F00;
  --ink: #111111;           /* тёмная таблетка */
  --danger: #C2410C;
  --r-card: 20px;
  --r-inner: 14px;
  --r-btn: 12px;
  --pill: 999px;
  --top: 64px;
  --ease: cubic-bezier(.22,.61,.36,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 'Inter Tight', -apple-system, 'Segoe UI', Arial, sans-serif;
  letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
h2 { font-size: 22px; }
code { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: 12px; letter-spacing: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: -0.01em; }
.small { font-size: 13px; }
::selection { background: rgba(240,90,0,.18); }

/* Шапка */
.top { position: sticky; top: 0; z-index: 5; height: var(--top); display: flex; align-items: center; gap: 28px;
  padding: 0 clamp(16px, 3vw, 40px); background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; letter-spacing: -0.04em; white-space: nowrap; }
.logo { width: 28px; height: auto; flex: none; transition: transform .35s var(--ease); }
.brand:hover .logo { transform: rotate(7deg); }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav button { background: none; border: 0; color: var(--muted); padding: 7px 14px; border-radius: var(--pill); font-weight: 500; font-size: 15px;
  white-space: nowrap; transition: background .18s ease, color .18s ease; }
nav button:hover { color: var(--text); background: var(--surface); }
nav button.active { color: #fff; background: var(--ink); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.spend { color: var(--muted); font-size: 13px; white-space: nowrap; background: var(--surface); padding: 6px 12px; border-radius: var(--pill); }

/* Формы */
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 12px; font-weight: 600; display: block; }
textarea, input:not([type=range]):not([type=checkbox]), select {
  width: 100%; background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-btn); padding: 11px 13px; font: inherit; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea::placeholder, input::placeholder { color: #9A9A9A; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
textarea:focus, input:focus, select:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(17,17,17,.06); }
input[type=range] { width: 100%; accent-color: var(--accent); }
button, .btn { font: inherit; letter-spacing: -0.01em; cursor: pointer; border-radius: var(--pill); padding: 10px 18px;
  text-decoration: none; text-align: center; display: inline-block; }
.primary { background: var(--accent); color: #fff; border: 0; font-weight: 600; transition: background .18s ease, transform .18s ease; }
.primary:hover { background: var(--accent-hover); }
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .5; cursor: wait; }
.ghost { background: var(--surface); color: var(--text); border: 0; font-weight: 500; transition: background .18s ease; }
.ghost:hover { background: var(--surface2); }
.ghost.icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.danger { color: var(--danger); }
.go { margin-top: 16px; padding: 16px; font-size: 17px; width: 100%; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 0; background: #fff; color: var(--text); border-radius: var(--pill); padding: 6px 13px; font-size: 13px; font-weight: 500; transition: background .18s ease; }
.chip:hover { background: var(--surface2); }
.chip.active { background: var(--ink); color: #fff; }
.row { display: flex; gap: 10px; align-items: center; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; margin-top: 6px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #fff; border-radius: var(--pill); padding: 4px; gap: 4px; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 4px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: color .18s ease, background .18s ease; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--accent); color: #fff; font-weight: 600; }
details.more summary { color: var(--muted); cursor: pointer; margin-top: 12px; font-size: 13px; font-weight: 500; }
details.more input { margin-top: 6px; }
.banner { background: #fff; border-radius: var(--r-inner); padding: 10px 12px; font-size: 13px; font-weight: 500; display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.banner button { margin-left: auto; padding: 4px 12px; }

/* Главная */
.page { min-height: calc(100vh - var(--top)); }
#page-explore, #page-library { padding: 0 clamp(16px, 5.5vw, 80px) 56px; max-width: 1600px; margin: 0 auto; }
.hero { padding: clamp(48px, 9vh, 110px) 0 clamp(28px, 5vh, 56px); max-width: 1180px; }
.hero h1 { font-size: clamp(42px, 6.4vw, 100px); line-height: 1.02; letter-spacing: -0.045em; }
.hero h1 span { color: var(--accent); }
.hero p { margin: 22px 0 28px; font-size: clamp(17px, 1.45vw, 22px); line-height: 1.45; color: var(--muted); max-width: 680px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-actions button { padding: 18px 32px; font-size: 18px; min-width: 220px; }
.hero-actions .ghost { background: var(--ink); color: #fff; }
.hero-actions .ghost:hover { background: #2a2a2a; }
.shelf { margin-top: 44px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.shelf-head h2 { font-size: clamp(28px, 3vw, 48px); text-transform: lowercase; letter-spacing: -0.045em; }
.shelf-head .muted { background: var(--surface); padding: 4px 12px; border-radius: var(--pill); font-size: 13px; }
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: 230px; gap: 16px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--dash) transparent; }
.pcard { position: relative; border-radius: var(--r-card); overflow: hidden; background: var(--surface); cursor: pointer; scroll-snap-align: start;
  border: 0; padding: 8px; color: var(--text); text-align: left; font: inherit; display: block; width: 100%;
  transition: background .18s ease, transform .25s var(--ease); }
.pcard:hover { background: var(--surface2); transform: translateY(-2px); }
.pcard .thumb { aspect-ratio: 3/4; position: relative; overflow: hidden; border-radius: var(--r-inner); background: #fff; }
.pcard .thumb img, .pcard .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s var(--ease); }
.pcard:hover .thumb img, .pcard:hover .thumb video { transform: scale(1.04); }
.pcard .ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 96px; font-weight: 700; letter-spacing: -0.06em; color: rgba(17,17,17,.1);
  border: 2px dashed var(--dash); border-radius: var(--r-inner); text-transform: lowercase; }
.pcard .info { padding: 10px 6px 4px; }
.pcard .info b { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.pcard .info small { color: var(--muted); font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .badge { position: absolute; top: 10px; left: 10px; background: #fff; color: var(--muted); padding: 3px 10px; border-radius: var(--pill); font-size: 11px; font-weight: 500; }
.pcard.active { background: var(--accent); color: #fff; }
.pcard.active .info small { color: rgba(255,255,255,.85); }

/* Студия */
.studio { display: grid; grid-template-columns: 390px 1fr; gap: 16px; height: calc(100vh - var(--top)); padding: 16px; }
.panel { background: var(--surface); border-radius: var(--r-card); padding: 18px 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; scrollbar-color: var(--dash) transparent; }
.panel h2 { font-size: 30px; text-transform: lowercase; }
.panel h2 + p { margin: 6px 0 8px; color: var(--muted); }
.feed { overflow-y: auto; padding: 4px 4px 48px; }
.preset-pick { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r-inner); padding: 8px; cursor: pointer; transition: box-shadow .18s ease; }
.preset-pick:hover { box-shadow: 0 0 0 1px var(--dash); }
.preset-pick .pthumb { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex: none; background: var(--surface); display: grid; place-items: center; font-weight: 600; font-size: 22px; color: var(--muted); }
.preset-pick .pthumb img, .preset-pick .pthumb video { width: 100%; height: 100%; object-fit: cover; }
.preset-pick b { display: block; font-size: 14px; font-weight: 600; }
.preset-pick small { color: var(--muted); }
.preset-pick .x { margin-left: auto; padding: 0; width: 28px; height: 28px; border-radius: 50%; }

.slot { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; background: #fff; border: 2px dashed var(--dash); border-radius: var(--r-inner); padding: 6px; transition: border-color .18s ease; }
.slot.over { border-color: var(--accent); }
.slot .ref { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
.slot .ref img { width: 100%; height: 100%; object-fit: cover; }
.slot .ref button { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 0; background: rgba(17,17,17,.75); color: #fff; font-size: 11px; }
.slot .add { aspect-ratio: 1; border: 0; background: var(--surface); color: var(--muted); font-size: 24px; font-weight: 300; padding: 0; border-radius: 10px; transition: color .18s ease, background .18s ease; }
.slot .add:hover { color: var(--text); background: var(--surface2); }

/* Лента */
.grid { columns: 4 240px; column-gap: 16px; }
.grid.wide { columns: 5 220px; margin-top: 20px; }
.tile { break-inside: avoid; margin-bottom: 16px; border-radius: var(--r-card); overflow: hidden; background: var(--surface); position: relative; cursor: zoom-in; }
.tile img, .tile video { width: 100%; display: block; }
.tile .cap { position: absolute; inset: auto 0 0 0; padding: 30px 14px 12px; font-size: 13px; font-weight: 500; color: #fff; background: linear-gradient(transparent, rgba(17,17,17,.82)); opacity: 0; transition: opacity .18s ease; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile:hover .cap { opacity: 1; }
.tile .kind { position: absolute; top: 10px; left: 10px; background: #fff; color: var(--text); border-radius: var(--pill); padding: 3px 10px; font-size: 11px; font-weight: 600; }
.tile .fav { position: absolute; top: 10px; right: 12px; color: var(--accent); }
.tile.loading { aspect-ratio: var(--ar, 1); cursor: default; background: linear-gradient(110deg, var(--surface) 30%, #fafafa 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 12px; white-space: pre-line; }
.tile.error { aspect-ratio: var(--ar, 1); cursor: default; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 18px; font-size: 13px; color: var(--body); }
.tile.error b { color: var(--danger); }
.tile.error .row button { padding: 5px 12px; font-size: 12px; background: #fff; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.empty { color: var(--muted); text-align: center; padding: 80px 20px; column-span: all; border: 2px dashed var(--dash); border-radius: var(--r-card); }

.list { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.aitem { background: var(--surface); border-radius: var(--r-card); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.aitem .top-line { display: flex; gap: 8px; align-items: center; }
.aitem .top-line b { font-size: 12px; font-weight: 600; background: var(--ink); color: #fff; padding: 3px 10px; border-radius: var(--pill); }
.aitem .top-line span { font-size: 13px; color: var(--muted); }
.aitem .top-line .actions { margin-left: auto; display: flex; gap: 6px; }
.aitem .top-line .actions > * { padding: 5px 12px; font-size: 12px; background: #fff; }
.aitem p { margin: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--body); }
.aitem audio { width: 100%; }
.aitem.loading { color: var(--muted); }
.aitem.error { color: var(--danger); }

/* Персонажи */
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.char { background: var(--surface); border-radius: var(--r-card); overflow: hidden; padding: 8px; }
.char .photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: var(--r-inner); overflow: hidden; }
.char .photos img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.char .body { padding: 12px 8px 6px; display: flex; flex-direction: column; gap: 8px; }
.char .body b { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; }
.char .body small { color: var(--muted); }
.char .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.char .actions button { padding: 6px 12px; font-size: 13px; }
.char .actions .ghost { background: #fff; }

.lib-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: clamp(28px, 5vh, 56px); }
.lib-head h1 { font-size: clamp(40px, 5vw, 80px); text-transform: lowercase; letter-spacing: -0.05em; }
.lib-head .chip { background: var(--surface); }
.lib-head .chip.active { background: var(--ink); }

/* Модалки */
.modal { position: fixed; inset: 0; background: rgba(17,17,17,.42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 10; padding: 20px; }
.card { background: #fff; border-radius: 28px; padding: 32px; width: min(500px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.18); }
.card h2 { font-size: 32px; text-transform: lowercase; }
.card p { margin: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.col { flex-direction: column; }
.sheet { background: #fff; border-radius: 28px; padding: 24px; width: min(1120px, 100%); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.18); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 36px; text-transform: lowercase; }
.sheet .shelf { margin-top: 20px; }
.sheet .shelf-head h2 { font-size: 24px; }
.sheet .shelf-row { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); grid-auto-columns: unset; overflow: visible; }
.viewer { position: relative; display: grid; grid-template-columns: 1fr 340px; gap: 22px; max-width: 1320px; width: 100%; max-height: 92vh; background: #fff; border-radius: 28px; padding: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.18); }
.viewer-media { display: grid; place-items: center; min-height: 200px; background: var(--surface); border-radius: var(--r-card); }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: calc(92vh - 36px); object-fit: contain; border-radius: var(--r-inner); }
.viewer-media audio { width: 90%; }
.viewer-side { display: flex; flex-direction: column; gap: 16px; padding-top: 40px; overflow-y: auto; }
.viewer-prompt { white-space: pre-wrap; margin: 0; max-height: 30vh; overflow-y: auto; font-size: 17px; line-height: 1.45; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.meta span { background: var(--surface); border-radius: var(--pill); padding: 4px 11px; font-size: 12px; color: var(--muted); }
.viewer .actions button, .viewer .actions .btn { text-align: left; border-radius: var(--r-btn); }
.close { position: absolute; top: 16px; right: 16px; }
.inpaint-wrap { display: grid; place-items: center; background: var(--surface); border-radius: var(--r-card); padding: 10px; }
#inpaintCanvas { max-width: 100%; max-height: 60vh; cursor: crosshair; border-radius: 10px; touch-action: none; }
.inpaint-controls { justify-content: space-between; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 500; padding: 12px 20px; border-radius: var(--pill); z-index: 20; max-width: 90vw; box-shadow: 0 12px 34px rgba(0,0,0,.2); }
.toast.err { background: #fff; color: var(--danger); box-shadow: 0 0 0 1px var(--line), 0 12px 34px rgba(0,0,0,.12); border-radius: var(--r-btn); }

@media (max-width: 860px) {
  .top { gap: 12px; }
  .brand span, .spend { display: none; }
  .studio { grid-template-columns: 1fr; height: auto; padding: 12px; }
  .viewer { grid-template-columns: 1fr; overflow-y: auto; }
  .viewer-side { padding-top: 0; }
  .hero-actions button { flex: 1; min-width: 0; padding: 16px 10px; font-size: 16px; white-space: nowrap; }
}
