/* «Новости» (news.js): the in-app feed as cards, an editor with a live
   preview of the app's feed and detail screen. Brand tokens only — seasonal
   moods recolour it through the same variables; the phone mock uses the app's
   own fixed colours (it shows the app, not the panel). */

.nw-head { align-items: flex-end; flex-wrap: wrap; }
.nw-lead { color: var(--subtle); margin-top: 6px; font-size: 14px; max-width: 68ch; }
.nw-loading { color: var(--subtle); padding: 40px 0; text-align: center; }
.nw-legacy {
  background: var(--amber-weak); color: var(--ink); border-radius: var(--r-md);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.45;
}
.nw-mini { font-size: 12.5px; color: var(--subtle); line-height: 1.45; }
.nw-spacer { flex: 1; }

/* KPI strip — same rhythm as «Рассылка» */
.nw-kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg); overflow: hidden;
}
.nw-kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0;
  background: transparent; padding: 14px 16px;
  box-shadow: inset -1px 0 0 var(--divider), inset 0 -1px 0 var(--divider);
}
.nw-kpi-ic { display: none; }
.nw-kpi > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nw-kpi b {
  font-family: var(--font-ui); font-weight: 700; font-size: 26px; letter-spacing: -0.03em; line-height: 1;
  font-variant-numeric: tabular-nums lining-nums; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.nw-kpi span { font-size: 13px; font-weight: 500; color: var(--ink-2); line-height: 1.35; }

/* Toolbar */
.nw-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.nw-filter button b { font-weight: 600; color: var(--subtle); font-variant-numeric: tabular-nums; }
.nw-filter button.active b { color: var(--accent-ink); }
.nw-search {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 280px;
  background: var(--surface); border: 1px solid var(--field-border); border-radius: var(--r-md); padding: 0 10px;
}
.nw-search svg { width: 16px; height: 16px; fill: none; stroke: var(--subtle); stroke-width: 1.8; flex: none; }
.nw-search input { border: none; background: none; outline: none; padding: 8px 0; width: 100%; min-width: 0; color: var(--ink); }

/* Cards */
.nw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.nw-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-xl); overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.nw-card:hover { border-color: var(--field-border); }
.nw-card.is-pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.nw-card.is-draft .nw-cover img, .nw-card.is-draft .nw-ph { filter: grayscale(.55) opacity(.8); }
.nw-card.is-off .nw-cover img, .nw-card.is-off .nw-ph { filter: grayscale(.35) opacity(.88); }

.nw-cover {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 7.5; padding: 0; border: 0;
  background: var(--paper-2); cursor: pointer; overflow: hidden;
}
.nw-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.nw-card:hover .nw-cover img { transform: scale(1.03); }
.nw-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.nw-pill {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill);
  /* Fixed colours: the pill sits on a photo, not on the themed paper. */
  background: rgba(255, 253, 248, .92); color: #2b3655; backdrop-filter: blur(6px);
  box-shadow: 0 1px 3px rgba(43, 54, 85, .15);
}
.nw-pill.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: 1px; }
.nw-pill.draft { background: rgba(43, 54, 85, .82); color: #fff; }
.nw-pill.pin { background: var(--accent); color: #fff; }
.nw-pill.soon::before { content: "🗓"; margin-right: 5px; }
.nw-pill.ended { background: rgba(43, 54, 85, .62); color: #fff; }

/* Generated cover for items without a photo */
.nw-ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background:
    radial-gradient(90% 120% at 85% 0%, rgba(255,255,255,.45), transparent 55%),
    linear-gradient(135deg, var(--c1), var(--c2));
}
.nw-ph span { font-size: 34px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.15)); }
.nw-ph.big span { font-size: 46px; }

.nw-card-body { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.nw-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--subtle); }
.nw-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  background: var(--paper-2); border: 1px solid var(--stroke); border-radius: var(--r-pill);
  padding: 1px 8px; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nw-title {
  margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--ink); word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nw-text {
  margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); white-space: pre-line; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.nw-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: auto; padding-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.nw-stat b { font-variant-numeric: tabular-nums; }
.nw-stat.plan { color: var(--blue); }
.nw-stat.muted { color: var(--subtle); }

.nw-actions {
  display: flex; align-items: center; gap: 8px; margin-top: auto;
  min-height: 52px; padding: 10px 12px;
  border-top: 1px solid var(--divider);
}
.nw-actions .btn-small,
.nw-actions .btn-icon {
  height: 32px; min-height: 32px; box-sizing: border-box;
}
.nw-actions .btn-small {
  padding: 0 12px; line-height: 1; font-size: 13px;
}
.nw-actions .btn-icon { width: 32px; height: 32px; }
.nw-actions .btn-icon.nw-ic.on { color: var(--accent-ink); background: var(--accent-weak); }
.nw-actions .btn-icon.nw-ic.danger:hover { color: var(--red); background: var(--red-weak); }

.nw-empty {
  background: var(--surface); border: 1px dashed var(--field-border); border-radius: var(--r-xl);
  padding: 42px 20px; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.nw-empty p { max-width: 46ch; line-height: 1.5; }
.nw-empty-ic { font-size: 38px; }

/* ── Editor (modal size xl) ── */
.modal.xl { width: 1000px; }
.nw-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.nw-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.nw-form .field { margin: 0; }
.nw-counter { float: right; font-weight: 500; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.nw-counter.warn { color: var(--amber); }
.nw-form textarea { resize: vertical; min-height: 140px; line-height: 1.5; }

.nw-drop {
  position: relative; border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
  border: 1.5px dashed var(--field-border); background: var(--paper-2);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.nw-drop.has { border-style: solid; border-color: var(--stroke); }
.nw-drop.over { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-weak); }
.nw-drop-img { aspect-ratio: 16 / 6.5; }
.nw-drop-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nw-drop:not(.has) .nw-drop-img .nw-ph { opacity: .55; }
.nw-drop-tools {
  position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(255, 253, 248, .9); backdrop-filter: blur(8px); border-radius: var(--r-md); padding: 6px 8px 6px 12px;
  box-shadow: 0 2px 10px rgba(43, 54, 85, .12);
}
.nw-drop-hint { font-size: 12.5px; color: #4a5473; margin-right: auto; }
.nw-form > .nw-mini { margin-top: -6px; }
.nw-seg { flex-wrap: wrap; }
.nw-form .seg + div { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }

/* Toggle switch */
.nw-switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px 14px; border-radius: var(--r-md); background: var(--paper-2); }
.nw-switch input { position: absolute; opacity: 0; pointer-events: none; }
.nw-switch > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.nw-switch b { font-weight: 600; color: var(--ink); }
.nw-switch-ui {
  flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--field-border); position: relative; margin-top: 1px;
  transition: background .15s ease;
}
.nw-switch-ui::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s ease;
}
.nw-switch input:checked + .nw-switch-ui { background: var(--accent); }
.nw-switch input:checked + .nw-switch-ui::after { transform: translateX(16px); }
.nw-switch input:focus-visible + .nw-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.nw-ed-actions { display: flex; align-items: center; gap: 10px; padding-top: 6px; border-top: 1px solid var(--divider); margin-top: 2px; padding-top: 14px; }
.modal-body .nw-ed-actions .btn-primary { margin-top: 0; }

/* After-publish prompt */
.nw-after { display: flex; flex-direction: column; gap: 14px; }
.nw-after p { color: var(--ink-2); line-height: 1.5; }
.nw-after-card { display: flex; gap: 12px; align-items: center; background: var(--paper-2); border-radius: var(--r-lg); padding: 10px; }
.nw-after-card > img, .nw-after-card > .nw-ph { width: 92px; height: 62px; border-radius: var(--r-md); object-fit: cover; flex: none; overflow: hidden; }
.nw-after-card > .nw-ph span { font-size: 24px; }
.nw-after-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nw-after-card span { font-size: 13px; color: var(--subtle); }
.modal-body .nw-after .btn-primary { margin-top: 0; }

/* ── Phone preview: the app's News sheet ── */
.nw-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.nw-pv-note { text-align: center; max-width: 30ch; }
.nw-phone {
  width: 300px; max-width: 100%; aspect-ratio: 300 / 610;
  border-radius: 46px; padding: 10px; background: #1b1e27;
  box-shadow: 0 0 0 2px #3a3f4d inset, 0 30px 60px -28px rgba(20, 24, 40, .55);
}
.nw-ph-screen {
  position: relative; height: 100%; border-radius: 37px; overflow: hidden;
  background: #ede6d9; color: #2e3a5c; display: flex; flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", var(--font-ui);
}
.nw-ph-island { position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 88px; height: 25px; background: #0b0c10; border-radius: 20px; z-index: 2; }
.nw-ph-status { display: flex; justify-content: space-between; padding: 12px 22px 0; font-size: 12px; font-weight: 600; min-height: 34px; color: #111; }
.nw-ph-icons { letter-spacing: 2px; font-size: 9px; }
.nw-ph-grab { width: 34px; height: 4px; border-radius: 2px; background: rgba(46, 58, 92, .25); margin: 4px auto 0; flex: none; }
.nw-ph-scroll { flex: 1; overflow: hidden; padding: 0 14px 14px; display: flex; flex-direction: column; gap: 9px; }
.nw-ph-head { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.01em; margin: 14px 0 3px; color: #2e3a5c; }
.nw-ph-card { background: #fff; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; flex: none; }
.nw-ph-card.mine { box-shadow: 0 0 0 2px #ed7d4d, 0 8px 20px -12px rgba(237, 125, 77, .7); animation: nw-pop .25s ease; }
.nw-ph-card.ghost { opacity: .55; }
.nw-ph-img { height: 108px; border-radius: 10px; overflow: hidden; background: #ede6d9; }
.nw-ph-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nw-ph-row { display: flex; align-items: flex-start; gap: 6px; }
.nw-ph-t { font-weight: 700; font-size: 12.5px; line-height: 1.25; flex: 1; min-width: 0; word-break: break-word; }
.nw-ph-t.empty, .nw-ph-h1.empty { color: rgba(46, 58, 92, .35); }
.nw-ph-d { font-size: 9.5px; font-weight: 500; color: #79809b; white-space: nowrap; padding-top: 2px; }
.nw-ph-b {
  font-size: 11px; line-height: 1.35; color: #79809b; white-space: pre-line; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nw-ph-link { font-size: 10.5px; font-weight: 600; color: #ed7d4d; }
.nw-ph-link span { font-size: 9px; }

.nw-ph-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 2px 12px 8px; font-size: 12px; }
.nw-ph-nav span:first-child { color: #ed7d4d; }
.nw-ph-nav b { font-weight: 600; }
.nw-ph-hero { height: 150px; border-radius: 14px; overflow: hidden; flex: none; margin-top: 4px; }
.nw-ph-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nw-ph-date { font-size: 10px; font-weight: 600; color: #79809b; margin-top: 4px; }
.nw-ph-h1 {
  font-family: -apple-system, "SF Pro Display", var(--font-display); font-weight: 900; font-stretch: condensed;
  font-size: 21px; line-height: 1.08; letter-spacing: -0.01em; word-break: break-word;
}
.nw-ph-full { font-size: 11.5px; line-height: 1.45; color: rgba(46, 58, 92, .85); white-space: pre-line; word-break: break-word; }
.nw-ph-cta {
  margin-top: 4px; flex: none; height: 38px; border-radius: 12px; display: grid; place-items: center; grid-auto-flow: column; gap: 6px;
  background: linear-gradient(135deg, #f09b7c, #ed7d4d 55%, #e85c68); color: #fff; font-weight: 700; font-size: 12px;
}
@keyframes nw-pop { from { transform: translateY(4px); opacity: .6; } to { transform: none; opacity: 1; } }

@media (max-width: 1180px) {
  .nw-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .nw-editor { grid-template-columns: minmax(0, 1fr); }
  .nw-preview { position: static; order: -1; }
  .nw-phone { width: 250px; }
}
@media (max-width: 640px) {
  .nw-kpi { padding: 10px 12px; }
  .nw-kpi b { font-size: 22px; }
  .nw-search { flex: 1 1 100%; }
  .nw-filter { max-width: 100%; overflow-x: auto; }
  .nw-actions { flex-wrap: wrap; }
  .nw-ed-actions { flex-wrap: wrap; }
  .nw-phone { width: 230px; }
}

/* Show window (0141): two date fields side by side, wrap on phones. */
.nw-window { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nw-date {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  font-size: 13px; font-weight: 600; color: var(--subtle);
}
.nw-date input { width: auto; min-width: 150px; }
