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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.main-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    margin-top: 20px;
}

/* Sidebar Styles */
.sidebar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    height: fit-content;
}

.sidebar h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-tab {
    padding: 6px 16px;
    border: none;
    border-radius: 20px;
    background: #e8f0fe;
    color: #1a73e8;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-tab:hover {
    background: #d2e3fc;
}

.category-tab.active {
    background: #1a73e8;
    color: white;
}

.preset-topics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-topic {
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.preset-topic:hover {
    background: #e8f0fe;
    border-color: #d2e3fc;
}

.historical-facts {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.historical-fact {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.historical-fact strong {
    display: block;
    margin-bottom: 5px;
    color: #1a73e8;
}

.historical-fact ul {
    margin-left: 20px;
    margin-top: 5px;
}

/* Main Content Styles */
.main-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Debate Format Pills */
.format-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
}

.format-pill {
    padding: 8px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    background: white;
    color: #5f6368;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.format-pill:hover {
    border-color: #d2e3fc;
    background: #f8f9fa;
}

.format-pill.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

/* AI Mode Toggle */
.ai-mode-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center; 
    gap: 15px;            
    border: 1px solid #e0e0e0;
}

.ai-mode-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.ai-toggle-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.use-template-text {
    font-size: 14px;
    color: #5f6368;
    font-weight: 400;
}

/* Modern Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    cursor: pointer;
}

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

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background: #1a73e8;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* API Key Section - Simple */
#apiKeySection {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

#apiKey {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 8px;
}

#apiKey:focus {
    outline: none;
    border-color: #1a73e8;
}

.api-hint {
    font-size: 12px;
    color: #5f6368;
    margin-top: 5px;
}

/* Shortcuts link */
.shortcuts-link {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 13px;
    color: #1a73e8;
    text-decoration: none;
    cursor: pointer;
}

.shortcuts-link:hover {
    text-decoration: underline;
}

/* Participant Selection */
.participant-section {
    margin-bottom: 20px;
}

.participant-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4285f4, #1a73e8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.participant-select {
    flex: 1;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.participant-select:focus {
    outline: none;
    border-color: #1a73e8;
}

/* Topic Input */
.topic-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 15px;
}

.topic-input:focus {
    outline: none;
    border-color: #1a73e8;
}

/* Response Count Section - Modified for better layout */
.response-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
}

.duration-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.response-section label {
    font-size: 14px;
    font-weight: 500;
}

.response-select {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* Join Debate Button - Positioned on the right */
.join-debate-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    color: #f39c12;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    white-space: nowrap;
}

.join-debate-btn:hover {
    background: #fff4e5;
    border-color: #f39c12;
}

.join-debate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Generate Button */
.generate-btn {
    background: #1aae9f;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    margin: 0 auto;
}

.generate-btn:hover {
    background: #159185;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 174, 159, 0.3);
}

.generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.stop-btn {
    background: #dc3545;
    margin-left: 10px;
}

.stop-btn:hover {
    background: #c82333;
}

/* Debate Output */
#debateOutput {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    min-height: 150px;
}

.debate-line {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.speaker {
    font-weight: 600;
    color: #1a73e8;
    display: block;
    margin-bottom: 8px;
}

.response-content {
    color: #5f6368;
    line-height: 1.6;
}

/* Interactive Debate Controls */
.interactive-debate-controls {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background: #f0f7ff;
    border-radius: 12px;
    border: 2px solid #1a73e8;
}

.interactive-debate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.interactive-debate-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a73e8;
}

.interactive-debate-timer {
    font-size: 14px;
    font-weight: bold;
    color: #1a73e8;
}

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

.interactive-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px;
    border: 1px solid #1a73e8;
    border-radius: 22px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.interactive-input:focus {
    outline: none;
    border-color: #1557b0;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.interactive-send-btn {
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.interactive-send-btn:hover {
    background: #1557b0;
}

.interactive-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.interactive-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.interactive-action-btn {
    padding: 6px 12px;
    border: 1px solid #1a73e8;
    border-radius: 16px;
    background: white;
    color: #1a73e8;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.interactive-action-btn:hover {
    background: #1a73e8;
    color: white;
}

.stop-interactive-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.stop-interactive-btn:hover {
    background: #c82333;
}

/* Enhanced debate messages for interactive mode */
.debate-line.user-message {
    background: #1a73e8;
    color: white;
    margin-left: 20%;
    border-radius: 12px 12px 4px 12px;
}

.debate-line.user-message .speaker {
    color: rgba(255, 255, 255, 0.9);
}

.debate-line.user-message .response-content {
    color: white;
}

.debate-line.ai-message {
    margin-right: 20%;
    border-left: 3px solid #e0e0e0;
}

.interactive-typing {
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-right: 20%;
    font-style: italic;
    color: #5f6368;
    border-left: 3px solid #1a73e8;
}

.live-debate-container {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    height: 85%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.live-debate-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    border-radius: 16px 16px 0 0;
}

.debate-title {
    font-size: 18px;
    font-weight: 600;
}

.debate-timer {
    font-size: 16px;
    font-weight: bold;
}

.close-debate {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.live-debate-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.debate-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.debate-message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    max-width: 85%;
    animation: slideIn 0.3s ease;
}

.user-message {
    background: #1a73e8;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.ai-message {
    background: white;
    border: 1px solid #e0e0e0;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-header {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-content {
    line-height: 1.5;
}

.debate-input-area {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
}

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

.debate-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.debate-input:focus {
    outline: none;
    border-color: #1a73e8;
}

.send-btn {
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #1557b0;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.debate-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: white;
    color: #5f6368;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: #1a73e8;
    color: #1a73e8;
}

.character-selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

.character-selection-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.character-card {
    text-align: center;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.character-card:hover {
    border-color: #1a73e8;
    transform: translateY(-2px);
}

.character-card.selected {
    border-color: #1a73e8;
    background: #f0f7ff;
}

.character-avatar {
    font-size: 32px;
    margin-bottom: 8px;
}

.character-name {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
}

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

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-right: auto;
    max-width: 85%;
    margin-bottom: 20px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #5f6368;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .main-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Mobile Navigation - Convert sidebar to top navigation */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1001;
        background: #1a73e8;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    /* Overlay for mobile menu */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .mobile-overlay.show {
        display: block;
    }

    /* Main content adjustments */
    .main-content {
        margin-top: 60px;
        padding: 20px 15px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    /* Format selector - make scrollable */
    .format-selector {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
    }

    .format-pill {
        font-size: 12px;
        padding: 6px 12px;
        white-space: nowrap;
    }

    /* Participant rows - stack on mobile */
    .participant-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .avatar {
        width: 40px;
        height: 40px;
        margin: 0 auto;
    }

    .participant-select {
        width: 100%;
    }

    /* Response section - stack elements */
    .response-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .duration-controls {
        width: 100%;
    }

    .join-debate-btn {
        width: 100%;
        justify-content: center;
    }

    /* Interactive debate controls */
    .interactive-debate-controls {
        padding: 15px;
    }

    .interactive-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .interactive-action-btn {
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Debate output */
    #debateOutput {
        margin-top: 20px;
        padding: 15px;
    }

    .debate-line {
        padding: 12px;
        margin-bottom: 15px;
    }

    .speaker {
        font-size: 14px;
    }

    .response-content {
        font-size: 14px;
    }

    /* Modal adjustments */
    .character-selection-container {
        width: 95%;
        padding: 20px;
        max-height: 90%;
    }

    /* Hide shortcuts link on mobile */
    .shortcuts-link {
        display: none;
    }

    /* Category tabs - make scrollable */
    .category-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }

    /* AI Mode section */
    .ai-mode-section {
        padding: 15px;
        flex-direction: column;
        text-align: center;
    }

    .ai-toggle-container {
        margin-top: 10px;
    }

    /* Team assignment for Oxford style */
    #teamAssignment {
        font-size: 12px;
    }

    #teamAssignment > div {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Format features */
    #formatFeatures > div > div {
        padding: 10px;
        font-size: 12px;
    }

    /* Historical facts */
    .historical-fact {
        font-size: 12px;
        padding: 10px;
    }

    /* Visitor stats */
    .visitor-stats {
        margin-top: 15px;
        padding-top: 15px;
    }

    .stat-item {
        font-size: 12px;
        padding: 8px 10px;
    }

    .stat-value {
        font-size: 14px;
    }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
    h1 {
        font-size: 20px;
    }

    .format-pill {
        font-size: 11px;
        padding: 5px 10px;
    }

    .generate-btn {
        padding: 12px 24px;
        font-size: 14px;
    }

    .interactive-action-btn {
        font-size: 10px;
    }

    .debate-line.user-message,
    .debate-line.ai-message {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .main-content {
        margin-top: 40px;
    }

    .interactive-debate-controls {
        position: relative;
    }

    #debateOutput {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, .preset-topic, .category-tab {
        min-height: 44px;
    }

    .participant-select {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .preset-topic:hover,
    .category-tab:hover,
    .format-pill:hover {
        transform: none;
    }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle,
    .mobile-overlay {
        display: none !important;
    }
}