:root {
    --bg-color: #f5f5f5;
    --text-color: #1a1a1a;
    --panel-bg: #ffffff;
    --panel-border: #e0e0e0;
    --input-bg: #ebebeb;
    --accent-color: #4CAF50; /* Primary Green */
    --accent-hover: #5cb85c;
    --secondary-accent-text: #2E8B57; /* Darker Green for text */
    --text-muted: #666666;
    --text-inverted: #ffffff;
    --text-shadow-color: rgba(255, 255, 255, 0.5);
    --bubble-text-shadow-color: #ffffff;
    --switch-bg: #ccc;
    --switch-checked-unhinged: #ff6b6b;
    --switch-checked-twist: #B22222; /* Dark Red */
    --switch-checked-roleplay: #4C8BF5;
    --body-bg-image: linear-gradient(to bottom, #f5f5f5, #e9e9e9);
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #ffffff;
    --panel-bg: #1e1e1e;
    --panel-border: #333;
    --input-bg: #2d2d2d;
    --accent-color: #4CAF50;
    --accent-hover: #66bb6a;
    --secondary-accent-text: #66bb6a; /* Lighter Green for dark mode text */
    --text-muted: #aaa;
    --text-inverted: #1a1a1a;
    --text-shadow-color: rgba(0, 0, 0, 0.5);
    --bubble-text-shadow-color: #000;
    --switch-bg: #333;
    --body-bg-image: linear-gradient(to bottom, #121212, #0d0d0d);
}

body {
    background-color: var(--bg-color);
    background-image: var(--body-bg-image);
    color: var(--text-color);
    font-family: 'Fredoka', sans-serif;
    padding: 20px;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
    opacity: 1;
}

.loading-logo {
    height: 80px;
    margin-bottom: 30px;
    animation: float 6s ease-in-out infinite;
}

.loader {
    border: 8px solid var(--panel-border);
    border-top: 8px solid var(--accent-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loading-screen p {
    color: var(--text-color);
    font-size: 20px;
    font-weight: bold;
}

body.modal-open {
    overflow: hidden;
}

#app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    width: 100%;
    border-bottom: 1px solid var(--panel-border);
}

#app-logo {
    height: 50px;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px) rotate(-1deg); }
    50% { transform: translateY(-5px) rotate(1deg); }
    100% { transform: translateY(0px) rotate(-1deg); }
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--panel-border);
    position: relative;
}

#generation-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: var(--text-muted);
    background-color: var(--panel-bg);
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
}

#generation-counter strong {
    color: var(--text-color);
}

#tabs {
    display: flex;
    gap: 10px;
    padding-bottom: 5px;
}

.tab-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid transparent;
    background-color: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
    top: 0;
}

.tab-btn:hover:not(.active) {
    background-color: var(--panel-bg);
    color: var(--text-color);
    top: -2px;
}

.tab-btn.active {
    color: var(--text-color);
    border-bottom-color: var(--accent-color);
    background-color: var(--panel-bg);
}

#generator-view {
    display: flex; /* Changed from grid to flex */
    gap: 20px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

@media (min-width: 992px) {
    #generator-view {
        flex-wrap: nowrap; /* Prevent wrapping on large screens */
    }
}

#generator-controls-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1 1 400px; /* Flex properties for responsive controls column */
    min-width: 350px;
}

#generator-output-column {
    display: flex;
    flex-direction: column;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: relative;
    flex: 2 1 500px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

/* Add styles for floating window behavior */
#generator-output-column.floating-window {
    position: absolute;
    right: 20px;
    top: 100px;
    width: 500px;
    max-width: 95vw;
    height: 75vh;
    min-height: 300px;
    resize: both;
    overflow: hidden;
    z-index: 1000;
    border: 1px solid var(--accent-color);
}

#output-window-header {
    padding: 12px 16px;
    background-color: var(--bg-color);
    cursor: move;
    border-bottom: 1px solid var(--panel-border);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

#output-window-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.window-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.window-btn:hover {
    background: var(--accent-color);
    color: white;
}

#settings-panel {
    background-color: var(--panel-bg);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--panel-border);
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-section h2 {
    font-size: 20px;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--secondary-accent-text);
    font-weight: 700;
}

#character-selector-wrapper {
    display: flex;
    justify-content: center;
}

#official-characters {
    width: 100%;
}

#official-characters h3 {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
}

#custom-characters-selection h3 {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
}

#custom-character-selector p {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

#character-selector-container {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 20px;
}

#character-selector, #community-char-sub-selector {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 15px;
}

#character-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding: 15px;
}

.character-label {
    width: 100%;
    box-sizing: border-box;
    height: auto;
    min-height: 45px;
    display: flex;
    align-items: center;
    margin: 0;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 18px;
    border: 3px solid transparent;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: visible; /* Changed from hidden to visible for tooltips */
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.character-label.selected {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.character-label.selected::after {
    content: '✔';
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 18px;
    color: var(--text-inverted);
    background-color: var(--accent-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.character-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--bg-color), var(--panel-bg), var(--bg-color));
    background-size: 200% 200%;
    animation: gradientBG 15s ease infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.character-label:hover::before {
    opacity: 1;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.character-label img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: contain;
    background: var(--bg-color);
}

#interact-character-selector .character-label img {
    width: 24px;
    height: 24px;
}

.character-label input {
    display: none;
}

.character-label input:checked + img + span {
    font-weight: bold;
}

/* Add character tooltip styles */
.character-tooltip {
    position: fixed;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 200px;
    max-width: 300px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.character-label:hover .character-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.character-tooltip strong {
    display: block;
    margin-bottom: 8px;
    color: var(--secondary-accent-text);
    font-size: 16px;
}

.character-tooltip p {
    margin: 0 0 8px 0;
    color: var(--text-color);
}

.character-tooltip em {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

/* Character action buttons for favorites and likes */
.character-label .subtle-btn:hover {
    transform: scale(1.15);
}

.character-label .subtle-btn:active {
    transform: scale(0.95);
}

#conversation-container, #modal-conversation-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    background-color: var(--bg-color); /* Slight contrast from panel */
    height: 100%;
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

#conversation-container::-webkit-scrollbar,
#modal-conversation-container::-webkit-scrollbar {
    width: 6px;
}

#conversation-container::-webkit-scrollbar-track,
#modal-conversation-container::-webkit-scrollbar-track {
    background: transparent;
}

#conversation-container::-webkit-scrollbar-thumb,
#modal-conversation-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}

.message-row {
    display: flex;
    opacity: 0;
    animation: fadeIn 0.4s ease-out forwards;
    gap: 12px;
    align-items: flex-start; /* Align to top for longer messages */
    max-width: 100%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-row.align-left {
    justify-content: flex-start;
    flex-direction: row;
    padding-right: 20%;
}

.message-row.align-right {
    justify-content: flex-end;
    flex-direction: row-reverse;
    padding-left: 20%;
}

.character-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%; /* Reverted to round icons */
    object-fit: contain;
    background-color: var(--input-bg);
    padding: 4px;
    border: 2px solid var(--panel-border);
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.character-icon:hover {
    transform: scale(1.05);
}

.character-icon.speaking {
    animation: speakPulse 2s infinite ease-in-out;
    border-color: var(--glow-color, var(--accent-color));
}

@keyframes speakPulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--glow-rgb), 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(var(--glow-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--glow-rgb), 0); }
}

.message-bubble {
    background-color: var(--panel-bg);
    /* Bring back stripey design */
    background-image: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 15px,
        rgba(0, 0, 0, 0.02) 15px,
        rgba(0, 0, 0, 0.02) 30px
    );
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.5;
    position: relative;
    border: 2px solid transparent;
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 60px;
}

/* Reverted to original form: rounded bubbles for both sides */
.message-row.align-left .message-bubble {
    border-top-left-radius: 18px;
}

.message-row.align-right .message-bubble {
    border-top-right-radius: 18px;
    background-color: var(--panel-bg); /* Use standard panel bg for all bubbles */
}

/* Original "Bold" style support but cleaner */
.message-bubble strong {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.dialogue-text {
    display: block;
    font-weight: 500;
}

/* Retain special styles but modernize */
.message-bubble[style*="background-color"] {
    color: #fff; /* Ensure text is white on colored bubbles */
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); /* Subtle readability shadow */
    /* Add contrast stripes to colored bubbles */
    background-image: repeating-linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.1) 15px,
        transparent 15px,
        transparent 30px
    );
}

/* Dandy's Rainbow Style - cleaner */
.Dandy .message-bubble {
    background: linear-gradient(120deg, #ff4e50, #f9d423, #42f59e, #4776e6, #8e54e9);
    background-size: 300% 300%;
    animation: rainbow-flow 8s ease infinite;
    color: white;
    border: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.message-bubble.font-default, .font-dropdown option[value="default"] {
    font-family: 'Fredoka', sans-serif;
}

.message-bubble.font-apple-ii, .font-dropdown option[value="apple-ii"] {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace !important;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 18px;
}

.message-bubble.font-monospace, .font-dropdown option[value="monospace"] {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace !important;
    font-weight: normal;
}

.message-bubble.font-serif, .font-dropdown option[value="serif"] {
    font-family: 'Times New Roman', 'Georgia', serif !important;
}

.message-bubble.font-comic, .font-dropdown option[value="comic"] {
    font-family: 'Comic Sans MS', 'Comic Sans', cursive !important;
    font-weight: bold;
}

.message-bubble.font-impact, .font-dropdown option[value="impact"] {
    font-family: 'Impact', 'Charcoal', sans-serif !important;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-bubble.font-papyrus, .font-dropdown option[value="papyrus"] {
    font-family: 'Papyrus', 'Trebuchet MS', fantasy !important;
    font-size: 18px;
}

.message-bubble.font-brush-script {
    font-family: 'Brush Script MT', 'Brush Script Std', cursive;
    font-size: 20px;
}

.message-bubble.font-chalkduster {
    font-family: 'Chalkduster', 'Chalkboard SE', fantasy;
}

.message-bubble.font-copperplate {
    font-family: 'Copperplate', 'Copperplate Gothic Light', serif;
    text-transform: uppercase;
}

.message-bubble.font-lucida {
    font-family: 'Lucida Console', 'Monaco', monospace;
    font-size: 14px;
}

.message-bubble.font-palatino {
    font-family: 'Palatino', 'Palatino Linotype', 'Book Antiqua', serif;
}

/* Update FF7 message style */
.message-bubble.ff7-style {
    border: solid 1px #424542;
    box-shadow: 1px 1px #e7dfe7,
                -1px -1px #e7dfe7,
                1px -1px #e7dfe7,
                -1px 1px #e7dfe7,
                0 -2px #9c9a9c,
                -2px 0 #7b757b,
                0 2px #424542;
    padding: 15px 20px;
    margin: 5px 0;
    background: #04009d;
    background: -moz-linear-gradient(top, #04009d 0%, #06004d 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#04009d), color-stop(100%,#06004d));
    background: -webkit-linear-gradient(top, #04009d 0%,#06004d 100%);
    background: -o-linear-gradient(top, #04009d 0%,#06004d 100%);
    background: -ms-linear-gradient(top, #04009d 0%,#06004d 100%);
    background: linear-gradient(to bottom, #04009d 0%,#06004d 100%);
    border-radius: 7px;
    position: relative;
    text-shadow: none;
    max-width: 75%;
}

.message-bubble.ff7-style .dialogue-text {
    color: #eff1ff;
    text-shadow: 2px 2px #212421,
                 1px 1px #212021;
    font-family: Verdana, sans-serif;
    font-size: 20px;
    font-weight: normal;
    margin: 5px 0;
    line-height: 1.4;
}

.message-bubble.ff7-style.font-apple-ii .dialogue-text {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-bubble.ff7-style.font-monospace .dialogue-text {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-weight: normal;
}

.message-bubble.ff7-style.font-serif .dialogue-text {
    font-family: 'Times New Roman', 'Georgia', serif;
    font-style: italic;
}

.message-bubble.ff7-style.font-comic .dialogue-text {
    font-family: 'Comic Sans MS', cursive;
    font-weight: bold;
}

.message-bubble.ff7-style.font-impact .dialogue-text {
    font-family: 'Impact', sans-serif;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-bubble.ff7-style:after {
    content: '▼';
    position: absolute;
    bottom: -20px;
    right: 20px;
    color: #eff1ff;
    text-shadow: 2px 2px #212421,
                 1px 1px #212021;
    animation: ff7Arrow 1s infinite;
}

/* Preview specific adjustments */
#edit-message-preview .message-bubble.ff7-style {
    margin: 10px 0;
    min-width: 200px;
}

#edit-message-preview .message-bubble.ff7-style .dialogue-text {
    font-size: 16px; /* Slightly smaller in preview */
}

/* Maintain the same arrow animation */
@keyframes ff7Arrow {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.message-bubble.twisted {
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 5px #ff4d4d;
}

.dialogue-text {
    display: block;
    padding: 5px 10px;
    font-weight: 700;
    color: #ffffff;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.message-bubble strong {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    opacity: 0.8;
}

.Dandy .message-bubble {
    background: linear-gradient(to bottom, rgba(255,255,255,0.9) 0%, #ff4e50 20%, #f9d423 40%, #42f59e 60%, #4776e6 80%, #8e54e9 100%);
    color: #ffffff;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    border-color: #FFEB3B;
}

@keyframes rainbow-flow {
    0%{background-position:0% 50%}
    50%{background-position:100% 50%}
    100%{background-position:0% 50%}
}

.Astro .message-bubble {
    background-color: #6495ED; /* Light Blue */
    color: #ffffff;
}

.Pebble .message-bubble {
     background-color: #808080; /* Grey */
     color: #ffffff;
}

.Pepper .message-bubble,
.message-bubble.Pepper {
    /* Pepper: streamlined, static, and minimal */
    background-color: #b33a2f;
    color: #ffffff;
    border: 2px solid rgba(0,0,0,0.32);
    padding: 8px 12px;
    font-size: 22px;
    line-height: 1.25;
    border-radius: 8px;
    transform: none;
    background-image: none;
    background-blend-mode: normal;
    text-shadow: none;
    box-shadow: none;
    transition: none;
}

.message-bubble.werewolf {
    border-color: #b22222;
    box-shadow: 0 0 10px rgba(178,34,34,0.4);
}

.message-bubble.peppermessage {
    /* Pepper message style — streamlined, stable, with subtle polka-dot texture */
    background-color: #b33a2f;
    color: #ffffff;
    border: 2px solid rgba(0,0,0,0.32);
    padding: 10px 14px;
    font-size: 22px;
    line-height: 1.25;
    border-radius: 8px;
    transform: none;
    box-shadow: none;
    transition: none;
    display: inline-block;
    max-width: 75%;
    white-space: normal;
    word-break: break-word;
    /* Keep a very subtle polka-dot texture but remove movement and heavy overlays */
    background-image:
        radial-gradient(circle at 12% 12%, rgba(255,255,255,0.06) 0 6px, transparent 6px),
        radial-gradient(circle at 62% 38%, rgba(255,255,255,0.04) 0 5px, transparent 5px),
        linear-gradient(180deg, rgba(0,0,0,0.03), rgba(0,0,0,0.02));
    background-repeat: no-repeat;
    background-size: 220px 220px, 160px 160px, 100% 100%;
    background-position: left top, center center, 0 0;
    background-blend-mode: overlay, overlay, normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* reduce visual clutter */
    filter: none;
    opacity: 1;
    pointer-events: auto;
}

/* Improved, subtle text outline for legibility without overpowering the art */
.message-bubble.peppermessage .dialogue-text,
.message-bubble.peppermessage {
    /* Prefer a small stroke where supported, otherwise a thin shadow */
    -webkit-text-stroke: 0.8px rgba(0,0,0,0.9);
    text-stroke: 0.8px rgba(0,0,0,0.9); /* non-standard but helpful when available */
    text-shadow:
        -0.8px -0.8px 0 rgba(0,0,0,0.85),
         0.8px -0.8px 0 rgba(0,0,0,0.85),
        -0.8px  0.8px 0 rgba(0,0,0,0.85),
         0.8px  0.8px 0 rgba(0,0,0,0.85);
}

/* Ensure text remains bold and slightly larger for readability */
.message-bubble.peppermessage .dialogue-text {
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 22px;
}

/* Veeronica Message Style */
.message-bubble.veeronica-style {
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.1) 0, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        repeating-linear-gradient(45deg, rgba(255, 77, 109, 0.05), rgba(255, 77, 109, 0.05) 10px, transparent 10px, transparent 20px);
    background-size: 20px 20px, 40px 40px;
    border-width: 3px;
    border-style: solid;
    animation: veeronica-bounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    box-shadow: 0 4px 15px rgba(255, 77, 109, 0.2);
    color: var(--text-color);
}

.dark-mode .message-bubble.veeronica-style {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

@keyframes veeronica-bounce {
    0% { transform: scale(0.8) translateY(10px); opacity: 0; }
    70% { transform: scale(1.05) translateY(-2px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.message-bubble.veeronica-style .dialogue-text {
    font-weight: 600;
    color: inherit;
    text-shadow: none;
}

#loading-message, #error-message {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--text-muted);
    margin: auto;
}

#error-message {
    color: #ff6b6b;
}

#action-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: center;
}

#generate-button {
    font-family: 'Fredoka', sans-serif;
    font-size: 20px;
    font-weight: bold;
    padding: 12px 25px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(to bottom, var(--accent-color), var(--accent-hover));
    color: var(--text-inverted);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
}

#generate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}

#generate-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

#generate-button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.search-container {
    padding: 12px 20px;
    background-color: var(--bg-color);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--panel-border);
}

#community-search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    box-sizing: border-box;
    font-family: 'Fredoka', sans-serif;
}

#community-character-filter {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-character-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    border: 2px solid transparent;
    background-color: var(--input-bg);
}

.filter-character-label input {
    display: none;
}

.filter-character-label img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--input-bg);
    object-fit: contain;
}

.filter-character-label:hover {
    border-color: var(--accent-color);
}

.filter-character-label input:checked ~ span {
    font-weight: bold;
}

#save-button {
    font-family: 'Fredoka', sans-serif;
    font-size: 20px;
    font-weight: bold;
    padding: 12px 25px;
    border-radius: 30px;
    border: none;
    background-color: #555;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#save-button:hover {
    background-color: var(--accent-hover);
}

#save-button:active {
    transform: scale(0.95);
}

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

#topic-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#topic-section label {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-muted);
    text-align: left;
}

#topic-input,
#action-input {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

#topic-input:focus,
#action-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 25px 20px;
    align-items: start;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    position: relative;
}

.control-group label {
    color: var(--text-muted);
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    cursor: help;
}

.toggle-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: normal;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid var(--panel-border);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    margin-bottom: 10px;
}

.control-group:hover .toggle-tooltip {
    opacity: 1;
    visibility: visible;
}

input#fandom-toggle:checked + .slider {
    background-color: #FF1493; /* Deep pink for fandom mode */
}

#length-select,
#content-rating-select,
#model-select {
    font-family: 'Fredoka', sans-serif;
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: border-color 0.3s ease;
    width: 100%;
}

#length-select:focus,
#content-rating-select:focus,
#model-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

#character-limit-message {
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    margin-top: 15px;
    display: none;
    width: 100%;
}

#topic-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Range slider styles */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--panel-border);
    border-radius: 5px;
    cursor: pointer;
    outline: none;
    transition: background 0.3s;
    margin-top: 4px; /* Align better with selects */
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
}

#max-line-length-value {
    font-weight: normal;
    color: var(--text-color);
}

/* Custom Toggle Switch for Unhinged Mode */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    margin-top: 2px; /* Align with other controls */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-bg);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--switch-checked-unhinged);
}

input#twist-toggle:checked + .slider {
    background-color: var(--switch-checked-twist);
}

input#roleplay-toggle:checked + .slider {
    background-color: var(--switch-checked-roleplay);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 28px;
}

.slider.round:before {
    border-radius: 50%;
}

#audio-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(30, 30, 30, 0.8);
    padding: 10px;
    border-radius: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 1000;
}

#audio-controls button {
    font-family: 'Fredoka', sans-serif;
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    background: var(--accent-color);
    color: var(--text-inverted);
    cursor: pointer;
    transition: background 0.3s;
    font-size: 15px;
    font-weight: bold;
    width: 100%;
    max-width: 800px;      /* cap width to match main container */
}

#audio-controls button:hover {
    background: var(--accent-hover);
}

#audio-controls button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Community View Styles */
#community-view-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0 auto;
    padding: 0;
    background-color: transparent;
    width: 100%;
    max-width: 1400px;
}

#community-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px 16px;
    padding: 20px;
    background-color: var(--panel-bg);
    border-radius: 20px;
}

.prompt-card {
    background-color: transparent;
    border-radius: 12px;
    overflow: visible;
    cursor: pointer;
    transition: none;
    border: none;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    position: relative;
}

.prompt-thumbnail-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    transition: border-radius 0.2s ease;
}

.prompt-card:hover .prompt-thumbnail-container {
    border-radius: 0;
}

.prompt-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.prompt-card:hover .prompt-thumbnail {
    transform: scale(1.05);
}

.prompt-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.prompt-card-body {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    align-items: flex-start;
}

.prompt-avatar-link {
    flex-shrink: 0;
}

.prompt-creator-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--input-bg);
}

.prompt-content-metadata {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.prompt-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 4px 0;
    color: var(--text-color);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.prompt-meta-row {
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.prompt-creator-name:hover {
    color: var(--text-color);
}

.prompt-stats-line {
    display: flex;
    gap: 4px;
    align-items: center;
}

.prompt-stats-line span::after {
    content: " • ";
}

.prompt-stats-line span:last-child::after {
    content: "";
}

#community-character-filter {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 12px 0;
    scrollbar-width: none; /* Hide scrollbar for cleaner look */
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

#community-character-filter::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 8px;
    background-color: var(--input-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.filter-chip:hover {
    background-color: var(--panel-border);
}

.filter-chip.active {
    background-color: var(--text-color);
    color: var(--bg-color);
    border-color: var(--text-color);
}

.filter-chip img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: contain;
}

.prompt-creator img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.prompt-creator-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.prompt-creator-username {
    font-weight: bold;
    color: var(--text-color);
}

.delete-prompt-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.delete-prompt-btn:hover {
    background-color: rgba(255, 0, 0, 0.1);
}

.prompt-card:hover .delete-prompt-btn {
    opacity: 1;
}

/* Custom Character View Styles */
#custom-character-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--panel-bg) 100%);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    #custom-character-view {
        grid-template-columns: 350px 1fr;
    }
}

#custom-char-creator {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--panel-border);
}

#custom-char-gallery {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid var(--panel-border);
}

#custom-char-creator h3, #custom-char-gallery h3 {
    font-size: 20px;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--secondary-accent-text);
    font-weight: 700;
}

#custom-char-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.span-2 {
    grid-column: span 2;
}

#custom-char-form label,
#edit-char-form label {
    font-weight: bold;
    color: var(--text-muted);
    font-size: 14px;
}

#custom-char-form input[type="text"],
#custom-char-form textarea,
#custom-char-form input[type="file"],
#custom-char-form select {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    box-sizing: border-box;
}

#custom-char-form textarea {
    resize: vertical;
    min-height: 80px;
}

#custom-char-form input[type="color"] {
    width: 100%;
    height: 44px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    cursor: pointer;
    padding: 2px;
    border-radius: 10px;
}

#custom-char-form button {
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    font-weight: bold;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background-color: var(--accent-color);
    color: var(--text-inverted);
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 16px;
    font-weight: bold;
    margin-top: 10px;
}

#custom-char-form button:hover {
    background-color: var(--accent-hover);
}

#custom-char-form button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

#custom-char-gallery {
    /* This now contains the selector */
}

#custom-char-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

.custom-char-card {
    background-color: var(--bg-color);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    border: 2px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
}

.custom-char-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    border-color: var(--accent-color);
}

.custom-char-card img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    background-color: var(--input-bg);
    margin: 0 auto 15px auto;
    border: 3px solid var(--panel-border);
    transition: border-color 0.3s ease;
}

.custom-char-card:hover img {
    border-color: var(--accent-color);
}

.custom-char-info h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: bold;
    word-break: break-word;
    color: var(--text-color);
}

.custom-char-info p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.custom-char-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-char-actions .action-row {
    display: flex;
    gap: 6px;
    justify-content: space-between;
}

.custom-char-actions button {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 1;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
}

.custom-char-actions .edit-btn {
    background-color: #4CAF50;
    color: white;
}

.custom-char-actions .edit-btn:hover {
    background-color: #45a049;
    transform: translateY(-1px);
}

.custom-char-actions .delete-btn {
    background-color: #dc3545;
    color: white;
}

.custom-char-actions .delete-btn:hover {
    background-color: #c82333;
}

.custom-char-actions .favorite-btn {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 2px solid var(--panel-border);
    font-size: 16px;
    padding: 6px;
    flex-grow: 0;
    width: 40px;
}

.custom-char-actions .favorite-btn:hover {
    background-color: #FFB6C1;
    border-color: #FF69B4;
    transform: scale(1.1);
}

.custom-char-actions .favorite-btn.favorited {
    background-color: #FFB6C1;
    border-color: #FF1493;
    color: #FF1493;
}

.custom-char-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-char-badge.private {
    background: #6c757d;
}

.custom-char-badge.favorited {
    background: #FF1493;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(5px);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Modal Content Container */
#modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    height: 85vh; /* Fixed height for consistent layout */
    background-color: var(--panel-bg);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

/* Modal Header - Sticky Top */
#modal-header {
    flex-shrink: 0;
    padding: 20px 24px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

#modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

/* Conversation Area - Scrollable Middle */
#modal-conversation-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background-color: var(--bg-color); /* Distinct background for content */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Footer / Interaction Section - Sticky Bottom */
#modal-interaction-section {
    flex-shrink: 0;
    padding: 20px 24px;
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
}

/* Make draggable-modal specific overrides */
.draggable-modal {
    display: none;
    background: transparent;
    pointer-events: none;
    padding: 0;
    z-index: 5001;
}

.draggable-modal > #modal-content {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 80vh;
    border: 1px solid var(--panel-border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    z-index: 5002;
}

#modal-like-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#modal-like-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#modal-like-button.liked {
    filter: drop-shadow(0 0 5px #ff6b6b);
}

#modal-like-button:hover {
    transform: scale(1.1);
}

#modal-like-count {
    font-size: 18px;
    font-weight: bold;
}

#comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 5px;
}

.subtle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    padding: 5px;
}

.subtle-btn:hover {
    color: var(--text-color);
}

#comments-collapsible-area {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--panel-bg);
}

#comments-collapsible-area::-webkit-scrollbar {
    width: 8px;
}

#comments-collapsible-area::-webkit-scrollbar-track {
    background: var(--panel-bg);
}

#comments-collapsible-area::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

#modal-comments-section h3 {
    margin: 0;
    font-size: 20px;
    color: var(--text-muted);
    border-bottom: none;
    padding-bottom: 0;
}

#modal-comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 10px;
    align-items: flex-start;
}

.comment-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.comment-item img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    flex-shrink: 0;
}

.comment-content {
    background: var(--bg-color);
    padding: 8px 12px;
    border-radius: 10px;
    flex-grow: 1;
}

.comment-author {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--secondary-accent-text);
}

.comment-text {
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

#modal-comment-form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

#modal-comment-input {
    flex-grow: 1;
    font-family: 'Fredoka', sans-serif;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    resize: vertical;
    min-height: 40px;
    box-sizing: border-box;
}

#modal-comment-form button {
     font-family: 'Fredoka', sans-serif;
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    background: var(--accent-color);
    color: var(--text-inverted);
    cursor: pointer;
    transition: background 0.3s;
    font-size: 15px;
    font-weight: bold;
}

#modal-comment-form button:hover {
    background: var(--accent-hover);
}

/* Edit Character Modal Specific Styles */
#edit-character-modal .modal-content {
    /* improve look and sizing */
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    height: 85vh; /* Fixed height relative to viewport to force inner scrolling */
    max-height: 90vh;
    width: 650px;
    max-width: 95vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#edit-character-modal #edit-char-form {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    flex: 1;
    height: 100%;
    overflow: hidden; /* Form itself doesn't scroll, inner content does */
}

/* Style the modal header to be sticky */
#edit-character-modal .modal-header {
    position: sticky; /* make header stay visible without covering content */
    top: 0;
    background: var(--panel-bg);
    padding: 16px 20px;
    z-index: 11;
    border-bottom: 1px solid var(--panel-border);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Position close button relative to sticky header area */
#edit-character-modal .close-modal-btn {
    top: 20px;
    right: 20px;
}

#edit-character-modal .edit-char-actions {
    display: flex;
    justify-content: space-between; /* Changed from flex-end to space-between */
    gap: 10px;
    margin-top: 0; /* Remove old margin */
    position: static; /* FIX: Make footer static within flex column */
    bottom: 0;
    background: var(--panel-bg);
    padding: 15px 20px; /* Add horizontal padding to match header */
    border-top: 1px solid var(--panel-border);
    z-index: 10;
    flex-shrink: 0;
}

#edit-character-modal input[type="text"],
#edit-character-modal textarea,
#edit-character-modal input[type="file"],
#edit-character-modal select {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    box-sizing: border-box;
}

#edit-character-modal textarea {
    resize: vertical;
    min-height: 80px;
}

#edit-character-modal input[type="color"] {
    width: 100%;
    height: 44px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    cursor: pointer;
    padding: 2px;
    border-radius: 10px;
}

.message-bubble.user-bubble {
    align-self: flex-end;
    background: var(--accent-color);
    color: white;
    border-radius: 18px 18px 2px 18px;
    border: none;
    text-shadow: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-image: none;
    animation: none;
}

.message-bubble.ai-bubble {
    align-self: flex-start;
    border-radius: 18px 18px 18px 2px;
}

#messaging-chat-display .message-row {
    width: 100%;
    margin-bottom: 5px;
}

.messaging-contact-item:hover {
    background-color: var(--panel-bg) !important;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.messaging-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent-color);
}

#messaging-chat-display .message-row.align-right {
    flex-direction: row; /* user side still uses row but bubbles align right */
}

/* Add styles for the private toggle in edit modal */
#edit-character-modal .switch {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

#edit-character-modal .switch .slider {
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

#edit-character-modal .switch input:checked + .slider {
    background-color: var(--accent-color);
}

#edit-character-modal .switch input:checked + .slider:before {
    transform: translateX(22px);
}

#edit-character-modal .switch .switch-label {
    position: relative;
    color: var(--text-color);
    font-size: 14px;
}

#edit-character-modal .switch input:not(:checked) + .slider + .switch-label {
    color: var(--text-muted);
}

#edit-character-modal #save-edit-character-button {
    font-family: 'Fredoka', sans-serif;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background-color: var(--accent-color);
    color: var(--text-inverted);
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 16px;
    font-weight: bold;
}

#edit-character-modal #save-edit-character-button:hover {
    background-color: var(--accent-hover);
}

#edit-character-modal #save-edit-character-button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

#edit-char-form {
    padding-bottom: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* New scroll container for form content */
#edit-char-scroll-content {
    overflow-y: auto;
    flex: 1;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--panel-bg);
    background-color: var(--bg-color); /* Slightly different bg for form area */
}

#edit-char-scroll-content::-webkit-scrollbar {
    width: 8px;
}

#edit-char-scroll-content::-webkit-scrollbar-track {
    background: var(--panel-bg);
}

#edit-char-scroll-content::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

#edit-character-modal .edit-char-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 0;
    position: sticky;
    bottom: 0;
    background: var(--panel-bg);
    padding: 20px 25px;
    border-top: 1px solid var(--panel-border);
    z-index: 20;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

#edit-character-modal #delete-edit-character-button {
    background-color: #dc3545; /* Red */
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 15px;
    font-weight: bold;
}

#edit-character-modal #delete-edit-character-button:hover {
    background-color: #c82333;
}

#edit-character-modal #delete-edit-character-button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

/* Add styles for message preview */
.message-preview {
    margin-top: 15px;
    border: 1px solid var(--panel-border);
    padding: 15px;
    border-radius: 10px;
}

.preview-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.preview-container .character-icon {
    width: 32px;
    height: 32px;
}

#message-preview .message-bubble,
#edit-message-preview .message-bubble {
    font-size: 14px;
    max-width: none;
    width: auto;
}

/* Update FF7 message style preview */
#message-preview .message-bubble.ff7-style,
#edit-message-preview .message-bubble.ff7-style {
    font-size: 14px;
    margin: 5px 0;
    min-width: 200px;
}

/* Live Conversation Display: updated to match other containers and improve placeholder visibility */
#live-conversation-display {
    flex-grow: 1;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--panel-bg);
    resize: both;
}

#live-conversation-display::-webkit-scrollbar {
    width: 8px;
}

#live-conversation-display::-webkit-scrollbar-track {
    background: var(--panel-bg);
}

#live-conversation-display::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

/* Center the "waiting" placeholder when no content is playing */
#live-conversation-display #live-player-placeholder {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
    text-align: center;
}

/* Adjust live view to contain dialogue in a window */
#live-view {
    display: grid;
    grid-template-columns: minmax(300px, 800px) 1fr;
    gap: 20px;
    margin-bottom: 20px;
    height: calc(100vh - 220px);
    min-height: 500px;
}

#live-player-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--panel-bg);
    border-radius: 20px;
    padding: 15px;
    border: 1px solid var(--panel-border);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

#live-prompt-info {
    background: var(--bg-color);
    padding: 15px;
}

#live-prompt-title {
    margin: 0 0 10px 0;
    font-size: 20px;
    color: var(--text-color);
    min-height: 24px;
}

#live-prompt-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#live-prompt-creator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    min-height: 32px;
}

#live-prompt-creator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

#live-prompt-stats {
    font-size: 16px;
    font-weight: bold;
}

#live-up-next {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 15px;
}

#live-up-next h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: var(--text-muted);
}

#up-next-prompt-card {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--input-bg);
    padding: 10px;
    border-radius: 10px;
    min-height: 70px;
}

#up-next-thumbnail {
    width: 100px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    background-color: #000;
}

#up-next-info h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

#up-next-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

#live-chat {
    background: var(--panel-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

#live-chat-header {
    padding: 15px 20px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

#live-chat-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--secondary-accent-text);
}

#live-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.chat-message {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 15px;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.chat-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-message .username {
    color: var(--secondary-accent-text);
    font-weight: bold;
}

.chat-message .timestamp {
    color: #777;
    font-size: 12px;
    margin-left: auto;
    flex-shrink: 0;
    align-self: center;
}

.chat-text {
    flex-grow: 1;
}

#live-chat-form {
    padding: 15px;
    display: flex;
    gap: 10px;
    background: var(--bg-color);
    border-top: 1px solid var(--panel-border);
}

#live-chat-input {
    flex-grow: 1;
    font-family: 'Fredoka', sans-serif;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    min-height: 20px; /* Base height for one line */
    box-sizing: border-box;
}

#live-chat-input:disabled {
    background-color: var(--text-muted);
}

#live-chat-form button {
    font-family: 'Fredoka', sans-serif;
    padding: 10px 15px;
    border-radius: 10px;
    border: none;
    background: var(--accent-color);
    color: var(--text-inverted);
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.3s;
}

#live-chat-form button:hover {
    background: var(--accent-hover);
}

/* New styles for character sub-tabs */
#character-sub-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center; /* Center the sub-tabs */
}

.sub-tab-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 16px;
    font-weight: bold;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background-color: var(--bg-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.sub-tab-btn.active {
    background-color: var(--accent-color);
    color: var(--text-inverted);
    border-color: var(--accent-color);
}

.sub-tab-btn:hover:not(.active) {
    background-color: var(--input-bg);
}

.community-sub-selector-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--panel-bg);
    border-radius: 15px;
    border: 1px solid var(--panel-border);
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#community-char-search-input {
    flex-grow: 1;
    max-width: 250px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    box-sizing: border-box;
    font-family: 'Fredoka', sans-serif;
}

/* Small switch for "My Characters" */
.small-switch {
    width: 100px; /* Adjust width to fit text */
    height: 28px;
    position: relative;
    display: flex; /* Use flex to align label */
    align-items: center;
    justify-content: center;
    padding: 0 5px; /* Add some padding for the label */
}

.small-switch .slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-bg);
    transition: .4s;
    border-radius: 50%;
}

.small-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.small-switch input:checked + .slider {
    background-color: var(--accent-color); /* Green for "on" */
}

.small-switch input:checked + .slider:before {
    transform: translateX(70px); /* Move further for wider switch */
}

.small-switch .switch-label {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-inverted); /* White text on active switch */
    text-align: center;
    pointer-events: none; /* Make sure label doesn't interfere with click */
    z-index: 1;
    transition: color 0.4s;
}

.small-switch input:not(:checked) + .slider + .switch-label {
    color: var(--text-muted); /* Muted text when off */
}

/* Add new styles for lore context section */
.lore-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#toggle-lore-btn {
    text-align: left;
    width: 100%;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#toggle-lore-btn:hover {
    background: var(--bg-color);
}

#lore-editor {
    display: none;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#lore-context-input {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    resize: vertical;
    line-height: 1.4;
    margin-bottom: 10px;
}

.lore-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.lore-status {
    font-size: 14px;
    color: var(--text-muted);
    margin: 5px 0 0 0;
    min-height: 20px;
    transition: opacity 0.3s;
}

.lore-status.fade {
    opacity: 0;
}

#extension-preview-header {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.subtle-btn {
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: var(--panel-bg);
    color: var(--text-color);
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    transition: all 0.2s ease;
}

.subtle-btn:hover {
    background: var(--accent-color);
    color: var(--text-inverted);
    border-color: var(--accent-color);
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    font-family: 'Fredoka', sans-serif;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--panel-border);
}

.pagination-controls button {
    padding: 8px 15px;
    border: none;
    background: var(--panel-bg);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--panel-border);
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-controls button:not(:disabled):hover {
    background: var(--accent-color);
    color: var(--text-inverted);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-muted);
}

.pagination-page-select {
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid var(--panel-border);
    background: var(--panel-bg);
    color: var(--text-color);
    font-family: inherit;
    cursor: pointer;
}

/* Add ichor-related styles */
.ichor-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    position: relative;
}

#ichor-tank {
    width: 140px;  /* Even thinner */
    height: 300px;
    background-color: var(--input-bg);
    border: 3px solid var(--panel-border);
    border-radius: 70px; /* Make it more capsule shaped */
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

#ichor-tank .tank-cap {
    position: absolute;
    width: 100%;
    height: 20px;
    background: #aaa;
    border-radius: 35px;
    z-index: 2;
}

#ichor-tank .tank-cap.bottom {
    bottom: 0;
    height: 15px; /* Make bottom cap smaller */
    z-index: 2;
}

.ichor-bubble {
    position: absolute;
    bottom: 15px; /* Start above bottom cap */
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translateY(-250px) scale(0.5);
        opacity: 0;
    }
}

#ichor-level {
    background: linear-gradient(to bottom, 
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.7) 50%,
        rgba(0, 0, 0, 0.9) 100%
    );
    position: absolute;
    bottom: 15px; /* Align with bottom cap */
    left: 0;
    width: 100%;
    height: 0%;
    transition: height 0.3s ease;
    z-index: 1;
}

/* Update skill check styles */
.skill-check {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 30px;
    background: var(--panel-bg);
    border-radius: 15px;
    display: none;
    z-index: 3;
    border: 1px solid var(--panel-border);
}

.skill-check-target {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 15px; /* Small yellow target */
    height: 100%;
    background: #FFD700;
    opacity: 0.5;
    z-index: 1;
}

.skill-check-bar {
    position: absolute;
    width: 5px;
    height: 100%;
    background: #fff;
    z-index: 2;
}

/* Update bonus zone styling */
.skill-check-bonus-zone {
    position: absolute;
    left: 35%;
    width: 30%; /* Wider grey area */
    height: 100%;
    background: #808080; /* Medium grey */
    opacity: 0.3;
    z-index: 0;
    border-radius: 15px;
}

.skill-check-result {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    text-align: center;
    text-shadow: 0 0 3px rgba(0,0,0,0.5);
}

.skill-check-result.show {
    opacity: 1;
}

@keyframes slideBar {
    from { left: 0; }
    to { left: calc(100% - 5px); }
}

#valve-wheel {
    width: 120px;
    height: 120px;
    position: absolute;
    top: -140px;
    left: 50%;
    transform: translateX(-50%);
    transition: transform 0.1s linear;
}

.extracting #valve-wheel {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#ichor-counter {
    position: absolute;
    bottom: 20px; /* Positioned at the bottom of the container */
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
    background: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 5px;
}

#status-indicator {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #FF4444; /* Red for not complete */
    border: 3px solid var(--panel-bg);
    transition: background 0.5s ease;
}

#status-indicator.complete {
    background: #4CAF50; /* Green for complete */
}

/* News Studio Styles */
#news-section {
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    overflow: hidden;
    position: relative;
    width: 100%;
    max-width: 100%;
}

/* Windows XP Style Window */
.news-window {
    background: #ece9d8;
    border: 2px outset #d4d0c8;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 100%;
    height: fit-content;
}

.news-window-title-bar {
    background: linear-gradient(to bottom, #0997ff, #0053ee);
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    color: white;
    font-family: 'Tahoma', sans-serif;
    font-size: 11px;
    font-weight: bold;
    border-bottom: 1px solid #316ac5;
    min-height: 30px;
}

.news-window-title {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.news-window-icon {
    width: 16px;
    height: 16px;
    background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAdgAAAHYBTnsmCAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFYSURBVDtNpZM9SwNBEIafgxALwcJCG1sLG1sZCGxsLbSy0sVBEBBFBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBBBRBARRBARRBARRBARRBARRBARRBB') no-repeat center;
    background-size: contain;
}

.news-window-controls {
    display: flex;
    gap: 2px;
}

.news-window-btn {
    width: 21px;
    height: 21px;
    border: 1px outset #d4d0c8;
    background: #d4d0c8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-family: 'Marlett', sans-serif;
}

.news-window-btn:hover {
    background: #e6e2d8;
}

.news-window-btn:active {
    border: 1px inset #d4d0c8;
}

#news-studio {
    background: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid var(--panel-border);
    overflow: hidden;
    position: relative;
    height: 400px;
    overflow: hidden;
    width: 100%;
}

/* News Studio Background */
#news-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(135deg, rgba(30, 60, 114, 0.9) 0%, rgba(42, 82, 152, 0.9) 100%),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(255,255,255,0.02) 10px,
            rgba(255,255,255,0.02) 20px
        );
    z-index: 0;
}

/* News Desk */
#news-desk {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(to bottom, #8B4513, #654321);
    border-top: 3px solid #A0522D;
    z-index: 1;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
}

#news-desk::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    width: 60%;
    height: 10px;
    background: linear-gradient(to right, #D2691E, #CD853F, #D2691E);
    border-radius: 5px;
}

/* News Anchors */
.news-anchor {
    position: absolute;
    bottom: 120px;
    z-index: 2;
    transition: transform 0.3s ease;
}

.news-anchor img {
    width: 200px;
    height: 300px;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

.news-anchor.speaking-animation {
    animation: newsAnchorSpeak 1s ease-in-out infinite;
}

@keyframes newsAnchorSpeak {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-5px) scale(1.02); }
    50% { transform: translateY(-3px) scale(1.01); }
    75% { transform: translateY(-7px) scale(1.03); }
}

/* News Dialogue Bubbles */
.news-dialogue-bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #333;
    border-radius: 15px;
    padding: 15px 20px;
    max-width: 300px;
    min-width: 150px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 10; 
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    word-wrap: break-word;
    line-height: 1.4;
}

.news-dialogue-bubble.show {
    opacity: 1;
    transform: scale(1);
}

.news-dialogue-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 30px;
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid #333;
}

.news-dialogue-bubble::before {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 32px;
    width: 0;
    height: 0;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-top: 13px solid rgba(255, 255, 255, 0.95);
}

/* Position bubbles relative to studio */
.news-dialogue-bubble {
    bottom: 200px;
}

/* News Content Area */
#news-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    z-index: 5;
}

#news-ticker {
    background: #c41e3a;
    color: white;
    padding: 5px 0;
    overflow: hidden;
    white-space: nowrap;
}

#ticker-text {
    display: inline-block;
    animation: tickerScroll 30s linear infinite;
    font-size: 14px;
    font-weight: bold;
}

@keyframes tickerScroll {
    from { transform: translateX(100%); }
    to { transform: translateX(-100%); }
}

#news-display {
    padding: 10px 20px;
    color: white;
}

#news-headline {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.queue-item {
    background: var(--bg-color);
    border-radius: 10px;
    padding: 12px;
    border: 2px solid var(--panel-border);
    transition: all 0.3s ease;
}

.queue-item.current {
    border-color: #e74c3c;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(231, 76, 60, 0.05));
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2);
}

.queue-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.queue-position {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.queue-item.current .queue-position {
    background: #e74c3c;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.queue-time {
    font-size: 12px;
    color: var(--text-muted);
}

.queue-prompt {
    margin: 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.queue-anchors {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-top: 8px;
}

.queue-author {
    color: var(--text-muted);
    font-style: italic;
}

#news-prompt-queue-container {
    min-height: 300px;
}

#news-prompt-queue::-webkit-scrollbar {
    width: 8px;
}

#news-prompt-queue::-webkit-scrollbar-track {
    background: var(--panel-bg);
}

#news-prompt-queue::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

/* Responsive adjustments for news section */
@media (max-width: 768px) {
    #news-studio {
        height: 300px;
    }
    
    .news-anchor img {
        width: 150px;
        height: 225px;
    }
    
    .news-dialogue-bubble {
        max-width: 250px;
        font-size: 14px;
        padding: 12px 16px;
    }
    
    #news-desk {
        height: 80px;
    }
    
    .news-anchor {
        bottom: 80px;
    }
}

@media (max-width: 420px) {
    #news-studio {
        height: 250px;
    }
    
    .news-anchor img {
        width: 120px;
        height: 180px;
    }
    
    .news-dialogue-bubble {
        max-width: 200px;
        font-size: 12px;
        padding: 10px 14px;
    }
    
    #news-desk {
        height: 60px;
    }
    
    .news-anchor {
        bottom: 60px;
    }
    
    .news-window-title-bar {
        font-size: 10px;
        height: 25px;
        min-height: 25px;
    }
}

/* Add multiplayer-specific styles */
.reaction-btn {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reaction-btn:hover {
    background: var(--accent-color);
    transform: scale(1.1);
}

@keyframes reactionFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

.live-reaction {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    font-size: 24px;
    animation: reactionFloat 3s ease-out forwards;
}

.viewer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px;
    border-radius: 8px;
    background: var(--bg-color);
}

.viewer-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
}

.viewer-name {
    font-size: 12px;
    color: var(--text-color);
    flex-grow: 1;
}

.viewer-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
}

.news-vote-btn {
    transition: all 0.2s ease;
}

.news-vote-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.news-vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#multiplayer-sidebar {
    transition: transform 0.3s ease;
}

#multiplayer-sidebar.hidden {
    transform: translate(100%, -50%);
}

/* Update live chat header to accommodate reactions */
#live-chat-header {
    padding: 15px 20px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

#live-chat-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--secondary-accent-text);
}

/* Responsive adjustments for multiplayer features */
@media (max-width: 768px) {
    #multiplayer-sidebar {
        width: 150px;
        right: 10px;
    }
    
    .reaction-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    #live-reactions-bar {
        gap: 5px !important;
    }
    
    #live-chat-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 420px) {
    #multiplayer-sidebar {
        display: none !important;
    }
    
    .reaction-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

.queue-position.used {
    background: #6c757d;
    color: white;
}

.queue-position.ready {
    background: #28a745;
    color: white;
}

.queue-position.waiting {
    background: #ffc107;
    color: #212529;
}

#char-custom-sound-input,
#edit-char-custom-sound-input {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    box-sizing: border-box;
    cursor: pointer;
}

#char-custom-sound-input::-webkit-file-upload-button,
#edit-char-custom-sound-input::-webkit-file-upload-button {
    background: var(--accent-color);
    color: var(--text-inverted);
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
}

#char-custom-sound-input::file-selector-button,
#edit-char-custom-sound-input::file-selector-button {
    background: var(--accent-color);
    color: var(--text-inverted);
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 10px;
}

#edit-char-current-sound {
    font-style: italic;
}

.achievement-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    animation: achievementSlide 0.5s ease-out forwards;
}

.achievement-icon {
    font-size: 24px;
}

@keyframes achievementSlide {
    from {
        bottom: -100px;
        opacity: 0;
    }
    to {
        bottom: 20px;
        opacity: 1;
    }
}

/* Generic resizable helper */
.resizable {
    resize: both;
    overflow: auto;
    min-width: 260px;
    min-height: 140px;
}

/* Make the modal content resizable as well */
#modal-content {
    resize: both;
    overflow: auto;
}

/* Live conversation window: make resizable by default */
#live-conversation-display {
    /* already has scrolling styles */
    resize: both;
}

/* Header/handle used to drag windows */
.window-header {
    user-select: none;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    font-weight: 700;
}

.window-header .window-hint {
    font-weight: normal;
    font-size: 12px;
    color: var(--text-muted);
}

/* When a panel is floating we give it a subtle shadow */
.floating-panel {
    position: fixed; /* constrained to viewport and easy to drag */
    z-index: 1100;
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
    border-radius: 12px;
}

/* Optional: nicer resize corner visibility on dark bg */
.resizable {
    background-clip: padding-box;
}

#community-char-sub-selector .character-label { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.result-badge { padding: 4px 8px; border-radius: 12px; background: var(--input-bg); color: var(--text-muted); font-size: 12px; }
#ichor-remote {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: auto;
    cursor: pointer;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

#veemote-button { display: none; }

#eclipse-werewolf-control {
    display: none;
}

#eclipse-werewolf-toggle:checked + .slider {
    background-color: #8B4513; /* Brown werewolf color */
}

#interact-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

#messaging-sub-view {
    display: flex;
    gap: 20px;
    flex-wrap: nowrap;
    height: 75vh;
    min-height: 500px;
    max-height: 900px;
    width: 100%;
    animation: fadeIn 0.3s ease-out;
}

@media (max-width: 900px) {
    #messaging-sub-view {
        flex-direction: column;
        height: auto;
        max-height: none;
    }
    
    #messaging-sidebar {
        flex: none !important;
        height: 300px;
    }
    
    #messaging-chat-window {
        height: 500px;
    }
}

#interact-controls-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1 1 400px;
    min-width: 350px;
}

#interact-settings-panel {
    background-color: var(--panel-bg);
    border-radius: 20px;
    padding: 25px;
    border: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#interact-character-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
}

#interact-character-selector .character-label {
    min-height: 35px;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 15px;
}

#interact-action-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: center;
}

#interact-generate-button {
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    font-weight: bold;
    padding: 12px 25px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(to bottom, var(--accent-color), var(--accent-hover));
    color: var(--text-inverted);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#interact-generate-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}

#interact-generate-button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#interact-output-column {
    display: flex;
    flex-direction: column;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    position: relative;
    flex: 2 1 500px;
}

#interact-output-column.floating-window {
    position: absolute;
    right: 20px;
    top: 150px;
    width: 45%;
    min-width: 350px;
    height: 70vh;
    min-height: 300px;
    resize: both;
    overflow: hidden;
    z-index: 1000;
}

#interact-output-header {
    padding: 10px 15px;
    background-color: var(--input-bg);
    cursor: move;
    border-bottom: 1px solid var(--panel-border);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    font-weight: bold;
    color: var(--text-color);
}

#interact-voting-container {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    max-height: calc(70vh - 50px);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--panel-bg);
}

#interact-voting-container::-webkit-scrollbar {
    width: 8px;
}

#interact-voting-container::-webkit-scrollbar-track {
    background: var(--panel-bg);
}

#interact-voting-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

.interact-option {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.interact-option label {
    font-weight: bold;
    color: var(--text-muted);
    font-size: 14px;
}

.interact-option-input {
    font-family: 'Fredoka', sans-serif;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid var(--panel-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    box-sizing: border-box;
}

.interact-remove-option {
    padding: 6px 12px;
    font-size: 13px;
}

.control-warning {
    display: block;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}

.control-warning.warning-short {
    background-color: rgba(255, 193, 7, 0.15);
    color: #ff9800;
    border-left: 3px solid #ff9800;
}

.control-warning.warning-long {
    background-color: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border-left: 3px solid #f44336;
}

.control-warning.warning-content {
    background-color: rgba(233, 30, 99, 0.15);
    color: #e91e63;
    border-left: 3px solid #e91e63;
}

.control-warning.warning-unhinged {
    background-color: rgba(156, 39, 176, 0.15);
    color: #9c27f0;
    border-left: 3px solid #9c27f0;
}

#autofill-button {
    padding: 8px 15px;
    font-weight: bold;
}

.subtle-btn:hover {
    color: var(--text-color);
}

/* Add style for modal close buttons (applies to both main and edit) */
#close-modal, .close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 30px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    z-index: 12; /* Above sticky headers/footers */
    transition: color 0.2s;
}

#close-modal:hover, .close-modal-btn:hover {
    color: var(--text-color);
}