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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #222;
    border-bottom: 1px solid #333;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

header .model-label {
    font-size: 0.85rem;
    color: #888;
    margin-left: 0.75rem;
}

button {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
}

button:hover {
    background: #3a3a3a;
}

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

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user {
    background: #2a3a5a;
}

.message.assistant {
    background: #2a2a2a;
}

.message.system {
    background: #4a2a2a;
    font-style: italic;
    color: #ffaaaa;
}

.message-role {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
    letter-spacing: 0.05em;
}

#composer {
    border-top: 1px solid #333;
    padding: 0.75rem 1rem;
    background: #222;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#composer textarea {
    flex: 1;
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.6rem;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 2.5rem;
    max-height: 12rem;
    line-height: 1.4;
}

#composer textarea:focus {
    outline: none;
    border-color: #4a6a9a;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem;
    width: 90%;
    max-width: 480px;
}

.modal h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal label {
    display: block;
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: #aaa;
}

.modal input,
.modal select {
    width: 100%;
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
}

.modal-actions {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.3rem;
}

/* Markdown list spacing inside messages */
.message-content ul,
.message-content ol {
    padding-left: 1.5rem;       /* room for bullets/numbers */
    margin: 0.5rem 0;            /* breathing room above and below */
}

.message-content li {
    margin: 0.25rem 0;           /* small gap between items */
}

/* Markdown content styling inside message bubbles */
.message-content p {
    margin: 0.25rem 0;
}

.message-content p:first-child {
    margin-top: 0;                  /* no extra space at top of message */
}

.message-content p:last-child {
    margin-bottom: 0;               /* no extra space at bottom */
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 0.5rem 0 0.2rem 0;     /* more space above, less below */
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.35rem; }
.message-content h2 { font-size: 1.2rem; }
.message-content h3 { font-size: 1.05rem; }
.message-content h4 { font-size: 1rem; }

.message-content ul,
.message-content ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.message-content li {
    margin: 0.25rem 0;
}

.message-content blockquote {
    border-left: 3px solid #555;
    padding-left: 0.75rem;
    margin: 0.3rem 0;
    color: #b0b0b0;
    font-style: italic;
}

.message-content code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #111;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0.4rem 0;
    overflow-x: auto;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
}

.message-content a {
    color: #6ab0ff;
    text-decoration: underline;
}

.message-content a:hover {
    color: #88c0ff;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content hr {
    border: none;
    border-top: 1px solid #444;
    margin: 0.5rem 0;
}

/* Tables (GitHub-flavored markdown) */
.message-content table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid #444;
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.message-content th {
    background: #2a2a2a;
    font-weight: 600;
}

/* Tighter list spacing */
.message-content ul,
.message-content ol {
    padding-left: 1.5rem;
    margin: 0.4rem 0;
}

.message-content li {
    margin: 0.15rem 0;          /* was 0.25rem — tighter between items */
}

/* Paragraphs INSIDE list items get reduced spacing,
   since the list already provides structure */
.message-content li p {
    margin: 0.15rem 0;          /* much tighter than the 0.5rem default for paragraphs */
}

.message-content li p:first-child {
    margin-top: 0;
}

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

/* Nested lists shouldn't get a big gap above */
.message-content li > ul,
.message-content li > ol {
    margin: 0.15rem 0;
}
