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

<style>
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
</style>

body {
    font-family: "Lato", sans-serif;
    font-weight: 300; /* Imposta il peso normale (regular) come predefinito */
    background-color: #f4f5f7; 
    color: #333; 
    height: 100vh; 
    display: flex; 
    overflow: hidden; 
}

input, textarea, button, select {font-family: inherit;}

.app-container { display: flex; width: 100%; height: 100%; position: relative; }

.sidebar { width: 280px; background-color: #2c3e50; color: #ecf0f1; display: flex; flex-direction: column; border-right: 1px solid #1a252f; transition: width 0.3s ease; position: relative; z-index: 10; }
.sidebar.collapsed { width: 0; overflow: hidden; border: none; }
.sidebar-header { padding: 15px 20px; font-size: 1.1rem; font-weight: bold; border-bottom: 1px solid #34495e; display: flex; flex-direction: column; gap: 10px; }
.sidebar-top-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.project-title-input { font-size: 1rem; font-weight: bold; color: #bc5a45; background: transparent; border: none; outline: none; width: 100%; font-family: 'Inter', sans-serif; display: none; }

.header-icon-btn { background: transparent; color: #bdc3c7; border: 1px solid #34495e; border-radius: 4px; padding: 4px 8px; font-size: 0.85rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 4px; }
.header-icon-btn:hover { background: #bc5a45; color: white; border-color: #bc5a45; }

.lang-select { background: #34495e; color: #ecf0f1; border: 1px solid #4e6d8d; border-radius: 4px; padding: 3px 6px; font-size: 0.8rem; outline: none; cursor: pointer; transition: border-color 0.2s; }
.lang-select:focus { border-color: #bc5a45; }

.project-tree { padding: 15px; overflow-y: auto; flex: 1; }
.section-header-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: #95a5a6; margin-bottom: 8px; margin-top: 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.05); padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.section-title-left { display: flex; align-items: center; gap: 6px; }
.small-add-btn { background: #34495e; color: #bc5a45; border: 1px solid #bc5a45; border-radius: 3px; padding: 2px 6px; cursor: pointer; font-size: 0.75rem; font-weight: 500; }
.small-add-btn:hover { background: #bc5a45; color: white; }

.chapter-group { margin-bottom: 12px; }
.chapter-header-item { font-size: 0.85rem; color: #bdc3c7; margin-bottom: 4px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.03); padding: 6px 8px; border-radius: 4px; }
.chapter-title-click { display: flex; align-items: center; gap: 6px; cursor: pointer; flex: 1; }
.chapter-actions { display: flex; align-items: center; gap: 8px; }
.edit-icon { color: #7f8c8d; cursor: pointer; font-size: 0.85rem; transition: color 0.2s; }
.edit-icon:hover { color: #bc5a45; }

.chapter-scenes-container, .section-items-container { margin-top: 4px; padding-left: 10px; display: flex; flex-direction: column; }
.chapter-scenes-container.collapsed, .section-items-container.collapsed { display: none; }

.nav-item { padding: 7px 10px; margin-bottom: 3px; border-radius: 4px; font-size: 0.9rem; background-color: rgba(255,255,255,0.03); display: flex; justify-content: space-between; align-items: center; margin-left: 5px; }
.nav-item:hover { background-color: #34495e; }
.nav-item.active { background-color: #bc5a45; color: white; font-weight: 500; }
.nav-item-content { flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-count-badge { font-size: 0.75rem; background: rgba(0,0,0,0.2); padding: 2px 6px; border-radius: 10px; color: #bdc3c7; margin-right: 6px; }

.main-editor { flex: 1; display: flex; flex-direction: column; background-color: #ffffff; position: relative; }
.editor-header { padding: 20px 40px; border-bottom: 1px solid #e0e0e0; display: flex; justify-content: space-between; align-items: center; background: #ffffff; }
.header-left-group { display: flex; align-items: center; gap: 15px; width: 50%; }
.collapse-btn { background: #f0f2f5; border: 1px solid #dcdde1; color: #2c3e50; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.collapse-btn:hover { background: #e1e4e8; border-color: #bc5a45; }
.main-title-input { width: 100%; font-size: 1.6rem; font-weight: bold; border: none; outline: none; color: #2c3e50; background: transparent; font-family: 'Inter', sans-serif; }

.header-right-actions { display: flex; align-items: center; gap: 12px; }
.live-stats { font-size: 0.82rem; color: #7f8c8d; display: flex; gap: 8px; align-items: center; background: #f8f9fa; padding: 6px 12px; border-radius: 6px; border: 1px solid #e9ecef; }

.minimal-format-bar { display: flex; gap: 6px; padding: 8px 40px; background-color: #fafbfc; border-bottom: 1px solid #e0e0e0; align-items: center; justify-content: space-between; }
.format-bar-group { display: flex; gap: 6px; align-items: center; }
.format-btn { background: white; border: 1px solid #dcdde1; border-radius: 4px; padding: 4px 10px; font-size: 0.85rem; cursor: pointer; color: #2c3e50; font-weight: bold; transition: all 0.2s; font-family: 'Inter', sans-serif; }
.format-btn:hover { background: #f0f2f5; border-color: #bc5a45; color: #bc5a45; }

.writing-area { 
    flex: 1; 
    padding: 40px 40px; 
    border: none; 
    outline: none; 
    font-family: 'Open Sans', sans-serif; 
    font-size: 1.00rem; 
    line-height: 1.50; 
    color: #2c3e50; 
    background-color: #f7f6f3; 
    overflow-y: auto; 
    white-space: pre-wrap; 
    word-break: break-word; 
    caret-color: #ff2d55; 
}

.writing-area * {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    background: transparent !important;
}

.character-sheet-container { flex: 1; padding: 30px 40px; overflow-y: auto; background-color: #fcfcfc; }
.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.char-field-group { display: flex; flex-direction: column; }
.char-field-group.full-width { grid-column: span 2; }
.char-label { font-size: 0.8rem; text-transform: uppercase; font-weight: bold; color: #7f8c8d; margin-bottom: 6px; }
.char-input, .char-textarea { padding: 10px; border: 1px solid #dcdde1; border-radius: 6px; font-family: 'Inter', inherit; font-size: 0.95rem; outline: none; background: white; transition: border-color 0.2s; }
.char-input:focus, .char-textarea:focus { border-color: #bc5a45; }
.char-textarea { height: 90px; resize: vertical; }

.structure-panel { width: 400px; background-color: #2c3e50; color: #ecf0f1; border-left: 1px solid #1a252f; display: flex; flex-direction: column; transition: width 0.3s ease; z-index: 10; }
.structure-panel.collapsed { width: 0; overflow: hidden; border: none; }

.panel-header { display: flex; flex-direction: column; align-items: stretch; padding: 15px; border-bottom: 1px solid #34495e; }

.dict-tabs { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; margin-top: 10px; }
.dict-tab { flex: 1; padding: 6px 4px; background: #34495e; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; color: #bdc3c7; font-size: 0.72rem; text-align: center; transition: all 0.2s; }
.dict-tab:hover { background: #4e6d8d; color: white; }
.dict-tab.active { background: #bc5a45; color: white; }

.notes-content { padding: 20px; overflow-y: auto; flex: 1; }
.note-group { margin-bottom: 16px; }
.note-label { display: block; font-size: 0.8rem; color: #95a5a6; margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
.note-input { width: 100%; padding: 8px 10px; border: 1px solid #4e6d8d; border-radius: 4px; font-size: 0.9rem; background: #34495e; color: #ecf0f1; outline: none; font-family: 'Inter', sans-serif; transition: border-color 0.2s; }
.note-input:focus { border-color: #bc5a45; }
.note-input::placeholder { color: #7f8c8d; font-style: italic; }
textarea.note-input { height: 60px; resize: vertical; }
select.note-input#pov-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    padding: 8px 24px 8px 0;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #7f8c8d;
    cursor: pointer;
    outline: none;
    transition: border-bottom-color 0.2s ease;
}

select.note-input#pov-input:focus {
    border-bottom-color: #bc5a45;
}

select.note-input#pov-input.selected {
    color: #ffffff;
}

select.note-input#pov-input option {
    background: #34495e;
    color: #ecf0f1;
}
.beat-item { background: rgba(255,255,255,0.03); border: 1px solid #34495e; border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.beat-item input { width: 100%; border: none; outline: none; font-size: 0.9rem; background: transparent; color: #ecf0f1; font-family: 'Inter', sans-serif; }
.beat-item input::placeholder { color: #7f8c8d; font-style: italic; }

.filter-btn-dark { padding: 5px 10px; border-radius: 15px; border: 1px solid #4e6d8d; background: #34495e; cursor: pointer; font-size: 0.75rem; font-weight: 500; color: #bdc3c7; transition: all 0.2s; }
.filter-btn-dark:hover { background: #4e6d8d; color: white; }
.filter-btn-dark.active { background: #bc5a45; color: white; border-color: #bc5a45; }

.dict-card-dark { background: #34495e; border: 1px solid #4e6d8d; border-radius: 6px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); position: relative; }
.dict-card-dark-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.dict-card-dark-title { font-size: 1rem; font-weight: bold; color: #bc5a45; }
.dict-card-dark-body p { font-size: 0.88rem; color: #ecf0f1; margin-bottom: 4px; line-height: 1.4; }
.dict-card-dark-body .example-text { font-style: italic; color: #95a5a6; font-size: 0.82rem; }
.card-actions-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; justify-content: flex-end; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal-box { background: white; width: 450px; padding: 25px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); display: flex; flex-direction: column; gap: 15px; color: #333; }
.modal-box h3 { color: #2c3e50; font-size: 1.2rem; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; }
.modal-field label { font-size: 0.8rem; font-weight: bold; text-transform: uppercase; color: #7f8c8d; }
.modal-field input, .modal-field select, .modal-field textarea { padding: 8px 10px; border: 1px solid #dcdde1; border-radius: 4px; font-size: 0.95rem; outline: none; font-family: 'Inter', sans-serif; transition: border-color 0.2s; }
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color: #bc5a45; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.btn-cancel { background: #e0e0e0; color: #333; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: 500; font-family: 'Inter', sans-serif; }
.btn-save { background: #bc5a45; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-weight: 500; font-family: 'Inter', sans-serif; }

/* Divisori tra i pannelli */
.resizer {
    width: 8px;
    cursor: col-resize;
    background-color: #2c3e50; /* Colore ben visibile */
    z-index: 100;
    user-select: none;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

/* Cambia colore quando il mouse ci passa sopra o trascina */
.resizer:hover, .resizer.dragging {
    background-color: #e74c3c !important;
}

/* Importante: assicurati che le sidebar non abbiano !important sulla larghezza nel CSS */
.sidebar, .structure-panel {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 15px;
    margin-top: auto; /* Lo spinge in fondo alla sidebar */
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    color: #95a5a6;
    text-align: center;
    font-style: italic;
    letter-spacing: 0.5px;
}

/* Contenitore flessibile per i tag del dizionario */
.dict-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
}

/* Stile del singolo tag a pillola */
.dict-tag {
    display: inline-flex;
    align-items: center;
    background-color: #6d757a;
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.dict-tag:hover {
    background-color: #bc5a45; /* Diventa del colore rosso mattone della tua interfaccia */
}

/* La "x" per eliminare il tag */
.tag-close {
    margin-left: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: #e0e0e0;
    transition: color 0.15s ease;
}

.tag-close:hover {
    color: #ffffff; /* La x risalta quando ci passi sopra */
}
/* Stili minimalisti per la scheda Scena */
.minimal-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #ecf0f1;
    padding: 8px 0;
    outline: none;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    overflow: hidden;
    display: block;
    margin-bottom: 4px;
    line-height: 1.4;
    transition: border-bottom-color 0.2s ease;
}

.minimal-input:focus {
    border-bottom-color: #bc5a45;
}

.minimal-input::placeholder {
    color: #7f8c8d;
    font-style: italic;
    opacity: 0.7;
}

.sub-beat-textarea {
    margin-left: 20px;
    width: calc(100% - 20px);
    font-size: 0.85rem;
    color: #bdc3c7;
}

.beat-section {
    margin-top: 20px;
}

.beat-label {
    font-size: 0.7rem;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}
