/* ============================================================
   NR SMM — каркас и компоненты (AGENTS.md §11, дизайн-язык NR Analysis).
   Компьютер 1440×900 и телефон 390×844 — та же функциональность (NFR-ST5).
   Наведение — только в @media (hover: hover); цели касания ≥ 44 px; цвета — токенами.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh; }
body { overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
*:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
::selection { background: var(--purple); color: var(--on-accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

#boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 200; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--track); border-top-color: var(--purple); animation: spin .8s linear infinite; }

/* ---------- шапка ---------- */
.top { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 1rem; height: 60px; padding: 0 1.5rem; background: var(--bg); border-bottom: 1px solid var(--border); }
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--heading); font-size: 14px; min-height: 44px; }
.logo-mark { width: 1.9rem; height: 1.9rem; border-radius: .6rem; background: var(--grad); display: inline-flex;
  align-items: center; justify-content: center; color: var(--on-accent); font-size: 12px; font-weight: 800; letter-spacing: 0; }
.top-title { min-width: 0; text-align: center; font-weight: 700; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; }
.main { min-width: 0; }

/* ---------- заголовки ---------- */
.h1-line { font-size: 1.6rem; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; color: var(--heading); margin: 0 0 1.2rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h3-line { font-size: .78rem; text-transform: uppercase; letter-spacing: .13em; font-weight: 700; color: var(--heading); margin: 0 0 .8rem;
  display: flex; align-items: center; gap: .5rem; }
.h3-line::before { content: "/"; color: var(--purple-text); }
.sub-line { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--dim); margin: 1rem 0 .55rem; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-border); border-radius: var(--r-pill); font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  font-size: 11.5px; padding: .72rem 1.25rem; cursor: pointer; min-height: 44px; white-space: nowrap; background-size: 250% 100%;
  transition: transform .3s ease, background .3s ease, color .3s ease; }
@media (hover: hover) { .btn:hover:not(:disabled) { background-image: var(--shimmer); color: var(--on-accent); border-color: transparent;
  animation: shimmer 4.5s ease infinite; transform: translateY(-1px); } }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--dim); border: 1px solid var(--border); letter-spacing: .08em; font-size: 12px; }
@media (hover: hover) { .btn.ghost:hover:not(:disabled) { background: transparent; background-image: none; color: var(--heading);
  border-color: var(--purple); animation: none; transform: none; } }
.btn.danger { background: transparent; color: var(--red-text); border: 1px solid var(--red-line); letter-spacing: .08em; font-size: 12px; }
@media (hover: hover) { .btn.danger:hover:not(:disabled) { background: var(--red-tint); background-image: none; color: var(--red-text); animation: none; transform: none; } }
.btn.small { min-height: 36px; padding: .45rem .85rem; font-size: 11px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ctrl-bg); border: 1px solid var(--ctrl-border); color: var(--dim); cursor: pointer; flex-shrink: 0; font-size: 14px; padding: 0; }
.icon-btn.flat { background: transparent; border-color: transparent; }
.icon-btn.round { background: var(--btn-bg); color: var(--btn-fg); border-color: transparent; }
.icon-btn.send { width: 40px; height: 40px; background: var(--btn-bg); color: var(--btn-fg); border-color: transparent; }
@media (hover: hover) { .icon-btn:hover { color: var(--heading); border-color: var(--purple); } .icon-btn.flat:hover { border-color: transparent; background: var(--hover); }
  .icon-btn.round:hover, .icon-btn.send:hover { color: var(--btn-fg); background-image: var(--grad); } }

/* ---------- карточки, поля, сегменты ---------- */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-card); padding: 1.1rem 1.2rem; min-width: 0; }
.fld { display: flex; flex-direction: column; gap: .35rem; margin-top: .8rem; }
.fld-label { font-size: 12px; font-weight: 600; color: var(--dim); }
.fld-hint { font-size: 11.5px; color: var(--dim); opacity: .85; }
.fld input, .fld textarea, textarea.brief, textarea.brief-out, input.rename, textarea.var-in { width: 100%; background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: var(--r-input); padding: .6rem .75rem; min-height: 44px; color: var(--text); font-size: 14px; resize: vertical; }
.fld textarea, textarea.var-in { font-size: 14px; line-height: 1.5; }
textarea.brief-out { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; min-height: 50vh; }
.fld input::placeholder, textarea::placeholder, input::placeholder { color: var(--placeholder); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--ctrl-bg); border: 1px solid var(--ctrl-border); }
.seg-btn { min-height: 36px; min-width: 44px; padding: 0 .9rem; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--dim);
  font-size: 12.5px; font-weight: 600; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); }
@media (hover: hover) { .seg-btn:hover:not([aria-pressed="true"]) { color: var(--heading); } }
.note { margin: .5rem 0 0; font-size: 12.5px; line-height: 1.45; }
.note.warn { color: var(--orange-text); }
.note.error { color: var(--red-text); }

/* ---------- меню «⋯» ---------- */
.menu { position: absolute; z-index: 90; min-width: 13rem; padding: .35rem; border-radius: var(--r-menu); background: var(--card);
  border: 1px solid var(--border); box-shadow: var(--shadow-pop); animation: rise .18s ease; }
.menu-item { display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 44px; padding: .5rem .7rem; border: 0; border-radius: .6rem;
  background: transparent; color: var(--text); cursor: pointer; text-align: left; font-size: 14px; }
.menu-item i { width: 1.1rem; text-align: center; color: var(--dim); }
.menu-item.danger, .menu-item.danger i { color: var(--red-text); }
@media (hover: hover) { .menu-item:hover { background: var(--hover); } }
.menu-item:focus-visible { outline-offset: -2px; }

/* ---------- окно ---------- */
.dialog-back { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: var(--overlay); animation: rise .18s ease; }
.dialog { width: min(32rem, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 1rem 1.2rem 1.2rem; }
.dialog.wide { width: min(52rem, 100%); }
.dialog:focus { outline: none; }
.dialog-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.dialog-title { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--heading); }
.dialog-body p { margin: .2rem 0 .6rem; color: var(--body2); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---------- сообщения ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px;
  width: min(36rem, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem .7rem 1rem; border-radius: var(--r-item);
  background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 13.5px; box-shadow: var(--shadow-toast); animation: rise .2s ease; }
.toast > span { flex: 1; }
.toast.warn { border-color: var(--orange-line); color: var(--orange-text); }
.toast.error { border-color: var(--red-line); color: var(--red-text); }
.toast .btn { min-height: 36px; }

/* ---------- бросить ролик ---------- */
.drop-veil { position: fixed; inset: 0; z-index: 110; display: none; place-items: center; background: var(--overlay); pointer-events: none; }
body.dragging .drop-veil { display: grid; }
.drop-veil-box { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 2.2rem 3rem; border-radius: var(--r-card);
  border: 2px dashed var(--purple-line); background: var(--card); color: var(--heading); font-weight: 700; }
.drop-veil-box i { font-size: 28px; color: var(--purple-text); }

@media (max-width: 720px) {
  .top { padding: 0 16px; gap: .5rem; height: 56px; }
  .logo-name { display: none; }
  .top-actions .btn.ghost { display: none; }
  .top-actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top-actions .btn { width: 44px; padding: 0; }
}
