:root {
    --bg-app: #000000;
    --bg-panel: #000000;
    --bg-input: #27272d;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #33333b;
    --radius: 6px;
}

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

/* Thay thế 'body' bằng lớp bao bọc của tool */
.typo-container {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    height: calc(100vh - var(--icatdev-header-height) - 80px); /* Tính toán chiều cao chính xác */
    overflow: hidden;
}

/* --- SCROLLBAR TINH TẾ --- */
.typo-container ::-webkit-scrollbar { width: 6px; }
.typo-container ::-webkit-scrollbar-track { background: transparent; }
.typo-container ::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 10px; }
.typo-container ::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* --- CONTROL PANEL (COMPACT) --- */
#control-panel {
    width: 320px;
    min-width: 320px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.panel-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.section-title::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}

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

/* Gom 2 control lên 1 hàng */
.row-group { display: flex; gap: 10px; }
.row-group .control-group { flex: 1; margin-bottom: 0; }

label {
    font-size: 11px;
    color: #cbd5e1;
    display: flex;
    justify-content: space-between;
}
.val-badge { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

input[type="text"], select {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    border-radius: var(--radius);
    font-size: 11px;
    outline: none;
    transition: border 0.2s;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }

/* Custom Slider */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    outline: none;
    margin: 8px 0;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Color Picker & File Upload */
.color-wrap { display: flex; gap: 8px; align-items: center; }
input[type="color"] {
    -webkit-appearance: none;
    width: 24px; height: 24px;
    border: none; border-radius: 4px;
    cursor: pointer; padding: 0; background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 4px; }

.file-btn {
    position: relative;
    background: #2e2e38; border: 1px dashed #52525b;
    padding: 8px; border-radius: var(--radius);
    text-align: center; font-size: 11px; color: #fff;
    cursor: pointer; transition: all 0.2s;
}
.file-btn:hover { background: #3f3f46; border-color: var(--accent); }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#fontStatus { font-size: 10px; color: #10b981; margin-top: 4px; text-align: right; }

/* Buttons */
.btn-primary {
    background: var(--accent); color: white;
    border: none; padding: 10px; border-radius: var(--radius);
    font-size: 12px; font-weight: 600; cursor: pointer;
    width: 100%; transition: background 0.2s;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-primary:hover { background: var(--accent-hover); }

.export-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.btn-sec {
    background: #27272a; color: #fff; border: 1px solid var(--border);
    padding: 8px; border-radius: var(--radius); font-size: 11px;
    cursor: pointer; transition: all 0.2s; font-weight: 500;
}
.btn-sec:hover { background: #3f3f46; border-color: #52525b; }

#palette-preview { display: flex; height: 12px; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.color-block { flex: 1; }

/* --- WORKSPACE --- */
#workspace {
    flex: 1; display: flex; justify-content: center; align-items: center;
    padding: 30px; position: relative;
    background: radial-gradient(circle at center, #1a1a20 0%, #09090b 100%);
}
canvas {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.7);
    border: 1px solid rgba(255,255,255,0.05);
}