:root {
    --bg: #0f172a;
    --card: #1e293b;
    --panel: #172033;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
}

.page-shell {
    width: min(760px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    margin-bottom: 6px;
    transition: color 0.2s;
}
.back-link:hover {
    color: var(--accent);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    color: var(--accent-hover);
    font-size: 28px;
    font-weight: 800;
}

h2 {
    font-size: 16px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.muted-panel {
    color: var(--text-muted);
}

.section-heading,
.master-toggle,
.inline-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.master-toggle,
.inline-toggle {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.preset-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.preset-card {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.preset-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
}

.preset-card:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.preset-card input {
    accent-color: var(--accent);
}

.custom-grid {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.58);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius);
    transition: opacity 0.3s;
}

.control-row {
    display: grid;
    grid-template-columns: 110px minmax(160px, 1fr) 78px 30px;
    align-items: center;
    gap: 10px;
}

.control-row label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

input[type="number"] {
    width: 100%;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s;
}
input[type="number"]:focus {
    border-color: var(--accent);
    outline: none;
}

.unit {
    color: var(--text-muted);
    font-size: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex: 0 0 auto;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #94a3b8;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: white;
}

@media (max-width: 620px) {
    .page-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .control-row {
        grid-template-columns: 1fr 74px 28px;
    }

    .control-row label {
        grid-column: 1 / -1;
    }
}
