:root {
    --bg: #0d0f14;
    --surface: #141720;
    --surface2: #1c2030;
    --surface3: #232840;
    --accent: #5b8fff;
    --accent2: #38e8c0;
    --accent3: #f97baa;
    --text: #e8ecf4;
    --muted: #6b7591;
    --border: rgba(255, 255, 255, 0.07);
    --border2: rgba(255, 255, 255, 0.12);
    --highlight: rgba(91, 143, 255, 0.15);
    --flash: rgba(56, 232, 192, 0.35);
    --success: #38e8c0;
    --warn: #f9a84b;
    --mono: ui-monospace, 'Cascadia Code', 'Fira Mono', Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    line-height: 1.6;
}

/* HEADER */
header {
    padding: 2.5rem 2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -60px;
    left: -60px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(91, 143, 255, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

header::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(56, 232, 192, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.header-tag {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent2);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-tag::before {
    content: '';
    width: 24px;
    height: 1px;
    background: var(--accent2);
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-family: var(--mono);
}

/* LAYOUT */
.main {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 0;
    min-height: calc(100vh - 130px);
}

/* FORM PANEL */
.form-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
}

.section {
    margin-bottom: 1.75rem;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border2);
}

/* FORM FIELDS */
label {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
    font-family: var(--mono);
}

input[type="text"],
select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.82rem;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-bottom: 0.9rem;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 143, 255, 0.12);
}

select option {
    background: var(--surface2);
}

/* TOGGLE SWITCH */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text);
}

.toggle-desc {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: var(--mono);
    margin-top: 1px;
}

.switch {
    position: relative;
    width: 42px;
    height: 23px;
    flex-shrink: 0;
    margin-left: 1rem;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--surface3);
    border-radius: 23px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid var(--border2);
}

.slider::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    left: 3px;
    top: 3px;
    background: var(--muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.switch input:checked+.slider {
    background: rgba(91, 143, 255, 0.25);
    border-color: var(--accent);
}

.switch input:checked+.slider::before {
    transform: translateX(19px);
    background: var(--accent);
}

/* BACKUP ENTRIES */
.backup-entry {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    position: relative;
}

.backup-entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.backup-entry input {
    margin-bottom: 0;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.btn-remove:hover {
    color: var(--accent3);
    background: rgba(249, 123, 170, 0.1);
}

.btn-add {
    width: 100%;
    background: var(--surface2);
    border: 1px dashed var(--border2);
    border-radius: 6px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.8rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    text-align: center;
}

.btn-add:hover {
    color: var(--accent2);
    border-color: var(--accent2);
    background: rgba(56, 232, 192, 0.05);
}

/* SCRIPT OUTPUT */
.output-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

.output-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.terminal-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red {
    background: #ff5f57;
}

.dot-yellow {
    background: #febc2e;
}

.dot-green {
    background: #28c840;
}

.terminal-title {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.btn-copy,
.btn-dl {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.78rem;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-copy:hover {
    border-color: var(--accent2);
    color: var(--accent2);
    background: rgba(56, 232, 192, 0.07);
}

.btn-dl:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(91, 143, 255, 0.07);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

/* TERMINAL BODY */
.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

#script-output {
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.85;
    white-space: pre;
    color: #c9d6f5;
    position: relative;
}

/* LINE HIGHLIGHT FLASH */
.line-wrap {
    display: block;
    transition: background 0.05s;
    border-radius: 3px;
    padding: 0 4px;
    margin: 0 -4px;
}

.line-wrap.flash {
    animation: flashLine 0.6s ease-out forwards;
}

@keyframes flashLine {
    0% {
        background: var(--flash);
    }

    100% {
        background: transparent;
    }
}

/* SYNTAX COLORS */
.tok-comment {
    color: #4a5578;
}

.tok-key {
    color: #5b8fff;
}

.tok-val {
    color: #38e8c0;
}

.tok-str {
    color: #f9d87b;
}

.tok-kw {
    color: #f97baa;
}

.tok-fn {
    color: #c8a8f9;
}

.tok-op {
    color: #7ba0ff;
}

.tok-bracket {
    color: #8899cc;
}

.tok-num {
    color: #f9a84b;
}

/* CRON SECTION */
.cron-section {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    flex-shrink: 0;
}

.cron-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent3);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cron-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border2);
}

.cron-fields {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.cron-field {
    flex: 1;
    min-width: 120px;
}

.cron-field label {
    margin-bottom: 0.3rem;
}

.cron-field select {
    margin-bottom: 0;
}

.cron-result {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cron-line {
    color: var(--accent2);
    letter-spacing: 0.02em;
    flex: 1;
    word-break: break-all;
}

.cron-desc {
    color: var(--muted);
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.btn-copy-cron {
    background: none;
    border: 1px solid var(--border2);
    border-radius: 5px;
    color: var(--muted);
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    font-family: var(--mono);
}

.btn-copy-cron:hover {
    color: var(--accent2);
    border-color: var(--accent2);
}

/* COPY FEEDBACK */
.copy-ok {
    color: var(--success) !important;
    border-color: var(--success) !important;
}

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

    .form-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .terminal-title {
        display: none;
    }

    h1 {
        font-size: 1.5rem;
    }
}

/* CRON INSTRUCTIONS */
.cron-instructions {
    margin-top: 0.85rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-family: var(--mono);
    line-height: 1.65;
}

.cron-instructions p {
    margin-bottom: 0.4rem;
}

.cron-instructions code {
    color: var(--accent2);
    background: var(--surface2);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.77rem;
}

.cron-instructions ol {
    margin: 0 0 0 1.3rem;
}

.cron-instructions li {
    margin-bottom: 0.2rem;
}

/* BONNES PRATIQUES */
.tips-section {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
}

.tips-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent2);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tips-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border2);
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.tip-card {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.tip-card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent2);
    margin-bottom: 0.3rem;
}

.tip-card-body {
    font-size: 0.78rem;
    color: var(--muted);
    font-family: var(--mono);
    line-height: 1.55;
}