* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

:root {
    --bg: #0b0d11;
    --panel: #12151b;
    --panel2: #171b22;
    --border: #272d38;
    --text: #edf1f7;
    --muted: #8e98a8;
    --accent: #7c8cff;
    --green: #49d17d;
    --red: #ff6875;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 74px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: #101319;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 2px;
}

.subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.status {
    font-size: 12px;
    font-weight: 700;
}

.status.online {
    color: var(--green);
}

.status.offline {
    color: var(--red);
}

.layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: 245px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    background: #0f1217;
    border-right: 1px solid var(--border);
}

.sidebar-title,
.service-title,
.section-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.mode-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #0d1015;
}

.mode-button {
    flex: 1;
    padding: 9px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.mode-button.active {
    background: var(--panel2);
    color: var(--text);
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.new-project,
.small-button,
.icon-button,
.stop-button,
.run-button,
.download-project-button,
.small-download-button,
.project-download {
    border-radius: 8px;
    cursor: pointer;
}

.new-project {
    width: 100%;
    margin-top: 14px;
    padding: 11px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    font-weight: 700;
}

.new-project:hover {
    background: #1d2230;
}

.project-list {
    margin-top: 15px;
    overflow: auto;
}

.project-row {
    display: flex;
    align-items: stretch;
    gap: 3px;
    margin-bottom: 4px;
}

.project {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    cursor: pointer;
}

.project:hover,
.project.active {
    background: #1d2230;
    color: var(--text);
}

.project-icon {
    color: var(--accent);
}

.project-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-download {
    width: 36px;
    flex-shrink: 0;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
}

.project-download:hover {
    background: #1d2230;
    border-color: var(--border);
    color: var(--text);
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 20px;
}

.services {
    margin-top: 10px;
}

.services > div {
    display: flex;
    justify-content: space-between;
    padding: 6px 3px;
    color: var(--muted);
    font-size: 12px;
}

.services span {
    color: var(--green);
}

.service-error {
    color: var(--red) !important;
}

.workspace {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 25px 30px;
}

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

.workspace-header h1 {
    margin: 5px 0 0;
    font-size: 25px;
}

.workspace-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.download-project-button {
    padding: 10px 15px;
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--text);
    font-size: 11px;
    font-weight: 800;
}

.download-project-button:hover {
    background: #1d2230;
    border-color: var(--accent);
}

.model-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 10px;
    color: var(--muted);
}

.model-info strong {
    margin-top: 4px;
    color: #a7b0ff;
    letter-spacing: 1px;
}

.model-info small {
    margin-top: 6px;
    color: var(--green);
}

.web-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.web-toggle button {
    padding: 10px 12px;
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--panel2);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .6px;
    cursor: pointer;
    white-space: nowrap;
}

.web-toggle button:last-child {
    border-right: 0;
}

.web-toggle button.active {
    background: var(--accent);
    color: #fff;
}

.chat-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg {
    max-width: 78%;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.msg-role {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
}

.msg-content {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
    font-size: 14px;
}

.msg-user {
    align-self: flex-end;
    background: #1a1f3a;
    border-color: #313a66;
}

.msg-user .msg-role {
    color: #a7b0ff;
}

.msg-assistant {
    align-self: flex-start;
    background: var(--panel);
}

.msg-reasoning {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0d1015;
}

.msg-reasoning summary {
    padding: 8px 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.msg-reasoning summary::-webkit-details-marker {
    display: none;
}

.msg-reasoning-content {
    padding: 0 10px 10px;
    color: var(--muted);
    font-size: 12px;
    font-style: italic;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-input-card {
    flex-shrink: 0;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.chat-input-card textarea {
    min-height: 90px;
}

.chat-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}

.chat-sources {
    color: var(--muted);
    font-size: 11px;
}

.file-download {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.file-download:hover {
    background: #1d2230;
    border-color: var(--border);
    color: var(--text);
}

.agent-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 20px;
}

.agent-main,
.right-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.task-card,
.activity-card,
.files-card,
.output-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.task-card {
    padding: 20px;
}

.task-card > label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.4px;
}

textarea {
    width: 100%;
    min-height: 145px;
    resize: vertical;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: #0d1015;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.55;
}

textarea:focus {
    border-color: var(--accent);
}

.task-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 15px;
}

.step-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.step-control label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

select {
    padding: 9px 30px 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel2);
    color: var(--text);
}

.button-row {
    display: flex;
    gap: 8px;
}

.run-button {
    padding: 12px 22px;
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.stop-button {
    padding: 12px 16px;
    border: 1px solid #6c3038;
    background: #29171a;
    color: #ff9aa3;
    font-weight: 800;
}

.hint {
    margin-top: 10px;
    color: #697383;
    font-size: 10px;
}

.activity-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 17px 19px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 4px 0 0;
    font-size: 15px;
}

.small-button,
.icon-button,
.small-download-button {
    border: 1px solid var(--border);
    background: var(--panel2);
    color: var(--muted);
}

.small-button {
    padding: 7px 10px;
}

.icon-button {
    width: 34px;
    height: 32px;
    font-size: 18px;
}

.small-download-button {
    height: 32px;
    padding: 0 10px;
    font-size: 10px;
    font-weight: 800;
}

.small-download-button:hover {
    color: var(--text);
    border-color: var(--accent);
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.activity {
    flex: 1;
    overflow: auto;
    padding: 8px 12px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid #1e232c;
}

.activity-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #1a1f29;
}

.activity-item.success .activity-icon {
    color: var(--green);
}

.activity-item.failure .activity-icon {
    color: var(--red);
}

.activity-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .8px;
}

.activity-content pre {
    margin: 5px 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.45;
}

.files-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.file-list {
    flex: 1;
    overflow: auto;
    padding: 8px 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 7px;
    border-bottom: 1px solid #1e232c;
    color: var(--muted);
    font-size: 12px;
}

.file-icon {
    width: 23px;
    text-align: center;
}

.file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.output-card {
    height: 180px;
    display: flex;
    flex-direction: column;
}

.output-card pre {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 14px;
    color: var(--muted);
    font: 11px/1.45 monospace;
    white-space: pre-wrap;
}

.empty-state,
.empty-projects,
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #687281;
    font-size: 12px;
}

.empty-state {
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
}

.error-message {
    padding: 10px;
    color: var(--red);
    font-size: 11px;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast {
    position: fixed;
    right: 25px;
    bottom: 25px;
    padding: 12px 17px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #1b2029;
    color: var(--text);
    font-size: 12px;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: .2s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    color: #ff9ba4;
}

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 7, 10, 0.86);
    backdrop-filter: blur(2px);
}

.login-card {
    width: 320px;
    padding: 28px 26px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-card .brand {
    text-align: center;
}

.login-card .subtitle {
    margin-bottom: 22px;
    text-align: center;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#loginForm label {
    margin-top: 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

#loginForm input {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0d1015;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

#loginForm input:focus {
    border-color: var(--accent);
}

.login-submit {
    margin-top: 18px;
    width: 100%;
    text-align: center;
}

.account-widget {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.account-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel2);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.account-toggle:hover {
    border-color: var(--accent);
}

.account-dot {
    color: var(--green);
    font-size: 10px;
}

.account-panel {
    width: 250px;
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-user-line {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
}

.account-full {
    width: 100%;
    padding: 9px;
    text-align: center;
}

.account-divider {
    margin: 12px 0 4px;
    border-top: 1px solid var(--border);
}

.account-panel input {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0d1015;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}

.account-panel input:focus {
    border-color: var(--accent);
}

.account-msg {
    min-height: 14px;
    font-size: 11px;
    color: var(--green);
}

.account-msg.error-message {
    padding: 0;
    color: var(--red);
}

@media(max-width: 1100px) {

    .workspace-actions {
        gap: 10px;
    }

    .download-project-button {
        padding: 9px 11px;
    }

    .agent-layout {
        grid-template-columns: minmax(0, 1fr) 330px;
    }
}

@media(max-width: 900px) {

    .sidebar {
        width: 190px;
    }

    .workspace {
        padding: 18px;
    }

    .agent-layout {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .right-panel {
        min-height: 500px;
    }
}