:root {
    --bg-dark-primary: #1e1e24;
    --bg-dark-secondary: #272730;
    --bg-light-primary: #f0f2f5;
    --border-color: #3a3a44;
    --text-primary: #e2e2e8;
    --text-secondary: #aaaabb;
    --accent-primary: #006fe6;
    --accent-primary-hover: #00a2ff;
    --accent-secondary: #dc3545;
    --accent-secondary-hover: #c82333;
    --controls-width: 320px;
    --btn-bg-primary: #38b6ff;
    --btn-color-primary: #000000;
    --btn-bg-secondary: #38b6ff;
    --btn-color-secondary: #000000;
}

/* --- Base & Layout --- */
body {
    font-family: 'Open Sans', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-dark-primary);
    color: var(--text-primary);
    display: grid;
    grid-template-columns: var(--controls-width) 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    grid-template-areas:
        "controls breakpoints"
        "controls canvas"
        "controls code";
}

.heading {
    display: inline-flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

#controls {
    grid-area: controls;
    background-color: var(--bg-dark-primary);
    padding: 10px 20px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.button-group {
    display: inline-flex;
    justify-content: flex-start;
    width: 100%;
    gap: 10px;
}

#breakpoints {
    display: inline-flex;
    justify-content: end;
    align-items: center;
    grid-area: breakpoints;
    background: var(--bg-dark-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 24px;
}

.citation {
    font-size: 13px;
    color: white;
    margin-left: 15px;
    width: 100%;
    text-align: right;

    a {
        color: white;
        font-weight: 700;
        text-decoration: none;

        &:hover,
        &:focus {
            opacity: .75;
            text-decoration: underline;
        }
    }
}

#canvas-wrapper {
    grid-area: canvas;
    background-color: var(--bg-light-primary);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
}

#canvas-container {
    width: 100%;
    height: calc(100% - 20px);
    background-color: #fff;
    border: 1px solid #d1d5db;
    transition: all 0.3s ease;
    max-width: 100%;
    transform-origin: top center;
    padding: 8px;
}

#code-output {
    grid-area: code;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1px;
    background-color: var(--border-color);
    border-top: 1px solid var(--border-color);
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 600;
}

h1 {
    position: relative;
    color: #fff;
    font-size: 32px;
    font-weight: 800;
    line-height: 32px;
    top: 0;
    left: 0;
    margin: 0;
}

h2 {
    font-size: 1.1em;
    color: #fff;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

h3 {
    font-size: 1em;
    margin-top: 20px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

h4 {
    font-size: 0.9em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

p {
    font-size: 14px;
    margin-top: 0;
    margin-bottom: 25px;
}

img {
    width: auto;
    height: 65px;
    border-radius: 8px;
}

/* --- Forms & Controls --- */
.control-group {
    margin-bottom: 24px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875em;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-group select,
.control-group input[type="text"],
.control-group input[type="number"] {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-dark-secondary);
    color: var(--text-primary);
    box-sizing: border-box;
    font-size: 0.9em;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 15px;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* --- Buttons --- */
.btn {
    width: 100%;
    padding: 12px;
    background-color: var(--btn-bg-primary);
    color: var(--btn-color-primary);
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--accent-primary-hover);
}

.btn-secondary {
    background-color: var(--accent-secondary);
}

.btn-secondary:hover {
    background-color: var(--accent-secondary-hover);
}

.breakpoint-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-dark-secondary);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
}

.breakpoint-btn.active {
    background-color: var(--btn-bg-primary);
    color: var(--btn-color-primary);
    border-color: var(--btn-bg-primary);

    &:hover,
    &:focus {
        background-color: var(--accent-primary-hover);
        color: var(--btn-color-primary);
        border-color: var(--accent-primary-hover);
    }
}

.breakpoint-btn:not(.active):hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}


/* --- Canvas & Code --- */
.canvas-item {
    background-color: #757575;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: 700;
    border-radius: 6px;
    min-height: 60px;
    min-width: 60px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.canvas-item.selected {
    border-color: #38b6ff;
    box-shadow: 0 0 0 4px rgba(56, 182, 255, 0.5);
    transform: scale(1.02);
}

.code-box {
    position: relative;
    background-color: var(--bg-dark-primary);
    display: flex;
    flex-direction: column;
}

.code-box h2 {
    position: relative;
    margin: 0;
    padding: 12px 16px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-color);
    z-index: 1;
    background-color: var(--bg-dark-primary);
}

.code-box pre {
    flex-grow: 1;
    padding: 16px;
    padding-top: 56px;
    overflow: auto;
    background: #272822 !important;
    height: 100%;
    max-height: 225px;
}

.code-box pre[class*="language-"] {
    font-size: 14px;
    margin: 0;
}

.code-box .copy-btn {
    position: absolute;
    top: 10px;
    right: 16px;
    background: var(--border-color);
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
    transition: all 0.2s;
    z-index: 2;
}

.copy-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.copy-btn:active {
    transform: scale(0.95);
}

.custom-input-wrapper {
    margin-top: 8px;
}

.hidden {
    display: none;
}

.token.constant,
.token.deleted,
.token.property,
.token.symbol,
.token.tag {
    color: #fe4d8e !important;
}

.ctaad {
    position: relative;
    display: block;
    margin: 15px;
}

.ctaad__link {
    position: relative;
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: stretch;
    background-color: white;
    color: #333333;
    text-decoration: none;
    height: 220px;
    width: 100%;
    max-width: 650px;
    border: 2px solid #ffffff;
    border-radius: 8px;
    margin: auto;
    top: 0;
    transition: all .2s ease-in-out;
    overflow: hidden;

    &:hover,
    &:focus {
        top: -2px;
        box-shadow: 0 3px 12px rgba(52, 152, 219, 0.25);
    }
}

.ctaad__image {
    position: absolute;
    height: 220px;
    max-width: 220px;
    margin-right: 20px;
    object-fit: cover;
}

.ctaad__text {
    font-size: 16px;
    font-weight: 600;
    padding: 15px 20px 30px 245px;

    h2 {
        margin-top: 0;
        margin-bottom: 10px;
        font-size: 18px;
        font-weight: 700;
        padding: 0;
        background: none;
        color: inherit;
        border: none;
    }

    p {
        &:last-of-type {
            margin-bottom: 0;
        }
    }
}

.ctaad__tag {
    position: absolute;
    right: 0;
    bottom: 0;
    font-size: 8px;
    text-transform: uppercase;
    background-color: #e9ecef;
    padding: 3px 10px;
    letter-spacing: 1px;
    border-top-left-radius: 4px;
}

.info-btn {
    background: var(--bg-dark-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
    /* Push it to the right */
}

.info-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.info-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.info-panel.is-visible {
    opacity: 1;
    visibility: visible;
}

.info-panel__content {
    background: var(--bg-dark-secondary);
    color: var(--text-primary);
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    padding: 30px 40px;
    border-radius: 12px 12px 0 0;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.info-panel.is-visible .info-panel__content {
    transform: translateY(0);
}

.info-panel__content h2 {
    border: none;
    font-size: 28px;
}

.info-panel__content h3 {
    color: var(--text-secondary);
}

.info-panel__content p {
    font-size: 16px;
    line-height: 24px;
}

.info-panel__content ul,
.info-panel__content ol {
    padding-left: 20px;
    line-height: 1.6;
}

.info-panel__content li {
    margin-bottom: 10px;
}

.info-panel__content code {
    background: var(--bg-dark-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.info-panel__close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.info-panel__close-btn:hover {
    color: white;
}