:root {
    /* Color Palette - Design Specified */
    --bg-outer: #2d3e41; /* Cinza-azulado escuro */
    --bg-paper: #f5ebd9; /* Creme/Bege claro texturizado */
    --color-terracotta: #b25a3c; /* Laranja/Terracota */
    --color-teal: #0d4240; /* Verde-azulado escuro */
    --text-white: #ffffff;
    
    --text-primary: #2f464d;
    --text-muted: #5d757d;
    --border-primary: var(--color-terracotta);
    --border-subtle: #e3e1d7;
    --accent-bg: #f3f0e6;
    --header-bg: #2f464d;
    --header-text: #f9f7f0;
    
    /* Typography */
    --font-display: 'Cinzel', serif;
    --font-body: 'EB Garamond', serif;
    --font-mono: 'Courier New', Courier, monospace;
}

body.dark-mode {
    /* Color Palette - Dark Mode */
    --bg-app: #2f464d; /* Deep slate background */
    --text-primary: #4e8697; /* Beige text */
    --text-muted: #90a4ae;
    --border-primary: #c7603b; /* Terracotta orange borders remain constant */
    --border-subtle: #455a64; /* Slate divider */
    --accent-bg: #24363c; /* Dark slate for inner cards/panels */
    --header-bg: #c7603b;
    --header-text: #2f464d;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app, #f9f7f0);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 19px; /* Enhanced size for EB Garamond legibility */
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Typography Overrides */
h1, h2, h3, .section-title, .block-header, .btn {
    font-family: var(--font-display);
    letter-spacing: 0.05em;
}

/* Header principal */
.app-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--border-primary);
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-container h1 {
    font-size: 1.3rem;
    margin: 0;
    text-transform: uppercase;
    font-weight: 800;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.app-main {
    max-width: 950px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Buttons (Terracotta styling) */
.btn {
    padding: 8px 16px;
    border: 1.5px solid var(--border-primary);
    cursor: pointer;
    font-weight: 700;
    background: transparent;
    color: var(--border-primary);
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.btn:hover,
.btn.active {
    background-color: var(--border-primary);
    color: var(--bg-app);
}

.btn.active:hover {
    background-color: transparent;
    color: var(--border-primary);
}

body.dark-mode .btn.active {
    background-color: var(--border-primary);
    color: var(--bg-app);
}

body.dark-mode .btn.active:hover {
    background-color: transparent;
    color: var(--border-primary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: rgba(128, 128, 128, 0.15);
}

/* Layout da Ficha - Horizontal */
.conflict-sheet {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 900px;
    margin: 2rem auto;
    background-color: var(--bg-paper);
    padding: 2rem;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Bloco Horizontal */
.block-section {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle);
    background: transparent;
    margin-bottom: 1rem;
}

.block-header {
    background-color: var(--color-terracotta);
    color: var(--text-white);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    padding: 10px 20px;
    font-weight: bold;
    text-transform: uppercase;
    width: 100%;
}

/* Cores específicas para headers */
.block-section:nth-child(2) .block-header { background-color: var(--color-terracotta); }
.block-section:nth-child(3) .block-header { background-color: var(--color-teal); }
.block-section:nth-child(4) .block-header { background-color: var(--color-terracotta); }
.block-section:nth-child(5) .block-header { background-color: var(--color-terracotta); }

.block-body {
    padding: 20px;
    background-color: transparent;
}

/* Inputs */
input[type="text"], textarea {
    font-family: var(--font-body);
    font-size: 1.15rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    padding: 6px 0;
    border-bottom: 1.5px solid transparent;
    transition: border-color 0.2s;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-bottom-color: var(--border-primary); /* Terracotta focus line */
}

.input-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: bold;
    text-transform: uppercase;
    border-bottom: 1.5px solid var(--border-subtle);
    margin-bottom: 0.5rem;
}

.input-title:focus {
    border-bottom-color: var(--border-primary);
}

.input-desc {
    font-size: 1.15rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Item Rows */
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.item-row:last-child {
    border-bottom: none;
}

.item-inputs {
    flex: 1;
}

.input-item-title {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1rem;
    color: var(--text-primary);
}

.input-item-desc {
    font-size: 1.05rem;
    color: var(--text-muted);
}

/* Counters */
.counters-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.counter-box {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border-primary); /* Terracotta */
    padding: 2px 8px;
    gap: 4px;
    background-color: var(--accent-bg);
}

.counter-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: bold;
    cursor: pointer;
    font-size: 1.2rem;
    transition: opacity 0.15s;
}

.counter-btn:hover {
    opacity: 0.7;
    color: var(--border-primary);
}

.counter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-value {
    font-family: var(--font-mono);
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    color: var(--text-primary);
}

/* Threat Cards */
.threat-card {
    border: 1.5px solid var(--border-primary); /* Terracotta */
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--accent-bg);
}

.threat-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid var(--border-primary);
}

.threat-header-row .input-threat-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
}

.threat-sub-header {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: var(--border-primary);
    border-bottom: 1px dashed var(--border-subtle);
    padding-bottom: 4px;
}

/* Utilities */
.btn-delete-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.15s;
}

.btn-delete-item:hover {
    color: var(--border-primary);
}

.btn-add-block {
    background: transparent;
    border: 1.5px solid currentColor;
    color: inherit;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.btn-add-block:hover {
    background-color: var(--border-primary);
    border-color: var(--border-primary);
    color: var(--bg-app) !important;
}

/* Drag and Drop Visuals */
.dragging {
    opacity: 0.4;
    border: 1.5px dashed var(--border-primary) !important;
}

/* WebP Images Container styling */
.counter-icon img {
    background: transparent;
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 600px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .item-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .counters-group {
        width: 100%;
        justify-content: flex-end;
    }
}
