:root {
    /* Bold & Modern Palette - Swiss Style Dark Mode */
    --bg-core: #030303;
    --bg-surface: #111111;
    --bg-surface-hover: #1a1a1a;

    --border-subtle: #222222;
    --border-strong: #333333;

    --text-main: #ffffff;
    --text-muted: #888888;
    --text-dim: #444444;

    /* Strict, sharp accent */
    --accent-color: #ffffff;
    --accent-active: #2952ff;
    /* Electric Blue for active states if needed */

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing & Layout */
    --radius-sharp: 4px;
    /* Tight radius for that technical feel */
    --radius-pill: 999px;

    --header-height: 80px;
    --input-area-height: 100px;
}

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

body {
    background-color: var(--bg-core);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    height: 100vh;
    overflow: hidden;
}

#aurora-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* --- Layout --- */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    /* Glassmorphism */
    background: rgba(3, 3, 3, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}


.logout-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 8px;
    border-radius: var(--radius-sharp);
    transition: all 0.2s ease;
    z-index: 50;
    opacity: 0.6;
}

.logout-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
}

.logout-btn.scrolled-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.logout-icon {
    width: 24px;
    height: 24px;
    filter: invert(1);
    /* Turn black SVG to white */
    display: block;
}

/* --- Typography Utilities --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

/* --- Chat Container --- */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 40px;
    /* More horizontal space */
    padding-bottom: 140px;
    scroll-behavior: smooth;
    width: 100%;

    /* Scrollbar hidden but functional */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.chat-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* --- Welcome Message --- */

.welcome-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 70%;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
    width: 100%;
    /* Ensure it spans full width */
}

.welcome-message h1 {
    font-size: 8rem;
    /* Even Bigger for full screen impact */
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.05em;
    text-transform: uppercase;
    margin-bottom: 24px;
    color: var(--text-main);
}

.welcome-message p {
    font-family: var(--font-display);
    color: var(--text-muted);
    font-size: 1.2rem;
    max-width: 600px;
    /* Allow wider text */
}

/* --- Message Rows --- */

.message-row {
    display: flex;
    margin-bottom: 32px;
    width: 100%;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-row {
    justify-content: flex-end;
}

.assistant-row {
    justify-content: flex-start;
    flex-direction: column;
    width: 100%;
    /* Ensure full width */
}

/* --- Message Bubbles --- */

.message-bubble {
    /* Allow wider bubbles on full screen */
    max-width: 90%;
    font-size: 1rem;
    position: relative;
}

/* User Bubble: Minimalist */
.user-row .message-bubble {
    background: rgba(17, 17, 17, 0.6);
    /* Semi-transparent surface */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-main);
    padding: 12px 24px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sharp);
    font-weight: 500;
}

/* Assistant Bubble: Container for components */
.assistant-row .message-bubble {
    width: 100%;
    max-width: 100%;
    /* Full width for assistant content */
}

/* --- Iteration Cards --- */

.iteration-card {
    background: rgba(17, 17, 17, 0.1);
    /* Very transparent */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sharp);
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    width: 100%;
    animation: popIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.iteration-card:hover {
    border-color: var(--border-strong);
    background: rgba(17, 17, 17, 0.2);
}

.iteration-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border-bottom: 1px solid transparent;
}

.iteration-card.open {
    border-color: var(--text-dim);
    background: rgba(17, 17, 17, 0.2);
    /* Transparent when open */
}

/* ... styles ... */

/* Content Area */
/* --- Content Area --- */
.iteration-outer-content {
    display: none;
    padding: 0;
    background: transparent;
}

.iteration-card.open .iteration-outer-content {
    display: block;
    animation: expandContent 0.3s ease-out;
}

/* 1. Draft Section (for Iteration 1) */
.draft-section {
    padding: 32px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.7;
}

/* 2. Revision Details Box (for Iteration > 1) */
.revision-details-box {
    background: rgba(255, 255, 255, 0.03);
    /* Lighter background for better separation */
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sharp);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.revision-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.revision-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    /* Brighter than dim */
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.revision-icon {
    font-size: 1rem;
    color: var(--text-main);
    /* Pure white icons */
    opacity: 0.8;
}

.revision-item-content {
    color: var(--text-main);
    /* Pure white text */
    font-size: 1rem;
    padding-left: 26px;
    line-height: 1.6;
    font-weight: 400;
}

/* Specific styling for rewrite to look like code/diff */
.revision-item:last-child .revision-item-content {
    font-family: var(--font-body);
    /* Keep body font for readability, or mono if preferred */
    background: rgba(30, 30, 30, 0.6);
    /* Much clearer background */
    padding: 16px;
    border-radius: var(--radius-sharp);
    border-left: 3px solid var(--accent-active);
    /* Clear blue accent */
    border: 1px solid var(--border-subtle);
    border-left-width: 3px;
    color: #ffffff;
    font-weight: 500;
}

/* 3. Merged Section (for Iteration > 1) */
.merged-section {
    padding: 24px 32px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.section-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    /* Brighter */
    margin-bottom: 20px;
    display: block;
    font-weight: 700;
    opacity: 1;
    /* removed transparency */
}

/* --- Final Answer --- */

.final-answer {
    margin-top: 40px;
    padding: 40px 0;
    /* Vertical padding */
    background: transparent;
    border-left: 3px solid var(--text-main);
    padding-left: 40px;
    margin-left: 0;
    width: 100%;
}

.final-header {
    font-family: var(--font-display);
    text-transform: uppercase;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 24px;
    display: block;
}

.final-content {
    font-size: 1.1rem;
    color: var(--text-main);
    max-width: 100%;
}

/* --- Input Area --- */

.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-core);
    /* Solid background, no gradient */
    border-top: 1px solid var(--border-strong);
    padding: 24px 40px;
    display: flex;
    justify-content: center;
    z-index: 10;
    width: 100%;
}

.input-wrapper {
    width: 100%;
    /* removed max-width to allow full stretch as per "no square area" request */
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 12px 24px;
    border-radius: var(--radius-sharp);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--text-dim);
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    border-right: 1px solid var(--border-subtle);
    padding-right: 12px;
    min-width: auto;
    user-select: none;
}

.selected-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-main);
}

.dropdown-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-left: 8px;
    transition: transform 0.2s;
}

.custom-dropdown.active .dropdown-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    bottom: 100%;
    /* Anchor to top of input bar */
    left: 0;
    min-width: 100%;
    width: max-content;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sharp);
    margin-bottom: 12px;
    display: none;
    flex-direction: column;
    overflow: visible;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.custom-dropdown.active .dropdown-menu {
    display: flex;
    animation: fadeIn 0.1s ease-out;
}

.dropdown-item {
    position: relative;
    padding: 12px 16px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.95rem;
    transition: all 0.1s;
    white-space: nowrap;

    /* Flex Layout for Tag Support */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dropdown-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

.dropdown-item.selected {
    color: var(--text-main);
    background: var(--border-subtle);
}

/* Recommended Tag (Floating NEXT to list item) */
.recommended-tag {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;

    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;

    /* Dropdown Theme Style */
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;

    animation: fadeIn 0.2s ease-out;
    pointer-events: none;
    /* Just a visual label */
    z-index: 200;
}

/* Hide External Badge (Deprecated) */
.recommended-badge {
    display: none !important;
}

/* Custom Iteration Input */
.custom-input-container {
    position: absolute;
    bottom: 110%;
    /* Lift it up slightly more */
    left: 0;
    min-width: 280px;
    background: rgba(10, 10, 10, 0.95);
    /* Much darker, almost opaque */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sharp);
    margin-bottom: 12px;
    padding: 16px;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 12px;
    align-items: center;
    transform-origin: bottom left;
    animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#custom-iteration-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sharp);
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-display);
    /* Use display font for numbers */
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

#custom-iteration-input:focus {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

#custom-iteration-input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
}

/* Hide spin buttons for number input */
#custom-iteration-input::-webkit-outer-spin-button,
#custom-iteration-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#custom-iteration-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

.custom-confirm-btn {
    background: var(--text-main);
    color: var(--bg-core);
    border: none;
    padding: 0 20px;
    height: 42px;
    /* Match input height height approx */
    border-radius: var(--radius-sharp);
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    letter-spacing: -0.01em;
}

.custom-confirm-btn:hover {
    background: #ffffff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.custom-confirm-btn:active {
    transform: translateY(0);
    opacity: 0.9;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1.1rem;
    resize: none;
    max-height: 150px;
    outline: none;
    padding: 10px 0;
}

.chat-input::placeholder {
    color: var(--text-dim);
}

/* Send Button */
.send-btn {
    background: var(--text-main);
    color: var(--bg-core);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sharp);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.4rem;
}

.send-btn:hover:not(:disabled) {
    background: #cccccc;
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: var(--border-strong);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.send-icon {
    width: 24px;
    height: 24px;
    filter: brightness(0);
}

.send-btn:disabled .send-icon {
    filter: brightness(0) invert(1) opacity(0.5);
}

/* --- Markdown Content Styling --- */
.markdown-content p {
    margin-bottom: 1.2em;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content code {
    background: var(--border-subtle);
    padding: 2px 6px;
    border-radius: 2px;
    font-family: monospace;
    font-size: 0.9em;
    color: #ffcc00;
}

.markdown-content pre {
    background: #000;
    padding: 20px;
    border-radius: var(--radius-sharp);
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid var(--border-subtle);
}

/* --- Animations --- */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}