:root {
    --hoyo-blue: #57BFF7;
    --hoyo-dark: #2d2d2d;
    
    /* Backgrounds */
    --hoyo-bg: #0A0A0A;
    --hoyo-white: #1D1F1E;
    
    /* Borders */
    --hoyo-border: rgba(255, 255, 255, 0.08);
    
    /* Text */
    --hoyo-text: rgba(255, 255, 255, 0.90);
    --hoyo-text-light: rgba(255, 255, 255, 0.45);
    
    /* Inputs */
    --input-bg: #2A2C2B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--hoyo-bg);
    color: var(--hoyo-text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === HEADER (NAVBAR) === */
.app-header {
    background: var(--hoyo-white);
    height: 56px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--hoyo-border);
    z-index: 10;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0px;
    font-weight: 700;
    font-size: 18px;
    color: var(--hoyo-text);
}

.brand-logo {
    width: 28px;
    height: 28px;
    background: var(--hoyo-blue);
    border-radius: 6px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* === GAME SELECTOR STYLES === */
.game-selector-wrapper {
    /* === margin-left: 20px;
    border-left: 1px solid var(--hoyo-border);
    padding-left: 20px;=== */
    height: 32px;
    display: flex;
    align-items: center;
}

.game-selector {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--hoyo-border);
    background: var(--input-bg);
    color: var(--hoyo-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    transition: 0.2s;
}

.game-selector:hover {
    border-color: var(--hoyo-blue);
    background: var(--hoyo-white);
}

.game-selector option {
    background: var(--hoyo-white);
    color: var(--hoyo-text);
    padding: 8px;
}

.header-actions button {
    background: transparent;
    border: 1px solid var(--hoyo-border);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--hoyo-text);
    cursor: pointer;
    transition: 0.2s;
}

.header-actions button:hover {
    border-color: var(--hoyo-blue);
    color: var(--hoyo-blue);
}

/* === MAIN WORKSPACE LAYOUT === */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === LEFT SIDEBAR (TOOLS) === */
.sidebar {
    width: 300px;
    background: var(--hoyo-white);
    border-right: 1px solid var(--hoyo-border);
    display: flex;
    flex-direction: column;
    z-index: 5;
    flex-shrink: 0;
}

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--hoyo-text-light);
    text-transform: uppercase;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

/* Form Styles */
.form-group { margin-bottom: 2px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--hoyo-text);
}

.input-field, .select-field {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--hoyo-border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
    background: var(--input-bg);
    color: var(--hoyo-text);
}

.input-field:focus {
    border-color: var(--hoyo-blue);
}

/* Palette Grid */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    margin-top: 8px;
}

.palette-btn {
    aspect-ratio: 1;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: transform 0.1s;
}
.palette-btn:hover { 
    transform: scale(1.1); 
    border-color: rgba(255,255,255);
    z-index: 1;
}

.palette-btn.selected {
    transform: scale(1.1);
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5); 
    z-index: 2;
}

/* === STYLE TOGGLE BUTTONS === */
.style-btn-group {
    display: flex;
    gap: 8px;
}

.style-btn {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--hoyo-border);
    border-radius: 6px;
    color: var(--hoyo-text-light);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.style-btn:hover {
    border-color: var(--hoyo-blue);
    color: var(--hoyo-text);
}

.style-btn.selected {
    border: 1px solid var(--hoyo-blue);
    box-shadow: 0 0 0 1px var(--hoyo-blue);
    color: white;
}

/* Color Pickers */
.color-row { display: flex; gap: 10px; align-items: center; }
input[type="color"] {
    border: none; width: 36px; height: 36px;
    background: none; cursor: pointer; border-radius: 50%;
}

/* Buttons */
.btn-primary {
    width: 100%;
    background: var(--hoyo-blue);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.btn-primary:hover { background: #3aa8d4; }

/* Rule List */
.rule-list {
    list-style: none;
    border-top: 1px solid var(--hoyo-border);
    margin-top: 20px;
    padding-top: 20px;
}
.rule-item {
    display: flex; justify-content: space-between; align-items: center;
}
.rule-tag {
    font-size: 13px; font-weight: 600; padding: 2px 6px;
    background: var(--input-bg);
    border: 1px solid var(--hoyo-border);
    border-radius: 4px;
    color: var(--hoyo-text);
}
.btn-del {
    background: none; border: none; color: var(--hoyo-text-light); cursor: pointer; font-size: 16px;
}
.btn-del:hover { color: #ff4d4f; }

/* === CENTER EDITOR (THE "PAPER") === */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: hidden;
    position: relative;
}

/* Toolbar */
.toolbar {
    background: var(--hoyo-white);
    border: 1px solid var(--hoyo-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 8px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.tool-icon {
    width: 24px; height: 24px;
    background: var(--input-bg);
    border-radius: 4px;
    display: inline-block; cursor: pointer;
    border: 1px solid var(--hoyo-border);
}

/* The Paper */
.editor-wrapper {
    flex: 1;
    background: var(--hoyo-white);
    border: 1px solid var(--hoyo-border);
    border-radius: 0 0 8px 8px; 
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    overflow: hidden;
}

.wiki-editor {
    flex: 1;
    width: 100%;
    border: none;
    padding: 30px 40px;
    font-family: 'Noto Sans', sans-serif;
    font-size: 15px;
    line-height: 1.8;
    color: var(--hoyo-text);
    outline: none;
    background: transparent;
    overflow-y: auto;
    white-space: pre-wrap; /* Penting untuk baris baru */
}

.wiki-editor[contenteditable="false"] {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Placeholder buatan untuk contenteditable */
.wiki-editor:empty:before {
    content: attr(placeholder);
    color: var(--hoyo-text-light);
    font-style: italic;
    pointer-events: none;
    display: block;
}

/* === RIGHT PANEL (PREVIEW & CODE) === */
.preview-panel {
    width: 320px;
    background: var(--hoyo-white);
    border-left: 1px solid var(--hoyo-border);
    display: flex;
    flex-direction: column;
    z-index: 5;
    flex-shrink: 0;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--hoyo-border);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--hoyo-text-light);
}

.preview-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-family: 'Noto Sans', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--hoyo-text);
}

.code-wrapper {
    height: 150px;
    border-top: 1px solid var(--hoyo-border);
    display: flex;
    flex-direction: column;
}

.code-box {
    flex: 1;
    background: #111;
    color: #abb2bf;
    border: none;
    padding: 15px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    resize: none;
    outline: none;
}

.btn-copy-float {
    background: var(--hoyo-blue);
    color: white;
    border: none;
    padding: 12px;
    font-weight: 600;
    cursor: pointer;
}
.btn-copy-float:hover { background: #3aa8d4; }

/* Helpers */
.hidden { display: none !important; }

.checkbox-group {
    display: flex;
    gap: 8px;
}

.checkbox-group label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--hoyo-text-light);
    background: var(--input-bg);
    border: 1px solid var(--hoyo-border);
    border-radius: 6px;
    padding: 8px;
    transition: all 0.2s;
}

.checkbox-group label:hover {
    border-color: var(--hoyo-blue);
    color: var(--hoyo-text);
}

.checkbox-group input[type="checkbox"] {
    display: none;
}

/* Modern toggle button style for checkboxes */
.checkbox-group label:has(input:checked) {
    border-color: var(--hoyo-blue);
    color: white;
    background: rgba(87, 191, 247, 0.1);
}

/* Toast */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--hoyo-blue); color: white; padding: 10px 20px; border-radius: 20px;
    opacity: 0; transition: 0.3s; pointer-events: none; font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.mini-palette {
    display: flex;
    gap: 2px;
    align-items: center;
}

.palette-dot {
    width: 20px;
    height: 20px;
    border-radius: 10px;
    border: 1px solid var(--hoyo-border);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    padding: 0;
}

.palette-dot:hover {
    transform: scale(1.1);
    border-color: white;
}

.palette-dot.active {
    border: 2px solid var(--hoyo-blue);
    transform: scale(1.1);
}

.style-btn-mini {
    width: 24px;
    height: 24px;
    justify-content: center;
    background: var(--input-bg);
    border: 1px solid var(--hoyo-border);
    color: var(--hoyo-text);
    padding: 2px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px;
    transition: 0.2 s;

}

.style-btn-mini:hover {
    border-color: var(--hoyo-blue);
    background: var(--hoyo-white);
}