:root {
    --bg: #0f172a;
    --card: #1e293b;
    --accent: #38bdf8;
    --text: #e2e8f0;
    --muted: #94a3b8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.branding {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.logo-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.logo-mark svg {
    width: 30px;
    height: 30px;
}

.app-name {
    letter-spacing: 0.02em;
}

.user-info {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.95rem;
}

.update-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.update-link:hover,
.update-link:focus {
    text-decoration: underline;
}

.username {
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
}

.username:hover,
.username:focus {
    color: var(--accent);
}

.language-switcher {
    margin: 0;
}

.language-switcher select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.language-switcher select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.logout {
    color: var(--text);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
}

.logout:hover {
    background: rgba(255, 255, 255, 0.16);
}

main {
    padding: 32px;
    max-width: 960px;
    margin: 0 auto;
    font-size: calc(1rem + 4px);
}

main * {
    font-size: inherit;
}

.auth-card {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 12px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.auth-form label {
    color: var(--muted);
    font-size: 0.95rem;
}

.auth-form input {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.auth-form button {
    margin-top: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #0b1220;
    font-weight: 700;
    cursor: pointer;
}

.auth-form button:hover {
    filter: brightness(1.05);
}

.helper {
    color: var(--muted);
    margin-top: 12px;
}

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

.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fecdd3;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #bbf7d0;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.chat-shell {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    padding: 20px;
}

.mcp-connector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.mcp-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.mcp-row.mcp-toggle {
    grid-template-columns: 1fr;
    align-items: center;
}

.mcp-toggle__label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mcp-toggle__label input[type='checkbox'] {
    width: 18px;
    height: 18px;
}

.mcp-row.mcp-service-full {
    grid-template-columns: 1fr;
}

.mcp-row select,
.mcp-row input[type='url'],
.mcp-row textarea {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

#mcp-service {
    background: #000;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    color: #fff;
    color-scheme: dark;
}

#mcp-service option {
    background-color: #0b1220;
    color: var(--text);
}

#mcp-service optgroup {
    background-color: #0b1220;
    color: var(--text);
}

#mcp-service option {
    background: #0b1220;
    color: var(--text);
}

.mcp-row textarea#mcp-service-full {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    resize: none;
    overflow: hidden;
    min-height: 48px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.mcp-row button {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #0b1220;
    font-weight: 700;
    cursor: pointer;
}

.mcp-row button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mcp-status {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.tool-example {
    margin: 4px 0 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tool-example__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.tool-example__label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
}

.tool-example__action {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
}

.tool-example__action:hover {
    background: rgba(255, 255, 255, 0.16);
}

.tool-example__text {
    margin: 0;
    color: var(--text);
    line-height: 1.5;
}

.tool-example__input {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    resize: vertical;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chat-log {
    height: 420px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-message {
    padding: 12px;
    border-radius: 10px;
    max-width: 80%;
    line-height: 1.45;
}

.chat-message.user {
    align-self: flex-end;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.chat-message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message.mysql-table {
    font-family: 'Courier New', Courier, monospace;
    white-space: pre;
}

.chat-message .chat-preformatted {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
}

.chat-message a {
    color: #ffffff;
    text-decoration: underline;
}

.chat-form {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.chat-form textarea {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    resize: none;
    overflow: hidden;
}

.chat-form button {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #0b1220;
    font-weight: 700;
    cursor: pointer;
}

.update-status {
    margin-bottom: 16px;
    color: var(--accent);
    min-height: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
