:root {
    --bg: #eef1ea;
    --bg-warm: #faf4e8;
    --surface: rgba(255, 255, 255, .78);
    --surface-strong: rgba(255, 255, 255, .94);
    --surface-dark: rgba(14, 24, 22, .76);
    --text: #17201d;
    --muted: #6a746e;
    --line: rgba(31, 43, 38, .12);
    --line-dark: rgba(255, 255, 255, .12);
    --accent: #0f8f71;
    --accent-2: #f0a94a;
    --accent-3: #7b6df0;
    --accent-soft: #e3f8ef;
    --ink: #0d1715;
    --danger: #bd3f47;
    --warn: #b86a00;
    --shadow: 0 24px 70px rgba(17, 27, 23, .14);
    --shadow-soft: 0 14px 34px rgba(17, 27, 23, .09);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
    --font: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font);
    background:
        radial-gradient(circle at 9% 8%, rgba(240, 169, 74, .24), transparent 28rem),
        radial-gradient(circle at 86% 5%, rgba(15, 143, 113, .18), transparent 24rem),
        linear-gradient(135deg, var(--bg), var(--bg-warm));
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(20, 29, 25, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 29, 25, .035) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 72%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    color: #fff;
    font-weight: 800;
    letter-spacing: -.01em;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .22), transparent 32%),
        linear-gradient(135deg, #13a880, #08745e);
    box-shadow: 0 16px 34px rgba(15, 143, 113, .28);
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

button:hover {
    transform: translateY(-2px);
    filter: saturate(1.08);
    box-shadow: 0 20px 42px rgba(15, 143, 113, .34);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    cursor: not-allowed;
    color: rgba(255, 255, 255, .72);
    background: linear-gradient(135deg, #aab5ae, #8c9991);
    box-shadow: none;
    transform: none;
    filter: none;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 16px;
    padding: 13px 14px;
    outline: none;
    color: var(--text);
    background: rgba(255, 255, 255, .92);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

select {
    cursor: pointer;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(15, 143, 113, .62);
    background: #fff;
    box-shadow:
        0 0 0 5px rgba(15, 143, 113, .12),
        inset 0 1px 0 rgba(255, 255, 255, .8);
}

.app-shell {
    position: relative;
    display: grid;
    grid-template-columns: 376px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
    overflow: hidden;
    color: #edf8f3;
    background:
        radial-gradient(circle at 14% 8%, rgba(240, 169, 74, .24), transparent 18rem),
        radial-gradient(circle at 92% 18%, rgba(15, 143, 113, .32), transparent 16rem),
        linear-gradient(180deg, #111b18, #0b1210 58%, #111714);
    border-right: 1px solid rgba(255, 255, 255, .1);
    box-shadow: 16px 0 54px rgba(13, 23, 21, .22);
}

.sidebar::after {
    content: "";
    position: absolute;
    inset: auto -40px -80px 36px;
    height: 190px;
    border-radius: 999px;
    background: rgba(240, 169, 74, .12);
    filter: blur(36px);
    pointer-events: none;
}

.brand-row {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 8px 4px 6px;
}

.brand-mark,
.login-mark {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #06241d;
    font-weight: 950;
    letter-spacing: -.06em;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .18)),
        linear-gradient(135deg, #8ff1c5, #f7c96a);
    box-shadow:
        0 16px 36px rgba(0, 0, 0, .28),
        inset 0 1px 0 rgba(255, 255, 255, .88);
}

.brand-row h1,
.task-header h2,
.login-box h1 {
    margin: 0;
}

.brand-row h1 {
    font-size: 21px;
    letter-spacing: -.04em;
}

.brand-row p,
.task-header p,
.eyebrow {
    margin: 5px 0 0;
    color: var(--muted);
}

.sidebar .brand-row p,
.sidebar .section-title,
.sidebar-footer {
    color: rgba(237, 248, 243, .64);
}

.sidebar-footer {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 4px;
    font-size: 13px;
}

.sidebar-footer a {
    color: #9ff2ca;
    text-decoration: none;
    font-weight: 800;
}

.section-title,
.panel-title {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.new-task,
.chat-list-wrap,
.console-panel,
.details-panel,
.status-strip {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.new-task,
.chat-list-wrap {
    position: relative;
    z-index: 1;
    border-color: var(--line-dark);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .105), rgba(255, 255, 255, .055));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.new-task {
    padding: 16px;
}

.new-task form,
.message-form,
.login-form {
    display: grid;
    gap: 11px;
}

.new-task button {
    width: 100%;
    margin-top: 2px;
    padding: 13px 16px;
}

.chat-list-wrap {
    min-height: 0;
    flex: 1;
    padding: 16px;
}

.chat-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 480px);
    overflow: auto;
    padding-right: 2px;
}

.chat-item {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 18px;
    padding: 13px 14px;
    color: #f6fff9;
    background: rgba(255, 255, 255, .075);
    box-shadow: none;
}

.chat-item:hover {
    background: rgba(255, 255, 255, .12);
    box-shadow: none;
}

.chat-item.active {
    color: #08271f;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .36)),
        linear-gradient(135deg, #b6f5d3, #f5c872);
    border-color: rgba(255, 255, 255, .58);
}

.chat-item strong {
    display: block;
    font-size: 14px;
    letter-spacing: -.01em;
}

.chat-item small {
    display: block;
    margin-top: 6px;
    color: rgba(246, 255, 249, .62);
}

.chat-item.active small {
    color: rgba(8, 39, 31, .66);
}

.main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 18px;
    padding: 28px;
}

.task-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 4px 4px 2px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 6px rgba(15, 143, 113, .12);
}

.task-header h2 {
    margin-top: 8px;
    font-size: clamp(28px, 3vw, 42px);
    line-height: .98;
    letter-spacing: -.065em;
}

.task-header p {
    max-width: 720px;
}

.stream-status {
    font-size: 13px;
}

.stream-status[data-mode="live"] {
    color: var(--accent);
}

.stream-status[data-mode="reconnecting"] {
    color: var(--warn);
}

.task-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.task-actions button {
    color: var(--ink);
    background: rgba(255, 255, 255, .68);
    border: 1px solid rgba(255, 255, 255, .9);
    box-shadow: var(--shadow-soft);
}

.task-actions button:hover {
    background: #fff;
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.status-strip > div {
    position: relative;
    min-width: 0;
    padding: 18px 20px;
    background: rgba(255, 255, 255, .42);
    border-right: 1px solid var(--line);
}

.status-strip > div:last-child {
    border-right: 0;
}

.status-strip span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.status-strip strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 15px;
}

.work-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 370px;
    gap: 18px;
    min-height: 0;
    flex: 1;
}

.console-panel,
.details-panel {
    min-height: 0;
    padding: 20px;
}

.console-panel {
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .72));
}

.message-stream {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 380px;
    overflow: auto;
    padding: 4px 6px 4px 1px;
}

.message {
    max-width: 92%;
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 22px;
    padding: 14px 16px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(17, 27, 23, .075);
}

.message.manager,
.message.user {
    align-self: flex-end;
    border-color: rgba(15, 143, 113, .22);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .55)),
        linear-gradient(135deg, #dff9eb, #f6efc9);
}

.message.agent {
    align-self: flex-start;
    background:
        linear-gradient(180deg, #ffffff, #f7faf7);
}

.message.agent-error {
    align-self: flex-start;
    border-color: rgba(189, 63, 71, .28);
    background: #fff3f4;
}

.message.pending {
    opacity: .76;
}

.message-role {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.message-role::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.message pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.58;
}

.message-form {
    grid-template-columns: minmax(0, 1fr) 112px;
    align-items: end;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .58));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
}

.message-form textarea {
    min-height: 70px;
    background: rgba(255, 255, 255, .92);
}

.message-form button {
    height: 48px;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    margin-top: 12px;
    padding: 9px 13px;
    border: 1px solid rgba(15, 143, 113, .2);
    border-radius: 999px;
    background: var(--accent-soft);
    color: #08745e;
    font-size: 13px;
    font-weight: 800;
}

.typing-indicator[hidden],
.new-reply-button[hidden] {
    display: none;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing-dot 1.1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: .15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: .3s;
}

.new-reply-button {
    position: sticky;
    bottom: 92px;
    align-self: center;
    width: fit-content;
    margin: -46px auto 10px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .12), transparent),
        linear-gradient(135deg, #1b2724, #0d1715);
    box-shadow: 0 18px 44px rgba(13, 23, 21, .28);
}

.details-panel {
    overflow: auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .64));
}

.changed-files,
.task-log {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.changed-file,
.log-entry,
.empty-state {
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 17px;
    padding: 12px;
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 8px 20px rgba(17, 27, 23, .045);
}

.changed-file {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
}

.changed-file code {
    overflow-wrap: anywhere;
    font-family: var(--mono);
    font-size: 12px;
}

.changed-file.is-new {
    border-color: rgba(15, 143, 113, .34);
    background: rgba(227, 248, 239, .82);
}

.status-code {
    display: inline-grid;
    place-items: center;
    min-width: 36px;
    min-height: 28px;
    border-radius: 999px;
    color: #08745e;
    background: rgba(15, 143, 113, .12);
    font-weight: 950;
    font-size: 12px;
}

.log-entry time {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    color: var(--muted);
    background: rgba(255, 255, 255, .5);
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10;
    max-width: 430px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 18px;
    color: #fff;
    background: rgba(13, 23, 21, .92);
    box-shadow: 0 22px 64px rgba(13, 23, 21, .34);
    backdrop-filter: blur(14px);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 22px;
    background:
        radial-gradient(circle at 25% 12%, rgba(240, 169, 74, .26), transparent 24rem),
        radial-gradient(circle at 78% 9%, rgba(15, 143, 113, .2), transparent 22rem),
        linear-gradient(135deg, #edf2eb, #faf4e8);
}

.login-box {
    width: min(440px, 100%);
    border: 1px solid rgba(255, 255, 255, .78);
    border-radius: 30px;
    padding: 30px;
    background: rgba(255, 255, 255, .76);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.login-box h1 {
    margin: 16px 0 20px;
    font-size: 34px;
    line-height: 1;
    letter-spacing: -.06em;
}

.login-form label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.login-form input {
    margin-top: 7px;
}

.login-form button {
    margin-top: 4px;
}

.alert {
    border-radius: 16px;
    padding: 11px 12px;
}

.alert-danger {
    color: var(--danger);
    background: #fff0f1;
    border: 1px solid rgba(189, 63, 71, .22);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: rgba(23, 32, 29, .22);
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(23, 32, 29, .34);
    background-clip: content-box;
}

@keyframes typing-dot {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .45;
    }

    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

@media (max-width: 1180px) {
    .app-shell,
    .work-area {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        overflow: visible;
    }

    .chat-list {
        max-height: 280px;
    }

    .status-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .main,
    .sidebar {
        padding: 16px;
    }

    .task-header,
    .task-actions {
        display: grid;
        justify-content: stretch;
    }

    .status-strip {
        grid-template-columns: 1fr;
    }

    .status-strip > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .message {
        max-width: 100%;
    }

    .message-form {
        grid-template-columns: 1fr;
    }
}
