:root {
    --stone-050: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --stone-950: #0c0a09;

    --blue: #3b82f6;
    --cyan: #46ccff;
    --indigo: #6366f1;

    --bg: var(--stone-950);
    --bg-raised: var(--stone-900);
    --bg-surface: var(--stone-800);
    --border: var(--stone-800);
    --border-strong: var(--stone-500);
    --text: var(--stone-200);
    --text-muted: var(--stone-400);
    --text-faint: var(--stone-500);
    --text-bright: var(--stone-100);
    --accent: var(--blue);
    --accent-hover: #5193f8;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Roboto Mono", "Cascadia Code", monospace;
    --line-height: 1.6;
    --line-height-tight: 1.2;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: 0 !important;
}

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

::selection {
    background-color: var(--indigo);
    color: var(--stone-050);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-surface); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.hidden { display: none !important; }

/* Layout */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 32px 80px;
}

header { margin-bottom: 40px; }

header h1 {
    font-family: var(--font-mono);
    font-size: 2em;
    font-weight: 700;
    color: var(--text-bright);
    line-height: var(--line-height-tight);
}

header h1 span { color: var(--accent); }

header p {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: 0.95rem;
}

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 32px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group.grow {
    flex: 1;
    min-width: 240px;
}

label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input, select {
    padding: 10px 12px;
    background-color: var(--bg);
    border: 1px solid var(--border-strong);
    color: var(--text-bright);
    font-family: inherit;
    font-size: 1rem;
    line-height: var(--line-height);
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-faint);
    opacity: 0.6;
}

select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2378716c' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* Buttons */
button {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    background-color: var(--accent);
    color: var(--stone-050);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    white-space: nowrap;
}

button:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

button:focus { outline: 2px solid var(--accent); }

button.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text);
}

button.btn-secondary:hover {
    background-color: var(--text-faint);
}

/* Info bar */
.info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px 20px;
    background-color: var(--bg-raised);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-label {
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.info-value {
    color: var(--text-bright);
    font-weight: 600;
}

.info-value.accent { color: var(--accent); }

.info-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
}

.toolbar button {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.toolbar .spacer { flex: 1; }

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.zoom-controls button {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
}

.zoom-controls span {
    min-width: 48px;
    text-align: center;
    color: var(--text-bright);
}

.coord-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    min-width: 120px;
    text-align: center;
}

.coord-display .coord-val {
    color: var(--cyan);
    font-weight: 600;
}

/* QR wrapper */
.qr-wrapper {
    overflow: auto;
    border: 1px solid var(--border);
    background-color: var(--stone-050);
    padding: 8px;
    position: relative;
}

#qr-canvas {
    display: block;
    image-rendering: pixelated;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-faint);
    text-align: center;
    gap: 12px;
}

.empty-state .icon {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: 8px;
}

.empty-state p { font-size: 0.95rem; }

.empty-state .hint {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-faint);
    opacity: 0.6;
}

/* Legend */
.legend {
    margin-top: 32px;
    padding: 20px 24px;
    background-color: var(--bg-raised);
    border: 1px solid var(--border);
}

.legend h3 {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-swatch {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* Shortcuts */
.shortcuts {
    margin-top: 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-faint);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.shortcuts kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Highlight options */
.highlight-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    user-select: none;
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}

.highlight-option:hover { border-color: var(--text-faint); }

.highlight-option.active {
    border-color: var(--accent);
    color: var(--text-bright);
}

.highlight-option input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* Fullscreen */
.app.fullscreen {
    max-width: none;
    padding: 16px;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.app.fullscreen header { margin-bottom: 16px; }
.app.fullscreen .controls { margin-bottom: 16px; }
.app.fullscreen .info-bar { margin-bottom: 12px; }
.app.fullscreen .toolbar { margin-bottom: 12px; }

.app.fullscreen .qr-wrapper {
    flex: 1;
    min-height: 0;
}

.app.fullscreen .legend { margin-top: 16px; }
.app.fullscreen .shortcuts { margin-top: 12px; }

/* Responsive */
@media (max-width: 640px) {
    .app { padding: 20px 16px 60px; }
    header h1 { font-size: 1.5em; }
    .controls { flex-direction: column; }
    .info-bar { flex-direction: column; gap: 12px; }
    .info-divider { width: 100%; height: 1px; }
}

/* Print */
@media print {
    body { background: white; color: black; }

    .controls, .toolbar, .legend, .shortcuts, header p,
    .info-bar, .coord-display {
        display: none !important;
    }

    .qr-wrapper {
        border: none;
        background: white;
        padding: 0;
        overflow: visible;
    }

    #qr-canvas {
        max-width: 100%;
        height: auto !important;
    }

    header h1 {
        color: black;
        font-size: 1.2em;
        margin-bottom: 10px;
    }
}
