/* ===== DESIGN TOKENS ===== */
:root {
    --color-bg: #0D0B1E;
    --color-surface: rgba(108, 92, 231, 0.08);
    --color-surface-solid: #151229;
    --color-glass: rgba(162, 155, 254, 0.06);
    --color-border: rgba(108, 92, 231, 0.2);
    --color-border-focus: #6C5CE7;
    --color-text: #E8E6F0;
    --color-text-secondary: #9B95B8;
    --color-text-muted: #5C5675;
    --color-primary: #6C5CE7;
    --color-primary-glow: rgba(108, 92, 231, 0.35);
    --color-secondary: #A29BFE;
    --color-accent: #FD79A8;
    --color-accent-glow: rgba(253, 121, 168, 0.3);
    --color-measure-line: #6C5CE7;
    --color-measure-fill: rgba(108, 92, 231, 0.08);
    --color-guide: rgba(253, 121, 168, 0.6);
    --color-grid: rgba(162, 155, 254, 0.06);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    cursor: crosshair;
    user-select: none;
}

/* ===== CANVAS ===== */
#ruler-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* ===== RULERS ===== */
.ruler {
    position: fixed;
    z-index: 10;
    background: var(--color-surface-solid);
    border: none;
}

.ruler-h {
    top: 0;
    left: 24px;
    right: 0;
    height: 24px;
    border-bottom: 1px solid var(--color-border);
}

.ruler-v {
    top: 24px;
    left: 0;
    bottom: 0;
    width: 24px;
    border-right: 1px solid var(--color-border);
}

/* ===== TOOLBAR ===== */
.toolbar {
    position: fixed;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px;
    background: rgba(21, 18, 41, 0.92);
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(108, 92, 231, 0.1);
}

.toolbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    color: var(--color-primary);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-right: 1px solid var(--color-border);
    margin-right: 4px;
}

.toolbar-tools,
.toolbar-actions {
    display: flex;
    gap: 2px;
}

.toolbar-actions {
    border-left: 1px solid var(--color-border);
    margin-left: 4px;
    padding-left: 6px;
}

/* Tool Buttons */
.tool-btn,
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tool-btn:hover,
.action-btn:hover {
    color: var(--color-text);
    background: var(--color-glass);
}

.tool-btn.active {
    color: var(--color-primary);
    background: rgba(108, 92, 231, 0.12);
    border-color: rgba(108, 92, 231, 0.25);
    box-shadow: 0 0 12px var(--color-primary-glow);
}

.action-btn {
    padding: 7px 9px;
}

/* ===== INFO PANEL ===== */
.info-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    background: rgba(21, 18, 41, 0.92);
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.info-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    min-width: 12px;
}

.info-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-secondary);
    min-width: 40px;
}

.info-unit {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

/* ===== CURSOR COORDS ===== */
.cursor-coords {
    position: fixed;
    z-index: 50;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--color-secondary);
    background: rgba(21, 18, 41, 0.85);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    opacity: 0;
    transition: opacity 150ms ease;
    white-space: nowrap;
}

.cursor-coords.visible {
    opacity: 1;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 10px 20px;
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 24px var(--color-primary-glow);
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== HELP OVERLAY ===== */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.help-card {
    position: relative;
    background: var(--color-surface-solid);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 400px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: cardSlide 0.25s ease;
}

@keyframes cardSlide {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.help-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--color-secondary);
}

.help-card #btn-close-help {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--color-text-muted);
    font-size: 1rem;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    align-items: center;
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 600;
}

.shortcut-grid span {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
    .toolbar {
        top: auto;
        bottom: 80px;
        flex-wrap: wrap;
        max-width: 90vw;
        justify-content: center;
    }

    .toolbar-brand {
        display: none;
    }

    .toolbar-actions {
        border-left: none;
        margin-left: 0;
        padding-left: 0;
    }

    .info-panel {
        bottom: 12px;
        gap: 12px;
        padding: 8px 14px;
    }

    .ruler-h,
    .ruler-v {
        display: none;
    }
}