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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    background: var(--ink);
    color: var(--cream);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow-x: hidden;
}

a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
    font: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding:
        calc(0.65rem + env(safe-area-inset-top, 0px))
        calc(1rem + env(safe-area-inset-right, 0px))
        0.65rem
        calc(1rem + env(safe-area-inset-left, 0px));
}

.back-link {
    font-family: "DM Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cream-dim);
    text-decoration: none;
    transition: color 0.2s ease;
}

.back-link:hover { color: var(--cream); text-decoration: none; }

.toolbar {
    display: flex;
    gap: 0.5rem;
}

.tool-btn {
    font-family: "DM Mono", monospace;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(243, 235, 224, 0.1);
    color: var(--cream-dim);
    background: rgba(22, 20, 31, 0.6);
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.tool-btn:hover {
    border-color: rgba(157, 122, 255, 0.4);
    color: var(--cream);
    background: rgba(157, 122, 255, 0.1);
}

.tool-btn.active {
    border-color: rgba(94, 228, 199, 0.4);
    color: var(--mint);
}

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(12, 11, 16, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.help-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.help-card {
    background: var(--card-bg);
    border: 1px solid rgba(243, 235, 224, 0.1);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 22rem;
    width: 100%;
}

.help-card h2 {
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    color: var(--cream);
}

.help-card kbd {
    font-family: "DM Mono", monospace;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(243, 235, 224, 0.08);
    border: 1px solid rgba(243, 235, 224, 0.12);
}

.help-list {
    list-style: none;
    font-size: 0.85rem;
    color: var(--cream-dim);
    line-height: 2;
}

.help-close {
    margin-top: 1rem;
    font-family: "DM Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--violet);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
