:root {
    --bg-color: #000;
    --text-color: #fff;
    --dim-text: #666;
    --border-color: #222;
    --font-main: 'Inter', sans-serif;
    --font-ui: 'Outfit', sans-serif;
}

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

body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
}

/* ============ LAYOUT ============ */
#app, #iconApp {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

input[type="text"] {
    width: 100%;
    background: #111;
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: #555;
}

/* Left sidebar: fixed 260px */
.sidebar-left {
    flex: 0 0 260px;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    background: #050505;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
}

.copyright {
    margin-top: auto;
    font-size: 0.75rem;
    color: #444;
    text-align: left;
}

/* Canvas: shrink-to-fit, centered vertically */
.workspace {
    flex: 0 0 auto;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #000;
}

.canvas-container {
    height: calc(100vh - 3rem);
    border: 1px solid var(--border-color);
}

#editorCanvas, #iconCanvas {
    display: block;
    height: 100%;
    width: auto;
}

/* Right overview: fills remaining space */
.sidebar-right {
    flex: 1 1 0;
    min-width: 200px;
    height: 100vh;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    padding: 0;
    background: #050505;
}

.inventory-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: #0a0a0a;
}

.char-set-selector {
    width: auto;
    min-width: fit-content;
    margin-left: 1rem;
}

.glyph-grid {
    padding: 1rem;
}

.word-preview-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #080808;
}

.preview-controls-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

.word-preview-display {
    width: 100%;
    min-height: 80px;
    background: #000;
    margin-top: 10px;
    display: flex;
    align-items: center;
    padding: 10px;
    overflow-x: auto;
    border: 1px solid #222;
    white-space: nowrap;
}

.word-preview-svg {
    height: 60px;
    flex-shrink: 0;
}

/* ============ LEFT SIDEBAR ============ */
.logo {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.1rem;
}
.logo span { font-weight: 300; opacity: 0.7; }
.tagline {
    font-size: 0.65rem;
    color: var(--dim-text);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.app-switcher { display: flex; gap: 0.4rem; }
.app-switch-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--dim-text);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05rem;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.app-switch-btn span { font-weight: 300; opacity: 0.7; }
.app-switch-btn.active { color: #fff; border-color: #555; }
.app-switch-btn:hover { color: #fff; }

.usage-preview { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; padding: 0.6rem 0 1rem; }
.usage-swatch { display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.usage-swatch.light { background: #f2f2f2; }
.usage-swatch.dark { background: #111; border: 1px solid var(--border-color); }
.usage-swatch img, .usage-swatch svg { display: block; }

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.6rem;
}

label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: var(--dim-text);
    font-family: var(--font-ui);
}

select, input[type="text"] {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    outline: none;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    padding: 0.5rem 0;
    border: none;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    background: #333;
    border-radius: 1px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -5px;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 2px;
    background: #333;
}

input[type="range"]::-moz-range-thumb {
    height: 12px;
    width: 12px;
    border: none;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-row input[type="checkbox"] {
    appearance: none;
    width: 12px;
    height: 12px;
    border: 1px solid var(--border-color);
    background: #000;
    cursor: pointer;
    border-radius: 0;
}

.checkbox-row input[type="checkbox"]:checked {
    background: #fff;
    border-color: #fff;
}
select:focus { border-color: #555; }
select option { background: #111; color: #fff; }

button {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    cursor: pointer;
    transition: all 0.15s;
}
button:hover { border-color: #666; background: #111; }

.button-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.5rem; }
.button-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.tool-btn.active { background: #fff; color: #000; border-color: #fff; }

.label-row { display: flex; justify-content: space-between; align-items: center; }
.value-bubble { font-size: 0.7rem; color: #888; font-family: var(--font-ui); }

.primary { border-color: #fff; }
.glow {
    background: #fff;
    color: #000;
    font-weight: 600;
}
.glow:hover { box-shadow: 0 0 20px rgba(255,255,255,0.3); }

.export-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
}

.persistence {
    display: flex;
    flex-direction: column;
}
.persistence button { flex: 1; }

/* ============ GLYPH OVERVIEW ============ */
.glyph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.glyph-item {
    position: relative;
    background: #0a0a0a;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.glyph-item:hover { border-color: #555; }
.glyph-item.active {
    border-color: #fff;
    background: #111;
}
.glyph-item.dragging {
    opacity: 0.5;
    border: 1px dashed #fff;
}

.preview-svg {
    width: 100%;
    flex: 1;
    display: block;
}

.char-label {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    font-family: var(--font-ui);
    color: var(--dim-text);
    padding: 0.25rem 0;
    letter-spacing: 0.05rem;
}
.glyph-item.active .char-label { color: #fff; }

.active-info {
    font-size: 1.2rem;
    font-family: var(--font-display);
    font-weight: 700;
    color: #fff;
    min-width: 1.5ch;
    text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.icon-btn {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.9rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.icon-btn:hover { opacity: 1; }

textarea {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.4rem;
    font-size: 0.8rem;
    font-family: var(--font-ui);
    outline: none;
    resize: vertical;
    min-height: 60px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: #111;
    border: 1px solid #333;
    padding: 2rem;
    width: 400px;
    max-width: 90%;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-family: var(--font-ui);
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin: 0;
}

.close-btn {
    font-size: 1.5rem;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
}
.close-btn:hover { color: #fff; }

.modal-body {
    display: flex;
    flex-direction: column;
}

.modal-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
}