:root {
    --bg: #efefed;
    --panel: #fbfbfa;
    --sidebar: #f1f1ef;
    --column: #f8f8f6;
    --card: #ffffff;
    --line: #dededb;
    --line-soft: #e9e9e6;
    --text: #171717;
    --muted: #73736f;
    --muted-2: #9b9b96;
    --blue: #2876e8;
    --blue-soft: #eaf2ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .03);
    --radius: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

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

button {
    cursor: pointer;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
    margin: 0;
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, .04);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .06);
}

.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100vh;
    padding: 20px 12px 16px;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
}

.brand {
    font-size: 22px;
    font-weight: 700;
    content: "ka";
    margin: 0 8px 18px;
}

.brand span {
    font-weight: 400;
    padding-left: 1px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 6px 16px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
}

.sidebar-search:focus-within {
    border-color: #c6d9f5;
    box-shadow: 0 0 0 3px rgba(40, 118, 232, .08);
}

.sidebar-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 12px;
}

.sidebar-search svg {
    width: 16px;
    height: 16px;
}

.utility-nav,
.projects nav,
.sidebar-bottom {
    display: grid;
    gap: 2px;
}

.utility-nav a,
.project-link,
.sidebar-bottom a {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 7px 9px;
    border-radius: 7px;
    color: #2c2c2a;
    text-decoration: none;
    font-weight: 520;
}

.utility-nav a:hover,
.project-link:hover,
.sidebar-bottom a:hover {
    background: rgba(0, 0, 0, .04);
}

.utility-nav svg,
.project-link svg,
.sidebar-bottom svg {
    width: 17px;
    height: 17px;
    color: #71716d;
}

.project-link.active {
    background: #e5e5e2;
    font-weight: 650;
}

.project-link.active svg {
    color: var(--blue);
}

.projects {
    margin-top: 18px;
}

.projects>header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 9px 8px;
    color: var(--muted);
    font-size: 12px;
}

.projects>header button,
.column-actions button,
.drawer-header button,
dialog header button {
    display: inline-grid;
    place-items: center;
    border: 0;
    background: transparent;
    padding: 4px;
    color: var(--muted);
}

.projects>header button:hover,
.column-actions button:hover,
.drawer-header button:hover {
    color: var(--text);
    background: rgba(0, 0, 0, .05);
    border-radius: 6px;
}

.project-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.archived-projects {
    margin: 18px 6px 0;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.archived-projects p {
    margin: 0 3px 6px;
    color: var(--muted-2);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.archived-project {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 30px;
    padding: 6px 3px;
    border: 0;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-size: 11px;
}

.archived-project:hover {
    color: var(--text);
}

.archived-project svg {
    width: 15px;
    height: 15px;
}

.archived-project span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.archived-project small {
    margin-left: auto;
    color: var(--blue);
    font-size: 10px;
    opacity: 0;
}

.archived-project:hover small {
    opacity: 1;
}

.sidebar-bottom {
    margin-top: auto;
}

.workspace {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel);
}

.workspace-header {
    border-bottom: 1px solid var(--line);
    background: rgba(251, 251, 250, .96);
}

.heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 28px 11px;
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

h1 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -.025em;
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-button,
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 600;
}

.text-button {
    background: transparent;
    color: var(--muted);
}

.text-button:hover {
    color: var(--text);
    background: #f3f3f1;
}

.primary-button {
    background: #1f1f1e;
    color: #fff;
}

.primary-button:hover {
    background: #000;
}

.primary-button svg {
    width: 15px;
    height: 15px;
}

.view-tabs {
    display: flex;
    gap: 28px;
    padding: 0 28px;
}

.view-tabs button {
    position: relative;
    border: 0;
    background: transparent;
    padding: 11px 0 13px;
    color: var(--muted);
    font-size: 12px;
}

.view-tabs button.active {
    color: var(--blue);
    font-weight: 650;
}

.view-tabs button.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--blue);
}

.filter-bar {
    display: flex;
    align-items: end;
    gap: 14px;
    padding: 10px 28px;
    border-bottom: 1px solid var(--line-soft);
    background: #fff;
}

.filter-bar label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
}

.filter-bar select {
    min-width: 140px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 6px 8px;
}

.checkbox-label {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 6px !important;
    padding-bottom: 7px;
}

.board-view {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(290px, 1fr);
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: #f7f7f5;
}

.board-column {
    min-width: 290px;
    border-right: 1px solid var(--line);
    background: var(--column);
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 15px 12px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(248, 248, 246, .96);
    backdrop-filter: blur(8px);
}

.column-header>div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-header h2 {
    margin: 0;
    font-size: 13px;
    letter-spacing: -.01em;
}

.column-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #edf2fb;
    color: var(--blue);
    font-size: 10px;
    font-weight: 700;
}

.column-help {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.column-help:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.column-help-wrap {
    position: relative;
    display: inline-flex;
}

.column-tooltip {
    position: fixed;
    z-index: 100;
    width: 230px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #1f1f1e;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
    font-size: 13px;
    font-weight: 450;
    line-height: 1.45;
    opacity: 0;
    transform: translate(-50%, -100%);
    transition: opacity .18s ease;
    visibility: hidden;
}

.column-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.column-tooltip::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    border: 5px solid transparent;
    border-top-color: #1f1f1e;
    transform: translateX(-50%);
}

.column-tooltip[hidden] {
    display: none;
}

.column-actions {
    display: flex;
    gap: 3px;
}

.column-actions svg {
    width: 16px;
    height: 16px;
}

.card-stack {
    min-height: calc(100vh - 170px);
    padding: 0 12px 50px;
}

.kanban-card {
    background: var(--card);
    border: 1px solid #dfdfdc;
    border-radius: 10px;
    padding: 13px 13px 11px;
    margin-bottom: 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .03);
    cursor: grab;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, opacity .14s ease;
}

.kanban-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    border-color: #d3d3d0;
}

.kanban-card:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.kanban-card.dragging {
    opacity: .45;
    transform: rotate(1deg) scale(.99);
}

.kanban-card.filtered-out {
    display: none;
}

.card-top {
    display: grid;
    grid-template-columns: 15px minmax(0, 1fr) auto;
    gap: 7px;
    align-items: start;
}

.task-ring {
    width: 13px;
    height: 13px;
    margin-top: 2px;
    border: 1.6px solid #b7b7b3;
    border-radius: 50%;
}

.task-ring.priority-high {
    border-color: #d79955;
}

.task-ring.priority-urgent {
    border-color: #d0605b;
    box-shadow: inset 0 0 0 3px #fff;
    background: #d0605b;
}

.task-ring.priority-low {
    border-color: #9fb2a3;
}

.kanban-card h3 {
    margin: 0;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 640;
    letter-spacing: -.012em;
}

.agent-avatar {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
    margin-top: -2px;
    border-radius: 50%;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 9px;
    font-weight: 800;
}

.card-type {
    margin: 5px 0 12px 22px;
    color: var(--muted);
    font-size: 11px;
}

.kanban-card footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    border-top: 1px solid #f0f0ee;
    padding-top: 9px;
    color: var(--muted);
    font-size: 10px;
}

.score-pill {
    font-weight: 650;
    color: #575753;
}

.card-deadline {
    white-space: nowrap;
}

.drop-placeholder {
    height: 0;
    border: 1px dashed transparent;
    border-radius: 10px;
    transition: height .12s ease, border-color .12s ease, margin .12s ease;
}

.card-stack.drag-over .drop-placeholder {
    height: 52px;
    margin-top: 8px;
    border-color: #aac7f0;
    background: rgba(40, 118, 232, .03);
}

.list-view {
    flex: 1;
    overflow: auto;
    padding: 22px 28px;
    background: #fafaf9;
}

.list-view table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

th,
td {
    text-align: left;
    padding: 12px 13px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
}

th {
    position: sticky;
    top: 0;
    background: #f7f7f5;
    color: var(--muted);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: 0;
}

.list-card-row {
    cursor: pointer;
}

.list-card-row:hover td {
    background: #fafcff;
}

.list-card-row td:first-child {
    min-width: 280px;
}

.list-card-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.empty-view {
    flex: 1;
    display: grid;
    place-items: center;
    background: #fafaf9;
}

.empty-view>div {
    max-width: 440px;
    text-align: center;
    color: var(--muted);
}

.empty-view h2 {
    color: var(--text);
    margin-bottom: 6px;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(24, 24, 22, .28);
    z-index: 20;
    backdrop-filter: blur(3px);
}

.card-modal {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(430px, calc(100vw - 28px));
    height: calc(100vh - 28px);
    background: #fff;
    border: 1px solid #d9d9d6;
    border-radius: 18px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .2);
    opacity: 0;
    pointer-events: none;
    transform: translateX(calc(100% + 24px));
    transition: opacity .18s ease, transform .22s ease, width .22s ease, height .22s ease, top .22s ease, right .22s ease;
    overflow: hidden;
}

.card-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.card-modal.expanded {
    top: 24px;
    right: 50%;
    width: min(760px, calc(100vw - 48px));
    height: calc(100vh - 48px);
    transform: translateX(50%);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    padding: 15px 22px;
    background: #fff;
    border-bottom: 1px solid var(--line-soft);
}

.drawer-header span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-leading,
.card-navigation {
    display: flex;
    align-items: center;
    gap: 5px;
}

.drawer-leading {
    min-width: 94px;
}

.drawer-icon {
    display: inline-grid;
    place-items: center;
    border: 0;
    padding: 5px;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}

.drawer-icon:hover {
    color: var(--text);
    background: #f2f2f0;
}

.drawer-icon:disabled {
    opacity: .28;
    cursor: default;
}

.drawer-icon svg {
    width: 16px;
    height: 16px;
}

.collapse-icon {
    display: none;
}

.card-modal.expanded .expand-icon {
    display: none;
}

.card-modal.expanded .collapse-icon {
    display: inline;
}

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

.drawer-title-row {
    padding: 24px 28px 16px;
}

.title-input {
    width: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -.035em;
}

.icon-danger {
    border: 0;
    background: transparent;
    color: #a35e5a;
    padding: 5px;
    border-radius: 7px;
}

.icon-danger:hover {
    background: #fff0ef;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
}

.compact-grid {
    margin: 0 28px 15px;
}

.card-modal label,
dialog label,
.auth-card label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 550;
}

.card-modal input:not(.title-input),
.card-modal select,
.card-modal textarea,
dialog input,
.auth-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    background: #fbfbfa;
    outline: 0;
    color: var(--text);
    font-size: 13px;
}

.card-modal textarea {
    resize: vertical;
    line-height: 1.5;
}

.card-modal input:focus,
.card-modal select:focus,
.card-modal textarea:focus,
dialog input:focus,
.auth-card input:focus {
    border-color: #acc9ef;
    box-shadow: 0 0 0 3px rgba(40, 118, 232, .08);
    background: #fff;
}

.detail-tabs {
    display: flex;
    gap: 28px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
}

.detail-tabs button {
    position: relative;
    border: 0;
    background: transparent;
    padding: 12px 0 13px;
    color: var(--muted);
    font-size: 12px;
}

.detail-tabs button.active {
    color: var(--text);
    font-weight: 650;
}

.detail-tabs button.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--blue);
}

.detail-panels {
    min-height: 0;
    overflow-y: auto;
    flex: 1;
    padding: 2px 28px 24px;
}

.detail-panel[hidden] {
    display: none;
}

.full-field {
    margin-top: 17px;
}

.source-grid {
    margin-top: 17px;
}

.url-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
}

.url-field a {
    display: grid;
    place-items: center;
    width: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
}

.url-field a:hover {
    color: var(--blue);
    border-color: #bdd1ee;
}

.activity-section {
    padding-top: 17px;
}

.activity-section h3 {
    margin: 0 0 12px;
    font-size: 13px;
}

.activity-item {
    display: grid;
    grid-template-columns: 7px 1fr;
    gap: 10px;
    padding: 8px 0;
}

.activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b8cbe6;
    margin-top: 5px;
}

.activity-item p {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

.activity-item small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.drawer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 28px;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--line);
}

.drawer-footer span {
    color: var(--muted);
    font-size: 10px;
}

#boardDialog,
#archiveDialog {
    width: min(420px, 90vw);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 0;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .16);
}

#boardDialog::backdrop,
#archiveDialog::backdrop {
    background: rgba(0, 0, 0, .22);
}

#boardDialog form,
#archiveDialog form {
    padding: 18px;
}

#boardDialog header,
#boardDialog footer,
#archiveDialog header,
#archiveDialog footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

#boardDialog header,
#archiveDialog header {
    margin-bottom: 16px;
}

#boardDialog h2,
#archiveDialog h2 {
    margin: 0;
    font-size: 19px;
}

#boardDialog footer,
#archiveDialog footer {
    justify-content: flex-end;
    margin-top: 18px;
}

.dialog-copy {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.5;
    font-size: 12px;
}

.toast {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    padding: 9px 13px;
    border-radius: 8px;
    background: #1f1f1e;
    color: #fff;
    font-size: 12px;
    box-shadow: var(--shadow);
    transition: .18s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #f0f0ee;
    padding: 20px;
}

.auth-card {
    width: min(390px, 94vw);
    display: grid;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .06);
}

.auth-card .brand {
    margin: 0 0 8px;
}

.auth-card h1 {
    font-size: 25px;
}

.auth-card p {
    margin: 0;
    color: var(--muted);
}

.auth-card .primary-button {
    width: 100%;
    margin-top: 4px;
}

.error-banner {
    padding: 9px 10px;
    border-radius: 7px;
    background: #fff0ef;
    color: #9b3c38;
    font-size: 12px;
}

.setup-card pre {
    padding: 12px;
    background: #f5f5f3;
    border-radius: 8px;
    overflow: auto;
}

.setup-card small {
    color: var(--muted-2);
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 68px minmax(0, 1fr);
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
    }

    .sidebar {
        padding-inline: 8px;
    }

    .brand {
        font-size: 0;
        margin-inline: 4px;
    }

    .brand::before {
        content: "ka";
        font-size: 18px;
    }

    .sidebar-search input,
    .utility-nav span,
    .project-link span,
    .sidebar-bottom span,
    .projects>header span {
        display: none;
    }

    .sidebar-search {
        justify-content: center;
        padding: 8px;
    }

    .utility-nav a,
    .project-link,
    .sidebar-bottom a {
        justify-content: center;
    }

    .projects>header {
        justify-content: center;
        padding: 0 0 8px;
    }

    .heading-row {
        padding-inline: 18px;
    }

    .view-tabs {
        padding-inline: 18px;
        gap: 20px;
    }

    .board-view {
        grid-auto-columns: 285px;
    }
}

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

    .sidebar {
        display: none;
    }

    .heading-actions .text-button {
        display: none;
    }

    .heading-row {
        align-items: center;
    }

    .view-tabs button[data-view="overview"],
    .view-tabs button[data-view="activity"] {
        display: none;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .card-modal {
        width: min(680px, calc(100vw - 24px));
        height: min(780px, calc(100vh - 24px));
    }

    .drawer-footer span {
        display: none;
    }

    .drawer-footer {
        justify-content: flex-end;
    }
}