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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    color: #e0e0e0;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
}

.legend-container {
    width: 15%;
    height: 100%;
    background-color: #1a1a1a;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

.legend-container h3 {
    margin-bottom: 15px;
    color: #d4af37;
    font-size: 1.1em;
}

#legend-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.legend-item {
    padding: 8px 12px;
    background-color: #2c2c2c;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s;
    border: 1px solid transparent;
}

.legend-item:hover {
    background-color: #3d3d3d;
}

.legend-item.active {
    background-color: #d4af37;
    color: #121212;
    font-weight: bold;
}

#reset-filter {
    margin-top: 15px;
    padding: 10px;
    background-color: #444;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

#reset-filter:hover {
    background-color: #555;
}

.graph-area {
    width: 55%;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
}

.episode-tabs {
    display: flex;
    background-color: #2c2c2c;
    padding: 10px;
    gap: 10px;
    border-bottom: 1px solid #444;
}

.episode-btn {
    padding: 8px 16px;
    background-color: #444;
    color: #ccc;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.episode-btn:hover {
    background-color: #555;
}

.episode-btn.active {
    background-color: #d4af37;
    color: #121212;
}

.graph-container {
    flex: 1;
    width: 100%;
    background-color: #1e1e1e;
    min-height: 300px;
}

/* ===== Timeline Bar ===== */
.timeline-bar {
    background: linear-gradient(to top, #0e0e0e, #1a1a1a);
    border-top: 1px solid #333;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline-info {
    text-align: center;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.seq-chapter {
    font-size: 0.7em;
    color: #888;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.seq-title {
    color: #d4af37;
    font-weight: bold;
    font-size: 1.05em;
    margin-top: 2px;
    transition: opacity 0.3s;
}

.seq-desc {
    color: #aaa;
    font-size: 0.82em;
    margin-top: 4px;
    line-height: 1.3;
    transition: opacity 0.3s;
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timeline-controls button {
    background: #2c2c2c;
    color: #d4af37;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9em;
    min-width: 36px;
    transition: background-color 0.2s;
}

.timeline-controls button:hover {
    background: #3d3d3d;
}

.timeline-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#seq-slider {
    flex: 1;
    accent-color: #d4af37;
    cursor: pointer;
}

.seq-counter {
    color: #888;
    font-size: 0.8em;
    min-width: 50px;
    text-align: right;
}

.chat-container {
    width: 30%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #1a1a1a;
}

.chat-header {
    padding: 20px;
    background-color: #2c2c2c;
    border-bottom: 1px solid #333;
    text-align: center;
}

.chat-header h2 {
    margin-bottom: 5px;
    color: #d4af37; /* Gold color for LOTR vibe */
}

.chat-header p {
    font-size: 0.9em;
    color: #aaa;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
    word-break: keep-all;
}

.message.user {
    align-self: flex-end;
    background-color: #2b5278;
    color: white;
    border-bottom-right-radius: 2px;
}

.message.ai {
    align-self: flex-start;
    background-color: #333;
    color: #e0e0e0;
    border-bottom-left-radius: 2px;
}

.message.system {
    align-self: center;
    background-color: transparent;
    color: #888;
    font-size: 0.9em;
    text-align: center;
}

.chat-input-area {
    padding: 20px;
    background-color: #2c2c2c;
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #444;
    background-color: #222;
    color: white;
    outline: none;
    font-size: 1em;
}

#chat-input:focus {
    border-color: #d4af37;
}

#send-button {
    padding: 12px 20px;
    background-color: #d4af37;
    color: #121212;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: background-color 0.2s;
}

#send-button:hover {
    background-color: #f1c40f;
}

#send-button:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background-color: #333;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    color: #aaa;
    font-style: italic;
    font-size: 0.9em;
}

/* Character Links in Chat */
.char-link {
    color: #d4af37;
    cursor: pointer;
    font-weight: bold;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.char-link:hover {
    color: #f1c40f;
    text-decoration-style: solid;
}
