/* Modal stacking — формы Studio поверх всего IDE */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .75);
    z-index: 1000;
    -webkit-app-region: no-drag;
}
.modal-overlay.open {
    display: flex;
    pointer-events: auto;
}
.modal-window {
    width: min(520px, 92vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-panel);
    border: 1px solid var(--text-main);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 50px #000;
}
.modal-window.wide { width: min(640px, 92vw); }
.api-settings-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .5);
}
.api-settings-window {
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100vh - 84px);
    border-color: #3f4c5d;
    border-radius: 12px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .62);
}
.api-settings-window .modal-header {
    padding: 15px 18px 14px;
    background: linear-gradient(135deg, #151c27, #0d1118);
}
.api-settings-drag-handle { cursor: grab; user-select: none; }
.api-settings-drag-handle:active { cursor: grabbing; }
.api-settings-drag-handle .modal-close { cursor: pointer; }
.api-settings-window h2 { margin: 2px 0 0; font-size: 16px; line-height: 1.2; }
.api-settings-kicker { color: #8ebcff; font: 700 10px/1 var(--font-code); letter-spacing: .12em; }
.api-settings-window .modal-body { padding: 18px; }
.api-settings-intro { margin: 0 0 16px; color: var(--text-dim); font-size: 12px; line-height: 1.45; }
.api-settings-section { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(255,255,255,.025); }
.api-settings-section .release-label { margin: 0; }
.api-settings-window .modal-footer { justify-content: flex-end; }
.api-settings-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.api-settings-actions .btn { min-width: 0; padding-inline: 8px; }
@media (max-width: 560px) {
    .api-settings-window { max-height: calc(100vh - 32px); }
    .api-settings-actions { grid-template-columns: 1fr; }
}
.git-settings-window { width: min(580px, 92vw); }
.git-settings-intro { margin: 0 0 16px; line-height: 1.45; }
.git-settings-window .release-label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.git-settings-window .field { width: 100%; }
#gitSettingsStatus { min-height: 18px; margin: 2px 0 0; }
.account-window { width: min(440px, 92vw); }
.account-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.account-body .release-label { width: 100%; }
.account-avatar { width: 148px; height: 148px; padding: 0; overflow: hidden; border: 2px solid var(--text-main); border-radius: 50%; background: #202b39; color: var(--text-main); cursor: pointer; font-size: 48px; }
.account-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.account-tokens { width: 100%; display: flex; flex-direction: column; gap: 5px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgba(255,255,255,.04); }
.account-tokens__label { font-size: 11px; color: var(--text-dim); }
.new-project-window { width: min(760px, 94vw) !important; }
.tpl-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.tpl-card {
    --tpl-accent: #b9c6d8;
    --tpl-accent-rgb: 185, 198, 216;
    position: relative;
    isolation: isolate;
    min-height: 126px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 3px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid rgba(var(--tpl-accent-rgb), .44);
    border-radius: var(--radius-md);
    background:
        linear-gradient(145deg, rgba(var(--tpl-accent-rgb), .26), transparent 47%),
        radial-gradient(circle at 86% 12%, rgba(var(--tpl-accent-rgb), .52), transparent 28%),
        linear-gradient(135deg, #171d27, #090b0f 72%);
    color: #fff;
    cursor: pointer;
    font: inherit;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 5px 16px rgba(0,0,0,.28);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.tpl-card::before {
    content: '';
    position: absolute;
    z-index: -1;
    width: 110px;
    height: 110px;
    right: -28px;
    top: -38px;
    border: 18px solid rgba(var(--tpl-accent-rgb), .33);
    border-radius: 30px;
    transform: rotate(28deg);
}
.tpl-card__glow { position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg, transparent 33%, rgba(0,0,0,.72)); }
.tpl-card__brand { margin-bottom: auto; color: var(--tpl-accent); font: 900 11px/1 var(--font-code); letter-spacing: .12em; text-shadow: 0 0 18px rgba(var(--tpl-accent-rgb), .82); }
.tpl-card__label { font-size: 15px; font-weight: 800; line-height: 1.15; letter-spacing: .01em; }
.tpl-card__hint { color: rgba(255,255,255,.72); font-size: 10px; font-weight: 600; line-height: 1.25; }
.tpl-card:hover { transform: translateY(-3px); border-color: var(--tpl-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 10px 23px rgba(0,0,0,.42), 0 0 20px rgba(var(--tpl-accent-rgb), .2); }
.tpl-card.active { border-color: #fff; box-shadow: inset 0 0 0 1px var(--tpl-accent), 0 0 0 2px rgba(var(--tpl-accent-rgb), .28), 0 10px 25px rgba(0,0,0,.46); }
.tpl-card:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.tpl-card--flutter { --tpl-accent: #54c5f8; --tpl-accent-rgb: 84, 197, 248; }
.tpl-card--kotlin { --tpl-accent: #c18cff; --tpl-accent-rgb: 193, 140, 255; }
.tpl-card--react { --tpl-accent: #61dafb; --tpl-accent-rgb: 97, 218, 251; }
.tpl-card--go { --tpl-accent: #00add8; --tpl-accent-rgb: 0, 173, 216; }
.tpl-card--java { --tpl-accent: #f89820; --tpl-accent-rgb: 248, 152, 32; }
.tpl-card--python { --tpl-accent: #ffd343; --tpl-accent-rgb: 255, 211, 67; }
.tpl-card--vanilla { --tpl-accent: #ff8a4c; --tpl-accent-rgb: 255, 138, 76; }
.tpl-card--vue { --tpl-accent: #42d392; --tpl-accent-rgb: 66, 211, 146; }
.tpl-card--next { --tpl-accent: #f5f5f5; --tpl-accent-rgb: 245, 245, 245; }
.tpl-card--node { --tpl-accent: #8cc84b; --tpl-accent-rgb: 140, 200, 75; }
.tpl-card--electron { --tpl-accent: #9feaf9; --tpl-accent-rgb: 159, 234, 249; }
.tpl-card--api { --tpl-accent: #ff6b96; --tpl-accent-rgb: 255, 107, 150; }
.tpl-card--mini-apps { --tpl-accent: #2aabee; --tpl-accent-rgb: 42, 171, 238; }
.tpl-card--telegram-bot { --tpl-accent: #54b9eb; --tpl-accent-rgb: 84, 185, 235; }
.tpl-card--max-bot { --tpl-accent: #b38cff; --tpl-accent-rgb: 179, 140, 255; }
.tpl-card--dotnet-desktop { --tpl-accent: #a78bfa; --tpl-accent-rgb: 167, 139, 250; }
@media (max-width: 560px) { .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.modal-overlay .modal-window {
    pointer-events: auto;
    -webkit-app-region: no-drag;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-active);
    font-weight: 700;
}
.modal-close {
    border: none;
    background: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-active);
}
.comp-diagnostics-error { color: #ff8d8d; font-weight: 700; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-row label { display: flex; flex-direction: column; gap: 4px; color: var(--text-dim); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.cal-day-modal.modal-overlay {
    z-index: 1100;
}
#studioFormModal.modal-overlay,
#studioPromptModal.modal-overlay,
#studioConfirmModal.modal-overlay,
#confirmModal.modal-overlay {
    z-index: 10050;
}
.field-invalid {
    border-color: #ff4d4d !important;
    outline: 1px solid #ff4d4d;
}
.studio-form-delete {
    margin-right: auto;
    color: #fff;
    background: #b91c1c;
    border-color: #dc2626;
}
.studio-form-delete:hover { background: #dc2626; }
.registration-window {
    width: min(440px, calc(100vw - 32px));
}
.registration-window .field {
    width: 100%;
    margin-top: 6px;
}
.registration-window .modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

/* Стартовая регистрация — обязательный gate коммерческой поставки. */
#registrationModal {
    z-index: 20000;
}
