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

:root {
    --bg: #151515;
    --bg-secondary: #1f1f1f;
    --text: #666666;
    --text-dim: #444444;
    --text-bright: #999999;
    --accent: #e8e8e8;
    --border: #2a2a2a;
    --sidebar-width: min(32vw, 320px);
    --content-padding: clamp(1.75rem, 4vw, 4rem);
}

body {
    font-family: 'Courier New', 'Courier', monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    overflow-x: hidden;
    font-size: 14px;
}

/* Info Panel */
.info-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
}

.info-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-bright);
    transition: all 0.3s ease;
    user-select: none;
}

.info-toggle:hover {
    background: var(--border);
    color: var(--accent);
    transform: scale(1.1);
}

.info-content {
    position: absolute;
    top: 40px;
    left: 0;
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.info-content.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.info-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.info-content p {
    margin: 0 0 0.75rem 0;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-bright);
}

.info-content ul {
    margin: 0.5rem 0 1rem 1.25rem;
    padding: 0;
    font-size: 0.75rem;
    color: var(--text);
}

.info-content li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.info-note {
    font-style: italic;
    color: var(--text-dim);
    font-size: 0.75rem !important;
    margin-bottom: 0 !important;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    z-index: 100;
}

.footer a {
    color: var(--text-bright);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--accent);
}

.footer .version {
    color: var(--text-dim);
}

/* Stats Sidebar */
.stats-bar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2.5rem;
    padding: clamp(2rem, 4vw, 3.25rem) clamp(1.5rem, 3vw, 2.25rem);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 100;
    overflow-y: auto;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.1rem;
    color: var(--text);
    font-weight: bold;
    letter-spacing: 0.05em;
}

.stat-separator {
    display: none;
}

/* Messages Section */
.messages-section {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.messages-header {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
}

.messages-container {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.messages-container::-webkit-scrollbar {
    width: 4px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--bg);
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.message-item {
    font-size: 0.75rem;
    color: var(--text);
    line-height: 1.5;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 4px;
    border-left: 2px solid var(--border);
}

.message-cycle {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

/* Output Area Container - No scrolling, only see present */
.output-container {
    margin-right: var(--sidebar-width);
    height: 100vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Anchor to bottom */
}

/* Prevent any scrollbar from appearing */
.output-container::-webkit-scrollbar {
    display: none;
}

.output-container {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Fade effect at top to show content disappearing into time */
.output-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
    z-index: 5;
    pointer-events: none;
}

/* Output Area */
.output {
    padding: var(--content-padding);
    max-width: clamp(640px, calc(100vw - var(--sidebar-width) - (var(--content-padding) * 1.5)), 960px);
    width: 100%;
}

.output-text {
    color: var(--accent);
    margin-bottom: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 2;
}

.cycle-marker {
    display: block;
    color: var(--accent);
    margin: 6rem 0 4rem 0;
    padding: 2.5rem 0;
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    text-align: center;
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    background: linear-gradient(90deg, transparent, var(--bg-secondary), transparent);
    box-shadow: 0 0 40px rgba(232, 232, 232, 0.1);
}

.continuation-footnote {
    display: block;
    color: var(--accent);
    margin: 2rem 0 1rem 0;
    padding: 0.5rem 0;
    font-size: 0.78rem;
    font-style: italic;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-align: center;
    opacity: 1;
    cursor: help;
}

.stat-current-message {
    width: 100%;
    max-width: 100%;
    gap: 0.75rem;
}

.message-current {
    width: 100%;
    min-height: 4.5rem;
    padding: 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--accent);
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message-history-block {
    width: 100%;
    max-width: 100%;
    gap: 0.75rem;
}

.message-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.message-history-item {
    padding: 0.75rem;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-bright);
    font-size: 0.7rem;
    line-height: 1.5;
}

.message-history-item span {
    display: block;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}

.message-history-empty {
    color: var(--text-dim);
    font-size: 0.65rem;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 6px;
}

/* Status indicators - always show blink */
.status-streaming,
.status-waiting,
.status-error {
    color: var(--accent);
}

.status-streaming::after,
.status-waiting::after,
.status-error::after {
    content: '█';
    margin-left: 0.25rem;
    animation: blink 1s infinite;
}

/* Blink animation */
@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.3; }
}

/* Responsive - Mobile Layout */
@media (max-width: 1024px) {
    body {
        display: flex;
        flex-direction: column;
    }

    .stats-bar {
        position: relative;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 1rem;
        padding: 1rem;
        border-left: none;
        border-bottom: 1px solid var(--border);
        order: 1;
        z-index: 100;
        background: var(--bg-secondary);
    }

    .stat {
        align-items: flex-start;
        flex: 0 0 calc(50% - 0.5rem);
        gap: 0.25rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .stat-separator {
        display: none;
    }

    /* Hide complex stats on mobile */
    .stat-current-message,
    .message-history-block {
        display: none;
    }

    .output-container {
        margin-right: 0;
        order: 2;
        height: calc(100vh - 100px); /* Subtract stats bar height */
    }
    
    .output-container::before {
        right: 0;
        height: 80px;
    }

    .output {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    .info-panel {
        top: 10px;
        left: 10px;
        z-index: 200;
    }

    .info-content {
        width: calc(100vw - 40px);
        max-width: 320px;
    }

    .footer {
        position: fixed;
        bottom: 10px;
        left: 10px;
        font-size: 0.65rem;
        z-index: 200;
    }

    .cycle-marker {
        font-size: 1.2rem;
        margin: 3rem 0 2rem 0;
        padding: 1.5rem 0;
    }

    .continuation-footnote {
        font-size: 0.7rem;
        margin: 1.5rem 0 0.75rem 0;
    }

    .output-text {
        font-size: 13px;
        line-height: 1.8;
    }
}

@media (max-width: 640px) {
    .stat {
        flex: 0 0 100%;
    }

    .stats-bar {
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .output {
        padding: 1rem 0.75rem;
    }

    .output-text {
        font-size: 12px;
    }
}
