/* ═══════════════════════════════════════════════════════════════
   Netfold UI kit · правая панель быстрых настроек (#side-panel)
   Ширина 300 px (токен --nf-panel-w), всё управление ≥ 36 px,
   на тач-экранах ≥ 44 px (см. nf-tokens.css).
   Два варианта раскладки: data-layout="tabs" (A) и "flow" (B).
   ═══════════════════════════════════════════════════════════════ */

.nf-panel {
  width: var(--nf-panel-w); box-sizing: border-box;
  display: flex; flex-direction: column; max-height: calc(100vh - 32px);
  background: var(--nf-panel-bg); color: var(--nf-ink);
  border: var(--nf-panel-bw) solid var(--nf-panel-line); border-radius: var(--nf-panel-r);
  box-shadow: var(--nf-panel-shadow);
  font: 14px/1.4 var(--nf-font-ui);
  overflow: hidden;
}
.nf-panel svg { width: var(--nf-icon); height: var(--nf-icon); flex: none; }
.nf-panel button, .nf-panel input, .nf-panel select, .nf-panel textarea { font: inherit; color: inherit; }
.nf-panel :focus-visible { outline: 2px solid var(--nf-focus); outline-offset: 2px; }

/* ── Шапка: иконка + заголовок ноды + закрыть ── */
.nfp-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.nfp-title {
  flex: 1; min-width: 0; height: 40px; box-sizing: border-box; padding: 0 10px;
  border: 1.5px solid transparent; border-radius: var(--nf-ctl-r); background: transparent;
  font-family: var(--nf-title-font) !important; font-weight: var(--nf-title-weight); font-size: 16px; letter-spacing: -.01em;
}
.nfp-title:hover { background: var(--nf-ctl-bg); }
.nfp-title:focus { background: var(--nf-card); border-color: var(--nf-focus); outline: none; }
.nfp-icon-btn {
  width: var(--nf-ctl-h); height: var(--nf-ctl-h); flex: none; display: grid; place-items: center;
  border: 0; border-radius: var(--nf-ctl-r); background: transparent; cursor: pointer; color: var(--nf-muted);
}
.nfp-icon-btn:hover { background: var(--nf-ctl-bg-hover); color: var(--nf-ink); }
.nfp-emoji { background: var(--nf-ctl-bg); color: var(--nf-ink); font-size: 18px; }

/* ── Вкладки (вариант A) ── */
.nfp-tabs { display: flex; gap: 2px; margin: 0 14px; padding: 3px; border-radius: calc(var(--nf-ctl-r) + 3px); background: var(--nf-ctl-bg); box-shadow: inset 0 0 0 1px var(--nf-ctl-line); }
.nfp-tabs button {
  flex: 1; height: calc(var(--nf-ctl-h) - 4px); border: 0; border-radius: var(--nf-ctl-r); background: transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--nf-muted);
}
.nfp-tabs button:hover { color: var(--nf-ink); }
.nfp-tabs button[aria-selected="true"] { background: var(--nf-card); color: var(--nf-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--nf-line); }
body.theme-netfold .nfp-tabs button[aria-selected="true"] { box-shadow: 0 0 0 1.5px #16181D, 2px 2px 0 1.5px #16181D; }
body.theme-midnight .nfp-tabs button[aria-selected="true"] { background: #1B2440; color: var(--nf-accent); box-shadow: 0 0 0 1px rgba(110,231,255,.45); }

.nfp-body { overflow-y: auto; padding: 6px 14px 16px; overscroll-behavior: contain; scrollbar-width: thin; }
.nfp-pane[hidden] { display: none; }

/* ── Секции ── */
.nfp-sec { padding: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.nfp-sec + .nfp-sec { border-top: 1px solid var(--nf-line); }
.nfp-label {
  margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: var(--nf-label-font); font-size: var(--nf-label-size); font-weight: 600;
  letter-spacing: var(--nf-label-ls); text-transform: var(--nf-label-tt); color: var(--nf-muted);
}
.nfp-label .nfp-link { font: 500 12px var(--nf-font-ui); letter-spacing: 0; text-transform: none; color: var(--nf-accent); background: none; border: 0; cursor: pointer; padding: 4px 0; }
body.theme-netfold .nfp-label .nfp-link { color: #2F45FF; }
body.theme-lagoon .nfp-label .nfp-link { color: #0B6E83; }
body.theme-botanical .nfp-label .nfp-link { color: #2F6B35; }
.nfp-row { display: flex; gap: 6px; align-items: center; }

/* ── Кнопки-инструменты ── */
.nfp-tools { display: flex; gap: 2px; padding: 3px; border-radius: calc(var(--nf-ctl-r) + 3px); background: var(--nf-ctl-bg); box-shadow: inset 0 0 0 1px var(--nf-ctl-line); }
.nfp-tool {
  flex: 1; height: calc(var(--nf-ctl-h) - 4px); min-width: 0; display: grid; place-items: center;
  border: 0; border-radius: var(--nf-ctl-r); background: transparent; cursor: pointer; color: var(--nf-ink);
}
.nfp-tool:hover { background: var(--nf-ctl-bg-hover); }
.nfp-tool[aria-pressed="true"] { background: var(--nf-ctl-on-bg); color: var(--nf-ctl-on-fg); }
.nfp-tools .nfp-gap { width: 1px; margin: 6px 3px; background: var(--nf-line); flex: none; }

/* ── Поля ── */
.nfp-select, .nfp-input, .nfp-stepper {
  height: var(--nf-ctl-h); box-sizing: border-box; border-radius: var(--nf-ctl-r);
  background: var(--nf-ctl-bg); border: 1px solid var(--nf-ctl-line);
}
.nfp-select { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 10px; cursor: pointer; font-weight: 500; }
.nfp-select svg { width: 16px; height: 16px; color: var(--nf-muted); }
.nfp-input { width: 100%; padding: 0 12px; }
.nfp-input::placeholder, .nfp-area::placeholder { color: var(--nf-muted); }
.nfp-area { width: 100%; min-height: 76px; box-sizing: border-box; padding: 10px 12px; resize: vertical; border-radius: var(--nf-ctl-r); background: var(--nf-ctl-bg); border: 1px solid var(--nf-ctl-line); line-height: 1.45; }
.nfp-input:focus, .nfp-area:focus { outline: none; border-color: var(--nf-focus); background: var(--nf-card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nf-focus) 18%, transparent); }
.nfp-stepper { display: inline-flex; align-items: center; flex: none; }
.nfp-stepper button { width: 30px; height: 100%; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--nf-muted); border-radius: var(--nf-ctl-r); }
.nfp-stepper button:hover { color: var(--nf-ink); background: var(--nf-ctl-bg-hover); }
.nfp-stepper svg { width: 14px; height: 14px; }
.nfp-stepper output { min-width: 26px; text-align: center; font: 600 13px var(--nf-font-mono); }

/* ── Сегменты с иконкой и подписью (тип ноды, форма) ── */
.nfp-cards { display: grid; gap: 6px; grid-template-columns: repeat(4, minmax(0,1fr)); }
.nfp-cards.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.nfp-cards.c3 .nfp-card { font-size: 11px; letter-spacing: -.01em; }
.nfp-cards.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.nfp-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 60px; padding: 8px 4px; box-sizing: border-box;
  border: 1.5px solid transparent; border-radius: var(--nf-ctl-r); background: var(--nf-ctl-bg); cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--nf-ink); text-align: center; line-height: 1.15;
}
.nfp-card svg { width: 22px; height: 22px; }
.nfp-card:hover { background: var(--nf-ctl-bg-hover); }
.nfp-card[aria-pressed="true"] { border-color: var(--nf-accent); background: var(--nf-card); color: var(--nf-ink); }
body.theme-netfold .nfp-card[aria-pressed="true"] { border-color: #16181D; box-shadow: 2px 2px 0 #16181D; background: #EEF0FF; }
body.theme-midnight .nfp-card[aria-pressed="true"] { background: rgba(110,231,255,.08); color: var(--nf-accent); }

/* быстрые стили — превью ноды прямо на карточке */
.nfp-style { min-height: 64px; gap: 7px; }
.nfp-style .pv { width: 64px; height: 22px; border-radius: 7px; display: block; }

/* ── Палитры ── */
.nfp-swatches { display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); gap: 6px; }
.nfp-sw {
  aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; cursor: pointer; position: relative;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
body.theme-midnight .nfp-sw { box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.nfp-sw:hover { transform: scale(1.08); }
.nfp-sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--nf-panel-bg), 0 0 0 4px var(--nf-ink); }
.nfp-sw.is-default { background: conic-gradient(var(--nf-n1-bg) 0 50%, var(--nf-n2-bg) 0); }
.nfp-sw.is-default::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(135deg, transparent 46%, var(--nf-muted) 46% 54%, transparent 54%); }
.nfp-sw.is-custom { background: conic-gradient(#ff5d5d, #ffd25d, #5dff8f, #5dd8ff, #8b5dff, #ff5dd2, #ff5d5d); }
.nfp-swatch-btn { display: inline-flex; align-items: center; gap: 6px; }
.nfp-swatch-btn i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }

/* ── Теги ── */
.nfp-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.nfp-tag {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: 999px;
  background: var(--nf-surface-3); font-size: 12.5px; font-weight: 500;
}
.nfp-tag button { width: 22px; height: 22px; border: 0; background: none; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: var(--nf-muted); }
.nfp-tag button svg { width: 12px; height: 12px; }
.nfp-tag-add { position: relative; }
.nfp-tag-add .nfp-input { padding-right: 40px; }
.nfp-tag-add button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: calc(var(--nf-ctl-r) - 2px); background: var(--nf-ctl-on-bg); color: var(--nf-ctl-on-fg); display: grid; place-items: center; cursor: pointer; }
.nfp-tag-add button svg { width: 16px; height: 16px; }

/* ── Кнопки действий ── */
.nfp-btn {
  height: var(--nf-ctl-h); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--nf-ctl-line); border-radius: var(--nf-ctl-r); background: var(--nf-ctl-bg); cursor: pointer; font-weight: 500; font-size: 13px;
}
.nfp-btn:hover { background: var(--nf-ctl-bg-hover); }
.nfp-btn.is-primary { background: var(--nf-ctl-on-bg); color: var(--nf-ctl-on-fg); border-color: transparent; }
.nfp-btn.is-danger { color: #C2271D; background: transparent; border: 1px solid color-mix(in srgb, #C2271D 35%, transparent); width: 100%; }
body.theme-midnight .nfp-btn.is-danger { color: #FF8A80; border-color: rgba(255,138,128,.35); }
.nfp-btn.is-danger:hover { background: color-mix(in srgb, #C2271D 8%, transparent); }
.nfp-btn svg { width: 16px; height: 16px; }
.nfp-grow { flex: 1; }

/* мои палитры */
.nfp-palettes { display: flex; flex-wrap: wrap; gap: 6px; }
.nfp-palette { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px 0 6px; border-radius: var(--nf-ctl-r); background: var(--nf-ctl-bg); border: 1px solid var(--nf-ctl-line); font-size: 12.5px; cursor: pointer; }
.nfp-palette i { width: 20px; height: 20px; border-radius: 6px; background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--bd); }

/* ── Переключатели (свойства) ── */
.nfp-switch { display: flex; align-items: center; gap: 10px; min-height: var(--nf-ctl-h); cursor: pointer; }
.nfp-switch > svg { color: var(--nf-muted); }
.nfp-switch span { flex: 1; }
.nfp-switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--nf-line); position: relative; cursor: pointer; transition: background var(--nf-dur); margin: 0; }
.nfp-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform var(--nf-dur) var(--nf-ease); }
.nfp-switch input:checked { background: var(--nf-ctl-on-bg); }
.nfp-switch input:checked::after { transform: translateX(16px); background: var(--nf-panel-bg); }

/* ── Вариант B: «лента» — одна прокрутка, сворачиваемые разделы ── */
.nf-panel[data-layout="flow"] .nfp-tabs { display: none; }
.nf-panel[data-layout="flow"] .nfp-pane[hidden] { display: block; }
.nfp-group-head { display: none; }
.nf-panel[data-layout="flow"] .nfp-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; margin-top: 4px; padding: 0 2px;
  border: 0; border-top: 1px solid var(--nf-line); background: none; cursor: pointer;
  font-family: var(--nf-title-font); font-weight: var(--nf-title-weight); font-size: 14px; letter-spacing: -.005em;
}
.nf-panel[data-layout="flow"] .nfp-pane:first-child .nfp-group-head { border-top: 0; margin-top: 0; }
.nf-panel[data-layout="flow"] .nfp-group-head svg { width: 16px; height: 16px; color: var(--nf-muted); transition: transform var(--nf-dur); }
.nf-panel[data-layout="flow"] .nfp-pane.is-closed .nfp-group-head svg { transform: rotate(-90deg); }
.nf-panel[data-layout="flow"] .nfp-pane.is-closed > :not(.nfp-group-head) { display: none; }
.nf-panel[data-layout="flow"] .nfp-pane .nfp-sec:first-of-type { border-top: 0; padding-top: 4px; }

/* ── Мобильный (≤ 700 px): панель становится нижним листом ── */
@media (max-width: 700px) {
  .nf-panel { width: 100%; max-height: 70vh; border-radius: var(--nf-panel-r) var(--nf-panel-r) 0 0; border-bottom: 0; box-shadow: 0 -8px 24px rgba(0,0,0,.12); }
  .nfp-head { position: relative; padding-top: 22px; }
  .nfp-head::before { content: ""; position: absolute; left: 50%; top: 8px; width: 36px; height: 4px; border-radius: 2px; background: var(--nf-line); transform: translateX(-50%); }
}
