html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color-scheme: dark;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    /* Reserve space for the fixed input bar + iOS home indicator */
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
    background-color: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-tap-highlight-color: transparent;
}

.header {
    padding: 0;
    padding-top: env(safe-area-inset-top);
}

.header a {
    text-decoration: none;
    display: block;
    line-height: 0;
}

.header-logo {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
    margin: 0 auto;
}

.status {
    padding: 8px;
    text-align: center;
    color: #3fb950;
    font-size: 0.9em;
}

.messages {
    padding: 10px;
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    flex-grow: 1;
}

.message {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    box-sizing: border-box;
}

.user-message {
    background-color: #1f6feb;
    color: #ffffff;
}

.bot-message {
    background-color: #161b22;
    color: #c9d1d9;
    line-height: 1.5;
    border: 1px solid #21262d;
}

.bot-message ul,
.bot-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.bot-message li {
    margin: 4px 0;
}

.bot-message p {
    margin: 8px 0;
}

.bot-message a {
    color: #58a6ff;
}

.bot-message a:hover {
    color: #79c0ff;
}

.bot-message h1,
.bot-message h2,
.bot-message h3,
.bot-message h4 {
    color: #e6edf3;
    border-bottom: 1px solid #21262d;
    padding-bottom: 4px;
}

.bot-message strong {
    color: #e6edf3;
}

.bot-message blockquote {
    margin: 8px 0;
    padding: 4px 12px;
    border-left: 3px solid #30363d;
    color: #8b949e;
}

.bot-message pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: #0d1117;
    border: 1px solid #30363d;
    padding: 10px;
    border-radius: 6px;
    white-space: pre;
    color: #e6edf3;
}

.bot-message code {
    word-break: break-word;
    overflow-wrap: anywhere;
    background-color: #0d1117;
    color: #79c0ff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

.bot-message pre code {
    background-color: transparent;
    color: #e6edf3;
    padding: 0;
    font-size: 1em;
}

.bot-message img,
.bot-message table {
    max-width: 100%;
    height: auto;
}

.bot-message table {
    border-collapse: collapse;
}

.bot-message th,
.bot-message td {
    border: 1px solid #30363d;
    padding: 6px 10px;
}

.bot-message th {
    background-color: #161b22;
    color: #e6edf3;
}

.input-container {
    display: flex;
    align-items: flex-end;
    padding: 8px;
    padding-left: calc(8px + env(safe-area-inset-left));
    padding-right: calc(8px + env(safe-area-inset-right));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 8px;
    background-color: #0d1117;
    border-top: 1px solid #21262d;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

#messageInput {
    flex-grow: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #30363d;
    border-radius: 20px;
    height: 20px;
    min-height: 20px;
    max-height: 200px;
    resize: none;
    /* 16px prevents iOS Safari from zooming on focus */
    font-size: 16px;
    line-height: 20px;
    background-color: #161b22;
    color: #e6edf3;
    overflow-y: hidden;
    -webkit-appearance: none;
    appearance: none;
}

#messageInput:focus {
    outline: none;
    border-color: #58a6ff;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

#messageInput::placeholder {
    color: #6e7681;
    font-style: italic;
}

button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    background-color: #1f6feb;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
}

button:hover {
    background-color: #388bfd;
}

button:disabled {
    background-color: #30363d;
    color: #6e7681;
    cursor: not-allowed;
}
