/* ============================================================
   CONGIX CODE — Всплывающие элементы и общие контролы
   Окна, выпадающие панели, тосты, переключатели, поля ввода.
   Стекло то же, что у карточек-папок (--glass-folder), но на плотной
   подложке: всплывающее окно лежит поверх контента, и сквозь прозрачное
   стекло текст под ним мешал бы читать.
   ============================================================ */

/* ── Затемнение под окном ── */
.ui-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6, 5, 12, 0.62);
}
:root[data-theme="light"] .ui-backdrop { background: rgba(11, 18, 32, 0.35); }

/* ── Окно ── */
.ui-modal {
  position: fixed; z-index: 101;
  top: 50%; left: 50%;
  translate: -50% -50%;
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  border-radius: 36px;
  background:
    radial-gradient(90% 60% at 30% 120%, rgba(109,74,255,0.30) 0%, transparent 70%),
    var(--glass-folder),
    #15131F;
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 40px 120px rgba(0,0,0,0.6);
  color: var(--color-text);
  overflow: hidden;
}
.ui-modal:focus { outline: none; }
.ui-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 26px 28px 8px;
}
.ui-modal-head h3 { margin: 0; font-size: 1.35rem; font-weight: 500; letter-spacing: -0.01em; }
.ui-x {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--glass-folder);
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.85);
  transition: border-color 0.18s, transform 0.18s;
}
.ui-x:hover { border-color: rgba(255,255,255,0.35); transform: rotate(90deg); }
.ui-modal-body { padding: 12px 28px 8px; overflow-y: auto; overscroll-behavior: contain; }
.ui-modal-actions {
  display: flex; justify-content: flex-end; gap: 0.6rem; flex-wrap: wrap;
  padding: 16px 28px 26px;
}
.ui-text { color: rgba(255,255,255,0.72); margin: 0.2rem 0 0.4rem; line-height: 1.55; }

:root[data-theme="light"] .ui-modal {
  background:
    radial-gradient(90% 60% at 30% 120%, rgba(109,74,255,0.12) 0%, transparent 70%),
    #F7F8FC;
  border-color: rgba(11,18,32,0.10);
  box-shadow: 0 40px 120px rgba(11,18,32,0.25);
}
:root[data-theme="light"] .ui-x { background: rgba(11,18,32,0.04); border-color: rgba(11,18,32,0.12); box-shadow: none; color: var(--color-text); }
:root[data-theme="light"] .ui-text { color: var(--color-mid); }

/* ── Кнопки ── */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-weight: 500; font-size: 0.95rem;
  white-space: nowrap;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.ui-btn:active { transform: scale(0.98); }
.ui-btn.primary {
  background: var(--gradient-accent); color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 30px var(--color-accent-glow), inset 0 1px 0 rgba(255,255,255,0.3);
}
.ui-btn.primary:hover { box-shadow: 0 14px 36px var(--color-accent-glow), inset 0 1px 0 rgba(255,255,255,0.3); }
.ui-btn.ghost {
  background: var(--glass-folder);
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
  color: var(--color-text);
}
.ui-btn.ghost:hover { border-color: rgba(255,255,255,0.35); }
.ui-btn.danger {
  background: rgba(248,113,113,0.16);
  border: 1px solid rgba(248,113,113,0.45);
  color: #fecaca;
}
.ui-btn.danger:hover { background: rgba(248,113,113,0.24); }
.ui-btn:disabled { opacity: 0.45; cursor: not-allowed; }
:root[data-theme="light"] .ui-btn.ghost { background: rgba(255,255,255,0.8); border-color: rgba(11,18,32,0.12); box-shadow: none; }
:root[data-theme="light"] .ui-btn.danger { color: #b91c1c; }

/* ── Поля ввода ── */
.ui-field { display: block; margin-bottom: 1rem; }
.ui-field > span, .ui-label { display: block; font-size: 0.85rem; color: rgba(255,255,255,0.55); margin-bottom: 0.45rem; }
.ui-field input, .ui-field textarea, .ui-field select {
  width: 100%;
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--color-text);
  font: inherit; font-size: 16px;   /* меньше 16px — iPhone зумит при фокусе */
  outline: none;
  transition: border-color 0.18s, background 0.18s;
}
.ui-field textarea { min-height: 96px; resize: vertical; }
.ui-field input:focus, .ui-field textarea:focus { border-color: rgba(167,139,250,0.7); background: rgba(255,255,255,0.08); }
.ui-field input[readonly] { color: rgba(255,255,255,0.55); }
.ui-error { min-height: 1.3em; margin: 0.4rem 0 0; color: #fca5a5; font-size: 0.85rem; }
:root[data-theme="light"] .ui-field > span, :root[data-theme="light"] .ui-label { color: var(--color-mid); }
:root[data-theme="light"] .ui-field input, :root[data-theme="light"] .ui-field textarea { background: #fff; border-color: var(--color-border); }

/* ── Переключатель ── */
.ui-switch {
  position: relative; flex-shrink: 0;
  width: 48px; height: 28px; border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.20);
  transition: background 0.2s, border-color 0.2s;
}
.ui-switch i {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.ui-switch[aria-checked="true"] { background: var(--gradient-accent); border-color: transparent; }
.ui-switch[aria-checked="true"] i { transform: translateX(20px); }
:root[data-theme="light"] .ui-switch { background: rgba(11,18,32,0.10); border-color: rgba(11,18,32,0.12); }

/* ── Сегменты (выбор одного из нескольких) ── */
.ui-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
}
.ui-seg button {
  padding: 0.35rem 0.85rem; border-radius: 999px;
  font-size: 0.82rem; color: rgba(255,255,255,0.65);
  transition: background 0.18s, color 0.18s;
}
.ui-seg button[aria-checked="true"] { background: var(--gradient-accent); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.25); }
:root[data-theme="light"] .ui-seg { background: rgba(11,18,32,0.04); border-color: rgba(11,18,32,0.12); }
:root[data-theme="light"] .ui-seg button { color: var(--color-mid); }

/* ── Выпадающая панель ── */
.ui-pop {
  position: fixed; z-index: 95;
  padding: 10px;
  border-radius: 28px;
  background:
    radial-gradient(90% 60% at 30% 120%, rgba(109,74,255,0.26) 0%, transparent 70%),
    var(--glass-folder),
    #15131F;
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 24px 60px rgba(0,0,0,0.55);
  color: var(--color-text);
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
}
:root[data-theme="light"] .ui-pop { background: #F7F8FC; border-color: rgba(11,18,32,0.10); box-shadow: 0 24px 60px rgba(11,18,32,0.18); }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px; }
.pop-head b { font-weight: 500; font-size: 1.02rem; }
.pop-link { font-size: 0.82rem; color: var(--color-accent-text); }
.pop-link:hover { text-decoration: underline; }

/* Уведомления */
.nt-list { display: flex; flex-direction: column; gap: 2px; }
.nt-item {
  position: relative;
  display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start;
  padding: 10px 12px; border-radius: 18px;
  color: inherit; text-decoration: none;
  transition: background 0.15s;
}
.nt-item:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nt-item.unread::after {
  content: ""; position: absolute; top: 16px; right: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #a78bfa; box-shadow: 0 0 8px rgba(167,139,250,0.8);
}
.nt-ic, .rec-ic {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, var(--rec-bg), rgba(255,255,255,0.03));
  border: 1px solid var(--rec-line);
  color: var(--rec-c);
}
.nt-ic.r-red, .rec-ic.r-red   { --rec-c: #f87171; --rec-bg: rgba(248,113,113,0.14); --rec-line: rgba(248,113,113,0.35); }
.nt-ic.r-yel, .rec-ic.r-yel   { --rec-c: #fbbf24; --rec-bg: rgba(251,191,36,0.12);  --rec-line: rgba(251,191,36,0.32); }
.nt-ic.r-blue, .rec-ic.r-blue { --rec-c: #60a5fa; --rec-bg: rgba(96,165,250,0.12);  --rec-line: rgba(96,165,250,0.32); }
.nt-ic.r-green, .rec-ic.r-green { --rec-c: #4ade80; --rec-bg: rgba(74,222,128,0.12); --rec-line: rgba(74,222,128,0.32); }
.nt-ic.r-violet, .rec-ic.r-violet { --rec-c: #a78bfa; --rec-bg: rgba(167,139,250,0.14); --rec-line: rgba(167,139,250,0.38); }
.nt-txt { display: flex; flex-direction: column; gap: 2px; padding-right: 14px; }
.nt-txt b { font-weight: 500; font-size: 0.92rem; }
.nt-txt span { font-size: 0.84rem; color: rgba(255,255,255,0.62); line-height: 1.4; }
.nt-txt time { font-size: 0.75rem; color: rgba(255,255,255,0.4); margin-top: 2px; }
:root[data-theme="light"] .nt-txt span, :root[data-theme="light"] .nt-txt time { color: var(--color-mid); }
:root[data-theme="light"] .nt-item:hover { background: rgba(11,18,32,0.04); }

/* Профиль */
.pf-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.pf-head .ava {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--gradient-accent); color: #fff; font-weight: 700;
}
.pf-head b { display: block; font-weight: 500; }
.pf-head span span { display: block; font-size: 0.8rem; color: rgba(255,255,255,0.55); word-break: break-all; }
.pf-trial {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 8px 8px; padding: 8px 12px;
  border-radius: 14px;
  background: rgba(251,191,36,0.10); border: 1px solid rgba(251,191,36,0.30);
  color: #fcd34d; font-size: 0.82rem;
  text-decoration: none;
}
.pf-trial:hover { text-decoration: none; border-color: rgba(251,191,36,0.5); }
.pf-trial.paid { background: rgba(167,139,250,0.12); border-color: rgba(167,139,250,0.40); color: #ddd6fe; }
:root[data-theme="light"] .pf-trial.paid { color: var(--color-accent-text); }
.pf-menu { display: flex; flex-direction: column; padding: 4px 0; border-top: 1px solid rgba(255,255,255,0.08); border-bottom: 1px solid rgba(255,255,255,0.08); }
.pf-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  color: inherit; font-size: 0.92rem; text-decoration: none;
}
.pf-menu a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.pf-menu a svg, .pf-row span svg, .pf-out svg { color: rgba(255,255,255,0.6); }
.pf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; font-size: 0.92rem; }
.pf-row > span { display: flex; align-items: center; gap: 12px; }
.pf-out {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: 14px;
  color: #fca5a5; font-size: 0.92rem; text-align: left;
  border-top: 1px solid rgba(255,255,255,0.08); margin-top: 4px;
}
.pf-out:hover { background: rgba(248,113,113,0.10); }
.pf-out svg { color: #fca5a5; }
:root[data-theme="light"] .pf-head span span { color: var(--color-mid); }
:root[data-theme="light"] .pf-trial { color: #92400e; }
:root[data-theme="light"] .pf-menu a:hover { background: rgba(11,18,32,0.04); }

/* Поиск */
.sr-pop { padding: 8px; }
.sr-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 16px;
  color: inherit; text-decoration: none;
}
.sr-item:hover, .sr-item.on { background: rgba(255,255,255,0.07); text-decoration: none; }
.sr-ic {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,0.2); color: rgba(255,255,255,0.85);
}
.sr-item b { display: block; font-weight: 400; font-size: 0.92rem; }
.sr-item b mark { background: rgba(167,139,250,0.3); color: #fff; border-radius: 4px; padding: 0 2px; }
.sr-item span span { display: block; font-size: 0.76rem; color: rgba(255,255,255,0.5); }
.sr-empty { padding: 14px; font-size: 0.88rem; color: rgba(255,255,255,0.55); }
:root[data-theme="light"] .sr-item:hover, :root[data-theme="light"] .sr-item.on { background: rgba(11,18,32,0.05); }
:root[data-theme="light"] .sr-item b mark { color: inherit; }
:root[data-theme="light"] .sr-ic { border-color: rgba(11,18,32,0.14); color: var(--color-text); }

/* ── Помощь ── */
.help-faq { display: flex; flex-direction: column; gap: 8px; }
.faq {
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 0 18px;
}
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0; cursor: pointer; list-style: none; font-size: 0.95rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary span { transition: transform 0.25s; color: rgba(255,255,255,0.55); display: flex; }
.faq[open] summary span { transform: rotate(180deg); }
.faq p { margin: 0 0 14px; font-size: 0.88rem; color: rgba(255,255,255,0.65); line-height: 1.55; }
.help-sub { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font-size: 0.9rem; color: rgba(255,255,255,0.6); }
.help-keys { display: flex; flex-direction: column; gap: 8px; }
.help-keys div { display: flex; align-items: center; gap: 14px; font-size: 0.9rem; }
kbd {
  min-width: 110px; text-align: center;
  padding: 0.3rem 0.7rem; border-radius: 10px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18);
  font-family: ui-monospace, monospace; font-size: 0.8rem;
}
:root[data-theme="light"] .faq { background: #fff; border-color: var(--color-border); }
:root[data-theme="light"] .faq p, :root[data-theme="light"] .help-sub { color: var(--color-mid); }

/* ── Новый проект ── */
.np-starts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.np-start {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 16px; border-radius: 24px; text-align: left;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.14);
  transition: border-color 0.18s, background 0.18s;
}
.np-start:hover { border-color: rgba(255,255,255,0.3); }
.np-start[aria-checked="true"] { background: rgba(124,92,255,0.16); border-color: rgba(167,139,250,0.6); }
.np-start b { font-weight: 500; font-size: 0.92rem; }
.np-start span:last-child { font-size: 0.8rem; color: rgba(255,255,255,0.55); line-height: 1.35; }
.np-ic {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.25);
}
@media (max-width: 560px) { .np-starts { grid-template-columns: 1fr; } }
:root[data-theme="light"] .np-start { background: #fff; border-color: var(--color-border); }
:root[data-theme="light"] .np-start span:last-child { color: var(--color-mid); }

/* ── Тосты ── */
.ui-toasts {
  position: fixed; z-index: 120;
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  translate: -50% 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.ui-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  background: var(--glass-folder), #1A1726;
  border: 1px solid rgba(255,255,255,0.20);
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  font-size: 0.9rem; color: var(--color-text);
}
.ui-toast i { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,0.8); }
.ui-toast.err i { background: #f87171; box-shadow: 0 0 8px rgba(248,113,113,0.8); }
.ui-toast.warn i { background: #fbbf24; box-shadow: 0 0 8px rgba(251,191,36,0.8); }
:root[data-theme="light"] .ui-toast { background: #fff; border-color: var(--color-border); box-shadow: 0 14px 40px rgba(11,18,32,0.15); }

/* На телефоне окно прижимается к низу, как лист */
@media (max-width: 680px) {
  /* Над нижним меню, иначе тост прячется за ним */
  .ui-toasts { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 560px) {
  .ui-modal { top: auto; bottom: 8px; translate: -50% 0; border-radius: 30px; }
  .ui-modal-head { padding: 22px 22px 6px; }
  .ui-modal-body { padding: 10px 22px 6px; }
  .ui-modal-actions { padding: 14px 22px calc(22px + env(safe-area-inset-bottom, 0px)); }
  .ui-modal-actions .ui-btn { flex: 1; }
}

/* ============================================================
   Подсказки при наборе кода (js/code-hints.js, CodeMirror show-hint)
   Список всплывает под курсором: название и короткое объяснение.
   Объяснение у выбранного пункта показывается целиком.
   ============================================================ */
.CodeMirror-hints {
  position: absolute;
  z-index: 1000;
  margin: 4px 0 0;
  padding: 6px;
  list-style: none;
  max-width: min(420px, calc(100vw - 24px));
  max-height: 18em;
  overflow-y: auto;
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(36, 32, 54, 0.98), rgba(22, 19, 34, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: var(--font-main);
  font-size: 0.86rem;
  box-sizing: border-box;
}
.CodeMirror-hint {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--color-text);
  cursor: pointer;
  white-space: normal;
}
.cm-hint-label {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 600;
  color: #c4b5fd;
  white-space: pre;
}
.cm-hint-desc {
  color: rgba(228, 235, 245, 0.62);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
li.CodeMirror-hint-active { background: var(--gradient-accent); }
li.CodeMirror-hint-active .cm-hint-label { color: #fff; }
li.CodeMirror-hint-active .cm-hint-desc { color: rgba(255, 255, 255, 0.88); white-space: normal; }

:root[data-theme="light"] .CodeMirror-hints {
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.99), rgba(246, 244, 252, 0.99));
  border-color: rgba(23, 20, 43, 0.12);
  box-shadow: 0 18px 44px rgba(58, 40, 140, 0.16);
}
:root[data-theme="light"] .cm-hint-label { color: #5b3fd6; }
:root[data-theme="light"] .cm-hint-desc { color: #5d5a75; }
:root[data-theme="light"] li.CodeMirror-hint-active .cm-hint-label,
:root[data-theme="light"] li.CodeMirror-hint-active .cm-hint-desc { color: #fff; }
