:root {
    --bg: #0a0e0c;
    --bg-deep: #06090a;
    --panel: rgba(20, 26, 22, 0.82);
    --panel-strong: rgba(23, 32, 25, 0.94);
    --panel-soft: rgba(17, 22, 19, 0.72);
    --input: rgba(0, 0, 0, 0.18);
    --text: #e8efea;
    --text-soft: #9aa89f;
    --text-dim: #64746a;
    --text-muted: #9aa89f;
    --line: rgba(16, 185, 129, 0.16);
    --line-strong: rgba(16, 185, 129, 0.32);
    --teal: #10b981;
    --teal-strong: #059669;
    --amber: #eab661;
    --amber-soft: rgba(234, 182, 97, 0.12);
    --red: #ff7d7d;
    --red-soft: rgba(255, 125, 125, 0.12);
    --green-soft: rgba(16, 185, 129, 0.1);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 12px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, rgba(16, 185, 129, 0.12), transparent 24%),
        radial-gradient(circle at 85% 18%, rgba(234, 182, 97, 0.14), transparent 22%),
        linear-gradient(180deg, #0a0e0c 0%, #06090a 48%, #050706 100%);
}

.grid-field,
.scanline,
.glow,
.page-noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.grid-field {
    background:
        linear-gradient(rgba(16, 185, 129, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.06) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 90%);
    z-index: -3;
}

.scanline {
    background: linear-gradient(180deg, transparent, rgba(16, 185, 129, 0.045), transparent);
    background-size: 100% 10px;
    opacity: 0.22;
    animation: scan-move 12s linear infinite;
    z-index: -2;
}

@keyframes scan-move {
    from { transform: translateY(-20px); }
    to { transform: translateY(20px); }
}

.glow {
    border-radius: 50%;
    filter: blur(60px);
    z-index: -3;
}

.glow-a {
    inset: auto -60px auto auto;
    width: 360px;
    height: 360px;
    top: -120px;
    background: rgba(5, 150, 105, 0.2);
}

.glow-b {
    inset: auto auto 4% -80px;
    width: 300px;
    height: 300px;
    background: rgba(234, 182, 97, 0.16);
}

.page-noise {
    opacity: 0.05;
    background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.72) 1px, transparent 0);
    background-size: 12px 12px;
    z-index: -1;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(18px);
    background: rgba(4, 15, 16, 0.72);
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

.app-header-inner,
.container {
    width: min(1160px, calc(100vw - 32px));
    margin: 0 auto;
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 0;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-en {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--teal), #a7fff3);
    color: var(--bg-deep);
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 1.16rem;
    font-weight: 700;
    box-shadow: 0 0 28px rgba(16, 185, 129, 0.3);
}

.logo-text {
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    color: var(--text);
}

.header-divider,
.header-tagline {
    color: var(--text-soft);
}

.header-tagline {
    font-size: 0.95rem;
}

.container {
    padding: 28px 0 64px;
}

.header {
    margin: 0 auto 24px;
    padding: 0 20px;
    text-align: center;
}

.header h1 {
    max-width: 66ch;
    margin: 0 auto;
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.65;
    color: var(--text-soft);
}

.stepper {
    position: sticky;
    top: 86px;
    z-index: 24;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
    padding: 12px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(4, 15, 16, 0.78);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    box-shadow: 0 22px 38px rgba(0, 0, 0, 0.22);
}

.stepper-item {
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(8, 22, 24, 0.94);
    border-radius: 18px;
    padding: 15px 16px;
    color: var(--text-soft);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.stepper-item:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--line-strong);
}

.stepper-item.is-active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(8, 22, 24, 0.96));
    border-color: rgba(16, 185, 129, 0.28);
    box-shadow: 0 16px 30px rgba(5, 150, 105, 0.12);
}

.stepper-item.is-complete {
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(8, 22, 24, 0.98);
}

.stepper-item:disabled {
    opacity: 0.46;
    cursor: not-allowed;
    transform: none;
}

.stepper-index {
    min-width: 30px;
    color: var(--teal);
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.stepper-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.stepper-title {
    color: var(--text);
    font-weight: 700;
}

.stepper-subtitle {
    color: var(--text-dim);
    font-size: 0.84rem;
}

.step-card,
.app-modal-dialog,
.level-popup > div {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(23, 32, 25, 0.84), rgba(5, 16, 17, 0.92));
    box-shadow: var(--shadow);
    overflow: hidden;
}

.step-card::after,
.app-modal-dialog::after,
.level-popup > div::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 42%);
    pointer-events: none;
}

.step-card {
    padding: 26px;
    margin-bottom: 22px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.step-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.step-card.is-active,
.step-card:hover {
    border-color: var(--line-strong);
}

.step-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    padding-bottom: 20px;
    margin-bottom: 22px;
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

.step-header-main {
    display: flex;
    gap: 18px;
    min-width: 0;
}

.step-header-meta {
    display: flex;
    align-items: flex-start;
}

.step-number {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(16, 185, 129, 0.12);
    color: var(--teal);
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-title h2,
.decision-card-header strong,
.progress-console-header h3,
.popup-header h2,
.app-modal-header h3 {
    font-family: 'JetBrains Mono', sans-serif;
}

.step-title h2 {
    font-size: 1.44rem;
    margin-bottom: 8px;
}

.step-title p,
.summary-label,
.summary-value,
.result-box,
.popup-text,
.popup-meta,
.progress-meta,
.progress-log-text,
.target-levels-loading,
.step4-hint,
.step4-order-label,
.manual-grid-title,
.modal-warning-note,
.modal-warning-item div,
.search-field-label,
.inline-stat,
.decision-list-item,
.form-group small,
.field-help {
    color: var(--text-soft);
}

.step-status-chip,
.inline-stat,
.level-state-pill,
.slot-state-pill,
.progress-badge,
.toolbar-chip,
.section-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.step-status-chip.is-complete,
.inline-stat.is-accent,
.level-state-pill.is-ready,
.slot-state-pill.is-safe,
.progress-badge {
    color: var(--bg-deep);
    background: linear-gradient(135deg, var(--teal), #a7fff3);
    border-color: transparent;
    box-shadow: 0 14px 28px rgba(5, 150, 105, 0.18);
}

.inline-stat-muted,
.level-state-pill.is-loading,
.slot-state-pill.is-neutral {
    color: var(--text-dim);
}

.form,
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-span-2 {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
}

.form-group input,
.search-field input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: var(--input);
    color: var(--text);
    font: inherit;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.form-group input::placeholder,
.search-field input::placeholder {
    color: var(--text-dim);
}

.form-group input:focus,
.search-field input:focus {
    outline: none;
    border-color: rgba(16, 185, 129, 0.34);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.08);
}

.form-actions,
.step2-actions,
.clone-action-bar,
.actions,
.levels-controls,
.progress-console-header,
.progress-meta,
.slot-header-row,
.levels-toolbar,
.levels-toolbar-main,
.levels-toolbar-stats,
.step4-order-row,
.step4-toggle,
.manual-grid,
.overview-grid,
.summary-box-source-target,
.summary-item,
.app-modal-actions,
.target-level-slot,
.progress-log-item {
    display: flex;
}

.form-actions,
.step2-actions,
.clone-action-bar,
.actions {
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.step2-actions,
.clone-action-bar {
    margin-top: 2px;
}

.btn {
    position: relative;
    z-index: 1;
    border: 0;
    border-radius: 999px;
    padding: 13px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

.btn-primary,
.btn-success {
    color: var(--bg-deep);
    background: linear-gradient(135deg, var(--teal), #6ee7b7);
    box-shadow: 0 18px 30px rgba(5, 150, 105, 0.18);
}

.btn-secondary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(16, 185, 129, 0.14);
}

.btn-small {
    padding: 10px 14px;
    font-size: 0.92rem;
}

.btn-large {
    padding: 15px 24px;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(4, 16, 17, 0.2);
    border-top-color: rgba(4, 16, 17, 0.9);
    animation: spin 0.75s linear infinite;
}

.btn-status {
    margin-left: 10px;
    color: inherit;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.result-box {
    display: block;
    padding: 16px 18px;
    margin-top: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    line-height: 1.7;
}

.result-box.success {
    border-color: rgba(16, 185, 129, 0.18);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(255, 255, 255, 0.03));
}

.result-box.error {
    border-color: rgba(255, 125, 125, 0.22);
    background: var(--red-soft);
}

.result-box.info {
    border-color: rgba(234, 182, 97, 0.2);
    background: var(--amber-soft);
}

.levels-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.levels-toolbar {
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.levels-toolbar-main {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    flex: 1 1 420px;
}

.search-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: min(100%, 340px);
}

.search-field-label,
.decision-kicker,
.progress-kicker,
.app-modal-kicker,
.summary-label,
.manual-grid-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-soft);
}

.levels-toolbar-stats {
    gap: 10px;
    flex-wrap: wrap;
}

.levels-container,
.exported-cards,
.target-levels-slots,
.progress-log {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 185, 129, 0.28) transparent;
}

.levels-container,
.exported-cards,
.target-levels-slots {
    max-height: 530px;
}

.level-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 9px 12px;
    border-radius: 18px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.level-item + .level-item,
.exported-card + .exported-card,
.target-level-slot + .target-level-slot {
    margin-top: 8px;
}

.level-item:hover,
.target-level-slot:hover,
.target-level-slot.drag-over,
.exported-cards.drag-over {
    transform: translateY(-1px);
    border-color: rgba(16, 185, 129, 0.18);
    background: rgba(16, 185, 129, 0.06);
}

.level-item.is-selected {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.09), rgba(234, 182, 97, 0.05));
    border-color: rgba(16, 185, 129, 0.18);
}

.level-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--teal);
    cursor: pointer;
}

.level-item-loading {
    opacity: 0.92;
}

.level-item-main {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.level-title-row,
.level-item label,
.level-title-meta,
.level-meta-row {
    display: flex;
    align-items: center;
}

.level-title-row {
    justify-content: space-between;
    gap: 12px;
}

.level-item label {
    gap: 10px;
    cursor: pointer;
    min-width: 0;
    flex: 1;
}

.level-number {
    min-width: 34px;
    color: var(--text-soft);
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 0.84rem;
}

.clickable-level {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.level-item-loaded .clickable-level {
    color: #6ee7b7;
    cursor: pointer;
    text-shadow: 0 0 14px rgba(16, 185, 129, 0.3);
}

.level-item-loading .clickable-level {
    color: var(--text-soft);
    cursor: default;
    pointer-events: none;
}

.level-title-meta {
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.level-meta-row {
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.level-meta-badge {
    padding: 6px 9px;
    border-radius: 999px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
    font-size: 0.72rem;
    white-space: nowrap;
}

.overview-grid {
    align-items: stretch;
    gap: 16px;
    flex-wrap: wrap;
}

.overview-grid > * {
    flex: 1 1 240px;
}

.summary-box,
.decision-card,
.progress-console,
.target-level-slot,
.exported-card,
.assigned-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.03);
}

.summary-box,
.decision-card,
.progress-console {
    padding: 20px;
}

.summary-box-source-target {
    flex-direction: column;
    gap: 16px;
}

.summary-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.18), transparent);
}

.summary-item {
    flex-direction: column;
    gap: 6px;
}

.summary-value {
    font-size: 0.98rem;
    line-height: 1.6;
}

.decision-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.decision-card-warning {
    border-color: rgba(234, 182, 97, 0.18);
    background: linear-gradient(180deg, rgba(234, 182, 97, 0.08), rgba(255, 255, 255, 0.03));
}

.decision-card-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.decision-card-header strong {
    font-size: 1.06rem;
}

.decision-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.decision-list-item {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(0, 0, 0, 0.14);
    line-height: 1.6;
}

.decision-list-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text);
}

.step4-order-row {
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin: 22px 0 14px;
    flex-wrap: wrap;
}

.step4-toggle {
    gap: 10px;
    flex-wrap: wrap;
}

.step4-toggle-btn {
    border: 1px solid rgba(16, 185, 129, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 11px 16px;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.step4-toggle-btn.active {
    color: var(--bg-deep);
    background: linear-gradient(135deg, var(--teal), #a7fff3);
    border-color: transparent;
}

.step4-hint,
.target-levels-loading,
.step4-warning {
    margin-bottom: 14px;
}

.manual-grid {
    gap: 16px;
    align-items: stretch;
}

.manual-grid > div {
    flex: 1 1 320px;
    min-width: 0;
}

.step4-auto-block,
.step4-manual-block {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.manual-grid-title {
    margin-bottom: 10px;
}

.target-level-slot {
    align-items: stretch;
    min-height: 88px;
    overflow: hidden;
}

.slot-num {
    display: grid;
    place-items: center;
    width: 60px;
    min-width: 60px;
    font-family: 'JetBrains Mono', sans-serif;
    color: var(--teal);
    border-right: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(16, 185, 129, 0.05);
}

.slot-cell {
    flex: 1;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.slot-header-row {
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.slot-label {
    color: var(--text-soft);
    font-size: 0.92rem;
}

.slot-assigned {
    display: none;
}

.slot-assigned:not(:empty) {
    display: flex;
}

.slot-state-pill.is-warning {
    color: #ffe6b8;
    border-color: rgba(234, 182, 97, 0.18);
    background: rgba(234, 182, 97, 0.12);
}

.exported-card,
.assigned-card {
    width: 100%;
    padding: 12px 14px;
    color: var(--text);
    font-weight: 600;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.11), rgba(0, 0, 0, 0.18));
}

.exported-card,
.assigned-card.assigned-draggable {
    cursor: grab;
}

.exported-card.dragging,
.assigned-card.assigned-draggable.dragging {
    opacity: 0.36;
    cursor: grabbing;
}

.step4-empty {
    padding: 16px;
    color: var(--text-soft);
}

.step4-warning {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 125, 125, 0.2);
    background: rgba(255, 125, 125, 0.1);
    color: #ffd3d3;
}

.progress-console {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-console-header {
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.progress-console-header h3 {
    margin-top: 6px;
    font-size: 1.18rem;
}

.progress-stage {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
}

.progress-track {
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.progress-track-bar {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--teal), #6ee7b7, var(--amber));
    transition: width 0.35s ease;
}

.progress-meta {
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.progress-log {
    max-height: 240px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-log:empty::before {
    content: 'Журнал появится после первого серверного статуса.';
    color: var(--text-dim);
}

.progress-log-item {
    justify-content: space-between;
    gap: 14px;
    padding: 11px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(16, 185, 129, 0.08);
}

.progress-log-time {
    color: var(--text-dim);
    font-size: 0.84rem;
    white-space: nowrap;
}

.actions {
    justify-content: center;
    margin-top: 22px;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
}

.app-modal[hidden] {
    display: none;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(1, 8, 9, 0.74);
    backdrop-filter: blur(10px);
}

.app-modal-dialog {
    position: relative;
    width: min(720px, calc(100vw - 24px));
    margin: 8vh auto 0;
    padding: 24px;
}

.app-modal-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.app-modal-header h3 {
    font-size: 1.24rem;
    margin-top: 6px;
}

.app-modal-close,
.popup-close {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(16, 185, 129, 0.16);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.app-modal-body {
    max-height: 60vh;
    overflow: auto;
    line-height: 1.7;
}

.app-modal-actions {
    justify-content: flex-end;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.modal-warning-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
}

.modal-warning-item {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(234, 182, 97, 0.14);
    background: rgba(234, 182, 97, 0.08);
}

.modal-warning-note {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(255, 255, 255, 0.03);
}

.level-popup {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(1, 8, 9, 0.72);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 12px 24px;
    overflow: auto;
}

.level-popup > div {
    width: min(860px, calc(100vw - 24px));
    padding: 24px;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.popup-header h2 {
    font-size: 1.24rem;
}

.popup-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.popup-section {
    padding: 16px 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.popup-section h3 {
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', sans-serif;
    font-size: 1rem;
}

.popup-item + .popup-item {
    margin-top: 10px;
}

.popup-item strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
}

.popup-html-content {
    margin-top: 8px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    background: rgba(0, 0, 0, 0.16);
    overflow: auto;
    line-height: 1.72;
    white-space: normal;
}

.popup-html-content * {
    max-width: 100%;
}

.popup-html-content > *:first-child {
    margin-top: 0;
}

.popup-html-content > *:last-child {
    margin-bottom: 0;
}

.popup-html-content p,
.popup-html-content div,
.popup-html-content li,
.popup-html-content blockquote {
    margin: 0 0 0.85em;
}

.popup-html-content a {
    color: #6ee7b7;
}

.popup-html-content pre,
.popup-html-content code {
    font-family: 'Manrope', sans-serif;
}

.popup-html-content pre {
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.popup-html-content table {
    width: 100%;
    border-collapse: collapse;
}

.popup-html-content td,
.popup-html-content th {
    border: 1px solid rgba(16, 185, 129, 0.12);
    padding: 8px;
}

.popup-empty {
    color: var(--text-dim);
}

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

@media (max-width: 980px) {
    .stepper {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .overview-grid,
    .manual-grid,
    .form-grid {
        flex-direction: column;
        display: flex;
    }

    .form-span-2 {
        grid-column: auto;
    }
}

@media (max-width: 760px) {
    .app-header-inner,
    .container {
        width: min(100vw - 20px, 1160px);
    }

    .step-card,
    .app-modal-dialog,
    .level-popup > div {
        padding: 20px;
        border-radius: 22px;
    }

    .app-header-inner,
    .step-header,
    .step-header-main,
    .levels-toolbar,
    .levels-toolbar-main,
    .step4-order-row,
    .progress-console-header,
    .progress-meta,
    .slot-header-row,
    .app-modal-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header {
        padding: 0 8px;
    }

    .header h1 {
        font-size: 0.92rem;
    }

    .stepper {
        top: 82px;
    }

    .step-header-meta {
        align-items: stretch;
    }

    .level-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .level-title-meta,
    .level-meta-row {
        justify-content: flex-start;
    }

    .level-title-meta {
        width: 100%;
        flex-wrap: wrap;
    }

    .slot-num {
        width: 52px;
        min-width: 52px;
    }
}

@media (max-width: 620px) {
    .stepper {
        grid-template-columns: 1fr;
    }
}

/* === Minimalist override — hide heavy decoration === */
.grid-field, .scanline, .glow, .page-noise { display: none !important; }
body {
    background:
        radial-gradient(ellipse 900px 500px at 50% -10%, rgba(16, 185, 129, 0.055), transparent 70%),
        radial-gradient(ellipse 600px 400px at 100% 80%, rgba(16, 185, 129, 0.025), transparent 70%),
        #0a0e0c !important;
    background-attachment: fixed !important;
}
.step-card, .app-modal-dialog, .level-popup > div {
    background: #141a16 !important;
}
.step-card::after, .app-modal-dialog::after, .level-popup > div::after {
    display: none !important;
}
.container > .header h1 {
    font-size: clamp(1.4rem, 2.6vw, 1.75rem) !important;
    line-height: 1.3 !important;
    font-weight: 700 !important;
    letter-spacing: -0.015em !important;
}

/* === Autofill override — подгоняем под цвет обычного поля внутри .step-card === */
/* Обычный input: rgba(0,0,0,0.18) поверх .step-card (#141a16) ≈ #101512 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #101512 inset !important;
    box-shadow: 0 0 0 1000px #101512 inset !important;
    -webkit-text-fill-color: #e8efea !important;
    caret-color: #e8efea !important;
    transition: background-color 60000s ease-in-out 0s !important;
    border: 1px solid rgba(16, 185, 129, 0.12) !important;
}
input:-moz-autofill {
    background-color: #101512 !important;
    color: #e8efea !important;
}

/* === Отступы списка уровней и внутренней области шагов === */
.levels-container,
.exported-cards,
.target-levels-slots,
.progress-log {
    padding: 18px !important;
    border-radius: 14px !important;
}
.levels-container .level-item,
.exported-cards .exported-card,
.target-levels-slots .target-level-slot {
    margin-bottom: 10px;
}
.levels-container .level-item:last-child,
.exported-cards .exported-card:last-child,
.target-levels-slots .target-level-slot:last-child {
    margin-bottom: 0;
}
.levels-toolbar {
    padding-bottom: 4px;
    margin-bottom: 8px;
}
.step-body {
    gap: 20px !important;
}
.levels-list {
    gap: 14px !important;
}
.step2-actions {
    margin-top: 4px;
}

/* === Название уровня как кликабельный элемент === */
.clickable-level {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    transition: color 0.15s ease;
}
.level-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
}
.level-view-icon {
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--teal);
}
.level-item-loaded .clickable-level {
    color: #6ee7b7 !important;
    text-shadow: none !important;
    cursor: pointer;
}
.level-item-loaded .clickable-level .level-name-text {
    text-decoration: underline dotted rgba(16, 185, 129, 0.45);
    text-underline-offset: 3px;
}
.level-item-loaded .clickable-level:hover {
    color: #a7fff3 !important;
}
.level-item-loaded .clickable-level:hover .level-name-text {
    text-decoration: underline solid rgba(16, 185, 129, 0.8);
}
.level-item-loaded .level-view-icon {
    opacity: 0.85;
    transform: translateX(0);
}
.level-item-loaded .clickable-level:hover .level-view-icon {
    opacity: 1;
}

/* Бейдж "Нет данных" / "Готово" */
.level-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.level-item-loaded .level-meta-badge {
    color: var(--teal);
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(16, 185, 129, 0.08);
}

/* === Mode toggle (Клонирование / Редактирование) === */
.mode-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(10, 14, 12, 0.7);
    margin: 0 auto 22px;
    width: fit-content;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 4px;
}
.mode-toggle-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 22px;
}
.mode-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-soft);
    font: inherit;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-toggle-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.mode-toggle-btn:hover {
    color: var(--text);
    background: rgba(16, 185, 129, 0.06);
}
.mode-toggle-btn.is-active {
    background: rgba(16, 185, 129, 0.14);
    color: var(--teal);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.24);
}

/* === Edit mode: прячем степпер и шаги 2/3/4 === */
body.mode-edit .stepper,
body.mode-edit #step2,
body.mode-edit #step3,
body.mode-edit #step4,
body.mode-edit .actions #resetBtn {
    display: none !important;
}
body.mode-edit #sourceResult.result-box { /* результат всё равно показываем */ }
body.mode-edit #step1 .step-title h2::after {
    content: ' → Редактор';
    color: var(--teal);
    font-weight: 500;
}

/* Прогресс загрузки сценария (edit mode) */
.editor-prep {
    margin-top: 16px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.04);
    display: none;
}
.editor-prep.active { display: block; }
.editor-prep-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 10px;
}
.editor-prep-status::before {
    content: '';
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid var(--teal);
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.editor-prep-bar {
    width: 100%;
    height: 4px;
    background: rgba(16, 185, 129, 0.12);
    border-radius: 2px;
    overflow: hidden;
}
.editor-prep-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal-strong), var(--teal));
    border-radius: 2px;
    width: 0%;
    transition: width 0.4s ease;
}
