:root {
    color: #17222d;
    background: #f3f5f7;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    --ink: #17222d;
    --muted: #64717d;
    --line: #dfe4e8;
    --paper: #fff;
    --cyan: #00b9e7;
    --cyan-dark: #087b98;
    --navy: #112431;
    --orange: #f47932;
    --red: #c73d4d;
    --green: #258561;
    --shadow: 0 18px 45px rgb(20 36 48 / 9%);
    --layout-gutter: clamp(1rem, 4vw, 4rem);
    --layout-width: 92rem;
    --layout-inline: max(
        var(--layout-gutter),
        calc((100vw - var(--layout-width)) / 2 + var(--layout-gutter))
    );
    --header-control-height: 2.875rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

.shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.empty-state {
    width: min(100%, 36rem);
    padding: 3rem;
    border: 1px solid #dfe5eb;
    border-radius: 1.5rem;
    background: #fff;
    box-shadow: 0 1rem 3rem rgb(20 32 43 / 8%);
    text-align: center;
}

.brand-mark {
    width: 3.5rem;
    height: 3.5rem;
    display: grid;
    place-items: center;
    margin: 0 auto 1rem;
    border-radius: 1rem;
    background: #00bdeb;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
}

.brand-mark--small {
    width: 2.45rem;
    height: 2.45rem;
    margin: 0;
    border-radius: 0.7rem;
    font-size: 1.05rem;
}

.eyebrow {
    color: #1684a0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

h1 {
    margin: 0.25rem 0 0.75rem;
    font-size: clamp(2rem, 8vw, 3.5rem);
}

h2,
h3,
h4,
p {
    margin-top: 0;
}

p {
    color: #526170;
    line-height: 1.6;
}

.button {
    display: inline-flex;
    margin-top: 1rem;
    padding: 0.8rem 1.1rem;
    border-radius: 0.75rem;
    background: #14202b;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.button:hover {
    background: #263b49;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.button--ghost {
    color: var(--ink);
    background: #edf1f3;
}

.button--ghost:hover {
    background: #e1e8ec;
}

.button--danger {
    background: #fae8eb;
    color: #9a2533;
}

.button:focus-visible {
    outline: 3px solid #00bdeb;
    outline-offset: 3px;
}

.app-header {
    position: sticky;
    z-index: 30;
    top: 0;
    min-height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.7rem var(--layout-inline);
    border-bottom: 1px solid rgb(223 228 232 / 85%);
    background: rgb(255 255 255 / 92%);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 0.1rem;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.header-actions,
.modal-actions,
.drawer-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.header-actions .button {
    min-height: var(--header-control-height);
    align-items: center;
    margin-top: 0;
    white-space: nowrap;
}

.header-actions .search-field input,
.header-actions .avatar-button {
    height: var(--header-control-height);
}

.avatar-button,
.icon-button,
.card-menu,
.tab,
.version-button {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.avatar-button {
    display: inline-flex;
    align-items: center;
    padding: 0.65rem;
    color: var(--muted);
    background: transparent;
}

.page {
    width: min(100%, var(--layout-width));
    margin: 0 auto;
    padding: var(--layout-gutter);
}

.page-heading,
.section-heading,
.pane-heading,
.project-card__top,
.kanban-column__heading,
.modal-heading,
.drawer-heading,
.list-card--row,
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-heading h1 {
    margin: 0;
}

.page-heading p:last-child,
.section-heading p:last-child {
    margin-bottom: 0;
}

.dashboard-page .page-heading {
    align-items: flex-end;
}

.dashboard-page .page-heading > .check-field {
    margin-bottom: 0.35rem;
}

.search-field input,
label input,
label select,
label textarea {
    width: 100%;
    padding: 0.72rem 0.82rem;
    border: 1px solid #ccd5db;
    border-radius: 0.7rem;
    background: #fff;
    color: var(--ink);
}

.search-field input {
    width: min(28vw, 22rem);
    padding-left: 1rem;
    background: #f6f8f9;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgb(0 185 231 / 35%);
    outline-offset: 2px;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.check-field input {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    accent-color: var(--cyan-dark);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 1.1rem;
    margin-top: 2.2rem;
}

.project-card {
    min-height: 15rem;
    display: flex;
    flex-direction: column;
    padding: 1.45rem;
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 6px 20px rgb(20 36 48 / 4%);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.project-card:hover {
    transform: translateY(-3px);
    border-color: #a8d9e5;
    box-shadow: var(--shadow);
}

.project-card h2 {
    margin: 2rem 0 0.5rem;
    font-size: 1.25rem;
}

.project-card p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.project-card__meta {
    margin-top: auto;
    color: var(--muted);
    font-size: 0.8rem;
}

.project-key,
.type-flag,
.priority,
.quiet-badge,
.status-pill,
.conflict-flag {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.04em;
}

.project-key,
.type-flag {
    color: var(--cyan-dark);
}

.status-pill,
.quiet-badge {
    padding: 0.3rem 0.55rem;
    background: #eef2f4;
    color: #52616c;
}

.status-active,
.status-completed {
    color: #176c50;
    background: #e3f4ec;
}

.status-archived {
    color: #737b82;
    background: #eceff1;
}

.empty-panel,
.empty-inline {
    padding: 2rem;
    border: 1px dashed #cbd5da;
    border-radius: 1rem;
    color: var(--muted);
    text-align: center;
}

.modal {
    width: min(92vw, 42rem);
    padding: 0;
    border: 0;
    border-radius: 1.2rem;
    box-shadow: 0 2rem 7rem rgb(10 25 35 / 30%);
}

.modal::backdrop {
    background: rgb(12 27 38 / 55%);
    backdrop-filter: blur(4px);
}

.modal form {
    padding: 1.6rem;
}

.modal-heading h2,
.drawer-heading h2 {
    margin-bottom: 0;
}

.icon-button {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    background: #eef2f4;
    color: var(--muted);
    font-size: 1.4rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-grid label,
.drawer-form label,
.workspace-toolbar label {
    display: grid;
    gap: 0.4rem;
    color: #46545f;
    font-size: 0.8rem;
    font-weight: 650;
}

.span-2 {
    grid-column: 1 / -1;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

.form-message {
    min-height: 1.5rem;
    color: var(--red);
}

.workspace {
    min-height: calc(100vh - 4.5rem);
}

.workspace-tabs {
    display: flex;
    gap: 0.2rem;
    padding: 0 2rem;
    border-bottom: 1px solid var(--line);
    background: #fff;
    overflow-x: auto;
}

.tab {
    position: relative;
    padding: 1rem 0.9rem;
    white-space: nowrap;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.tab.is-active {
    color: var(--ink);
}

.tab.is-active::after {
    position: absolute;
    right: 0.75rem;
    bottom: -1px;
    left: 0.75rem;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--cyan);
    content: "";
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.workspace-toolbar {
    display: flex;
    align-items: end;
    gap: 1rem;
    min-height: 4.2rem;
    padding: 0.65rem 1.2rem;
    border-bottom: 1px solid var(--line);
    background: #f9fafb;
}

.workspace-toolbar .button {
    margin: 0 0 0 auto;
}

.mobile-view-switch {
    display: none;
}

.planning-split {
    --gantt-ratio: 52%;
    height: calc(100vh - 13.2rem);
    min-height: 34rem;
    display: grid;
    grid-template-columns: minmax(0, var(--gantt-ratio)) 7px minmax(0, 1fr);
    background: #fff;
}

.planning-pane {
    min-width: 0;
    overflow: hidden;
}

.pane-heading {
    height: 4.6rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--line);
}

.pane-heading h2,
.pane-heading p {
    margin-bottom: 0;
}

.pane-heading h2 {
    font-size: 1rem;
}

.split-handle {
    position: relative;
    z-index: 2;
    cursor: col-resize;
    background: #e3e8eb;
}

.split-handle::after {
    position: absolute;
    top: 50%;
    left: 2px;
    width: 3px;
    height: 3.5rem;
    border-radius: 4px;
    background: #a5b1b9;
    content: "";
    transform: translateY(-50%);
}

.gantt-host {
    height: calc(100% - 4.6rem);
    overflow: auto;
}

.gantt .bar-wrapper.gantt-selected .bar {
    stroke: var(--cyan-dark);
    stroke-width: 3px;
}

.gantt .bar-wrapper.gantt-conflict .bar {
    fill: #df6472;
}

.gantt .bar-wrapper.gantt-generated .bar {
    fill: #7367c9;
}

.gantt .bar-wrapper.gantt-archived,
.kanban-card.is-archived {
    opacity: 0.62;
}

.gantt .bar-wrapper.gantt-milestone .bar {
    fill: var(--orange);
}

.kanban-board {
    height: calc(100% - 4.6rem);
    display: grid;
    grid-auto-columns: minmax(14rem, 1fr);
    grid-auto-flow: column;
    gap: 0.75rem;
    padding: 0.75rem;
    overflow: auto;
    background: #f3f5f7;
}

.kanban-column {
    display: flex;
    flex-direction: column;
    min-width: 14rem;
    border: 1px solid #e0e5e8;
    border-radius: 0.9rem;
    background: #f9fafb;
}

.kanban-column__heading {
    padding: 0.8rem;
}

.kanban-column__heading h3 {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.kanban-list {
    min-height: 8rem;
    flex: 1;
    padding: 0 0.55rem 0.7rem;
}

.kanban-card {
    margin-bottom: 0.55rem;
    padding: 0.75rem;
    border: 1px solid #dde4e8;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 3px 10px rgb(20 36 48 / 4%);
    cursor: grab;
}

.kanban-card:hover,
.kanban-card.is-selected {
    border-color: #6fcce2;
    box-shadow: 0 5px 18px rgb(0 150 190 / 12%);
}

.kanban-card.has-conflict {
    border-left: 4px solid var(--red);
}

.kanban-card.is-dragging {
    opacity: 0.45;
}

.kanban-card h4 {
    margin: 0.7rem 0 0.45rem;
    font-size: 0.9rem;
}

.card-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.priority {
    padding: 0.18rem 0.35rem;
    color: #56636c;
    background: #edf1f3;
    font-size: 0.58rem;
}

.priority-high,
.priority-critical,
.conflict-flag {
    color: #9b2936;
    background: #fae5e8;
}

.type-flag,
.conflict-flag {
    padding: 0.18rem 0.35rem;
    background: #e8f6f9;
    font-size: 0.6rem;
}

.card-dates,
.card-footer,
.drawer-meta {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.72rem;
}

.card-menu {
    padding: 0;
    background: transparent;
    color: var(--cyan-dark);
    font-size: 0.72rem;
    font-weight: 700;
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.sync-indicator i {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--green);
}

.sync-indicator.is-busy i {
    background: var(--orange);
    animation: pulse 900ms infinite alternate;
}

@keyframes pulse {
    to { opacity: 0.3; }
}

.drawer {
    position: fixed;
    z-index: 40;
    top: 4.5rem;
    right: 0;
    width: min(92vw, 26rem);
    height: calc(100vh - 4.5rem);
    padding: 1.3rem;
    overflow: auto;
    border-left: 1px solid var(--line);
    background: #fff;
    box-shadow: -1rem 0 3rem rgb(20 36 48 / 14%);
}

.drawer-form,
.drawer-actions {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.drawer-actions .button,
.drawer-form .button {
    justify-content: center;
    margin-top: 0;
}

.content-panel {
    width: min(100%, 88rem);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2.5rem);
}

.section-heading {
    margin-bottom: 2rem;
}

.context-grid,
.settings-grid,
.progress-report-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
}

.settings-grid {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
}

.subsection-heading,
.inline-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.subsection-heading {
    margin-bottom: 0.8rem;
}

.stack-list,
.timeline,
.version-list {
    display: grid;
    gap: 0.75rem;
}

.list-card,
.detail-surface,
.progress-report-content,
.media-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: #fff;
}

.list-card h3,
.media-card h3 {
    margin: 0.45rem 0;
    font-size: 1rem;
}

.list-card p,
.media-card p {
    margin-bottom: 0.35rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0.75rem;
}

.media-icon {
    min-height: 6rem;
    display: grid;
    place-items: center;
    border-radius: 0.6rem;
    background: #eaf5f8;
    color: var(--cyan-dark);
    font-size: 2rem;
}

.detail-surface {
    margin-top: 1rem;
}

.variance-row {
    padding: 0.6rem 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.progress-report-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
}

.version-button {
    display: grid;
    gap: 0.25rem;
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.version-button span,
.version-button small {
    color: var(--muted);
}

.version-button.is-active {
    border-color: var(--cyan);
    background: #f0fbfd;
}

.progress-report-content {
    min-height: 24rem;
    padding: clamp(1.2rem, 3vw, 2.5rem);
}

.progress-report-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.progress-report-comparison > section + section {
    padding-left: 1.5rem;
    border-left: 1px solid var(--line);
}

.revision-card {
    display: grid;
    gap: 0.25rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
}

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

.prose {
    max-width: 52rem;
    line-height: 1.75;
}

.prose h1 {
    font-size: 2rem;
}

.prose h2 {
    margin-top: 2rem;
    font-size: 1.15rem;
}

.timeline {
    position: relative;
    padding-left: 1.5rem;
}

.timeline::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0.35rem;
    width: 1px;
    background: var(--line);
    content: "";
}

.timeline-item {
    position: relative;
    padding: 0.2rem 0 1rem;
}

.timeline-dot {
    position: absolute;
    top: 0.3rem;
    left: -1.45rem;
    width: 0.65rem;
    height: 0.65rem;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 0 1px var(--cyan);
}

.toast-region {
    position: fixed;
    z-index: 100;
    top: 1rem;
    right: 1rem;
    width: min(90vw, 24rem);
    display: grid;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    background: var(--navy);
    color: #fff;
    box-shadow: var(--shadow);
}

.toast--error {
    background: #922f3b;
}

.toast--success {
    background: #176c50;
}

.global-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 12rem auto;
    align-items: end;
    gap: 0.8rem;
    margin: 2rem 0;
}

.global-search-form .search-field input {
    width: 100%;
    padding: 1rem;
    background: #fff;
}

.global-search-form label {
    display: grid;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.global-search-form .button {
    margin: 0;
}

.search-results {
    display: grid;
    gap: 0.7rem;
}

.search-result {
    display: block;
    padding: 1rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}

.search-result:hover {
    border-color: #6fcce2;
    box-shadow: 0 6px 20px rgb(0 150 190 / 9%);
}

.search-result h2 {
    margin: 0.55rem 0 0.35rem;
    font-size: 1.05rem;
}

.search-result p {
    margin-bottom: 0.4rem;
}

.search-result small,
.search-summary {
    color: var(--muted);
}

@media (max-width: 800px) {
    .app-header {
        align-items: center;
    }

    .header-actions .search-field,
    .sync-indicator {
        display: none;
    }

    .page-heading,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-page .page-heading {
        align-items: flex-start;
    }

    .dashboard-page .page-heading > .check-field {
        margin-top: 0.5rem;
        margin-bottom: 0;
    }

    .planning-split {
        height: auto;
        display: block;
    }

    .mobile-view-switch {
        display: flex;
        gap: 0.4rem;
        width: 100%;
    }

    .planning-split.mobile-gantt .kanban-pane,
    .planning-split.mobile-kanban .gantt-pane {
        display: none;
    }

    .planning-pane {
        min-height: 32rem;
        border-bottom: 1px solid var(--line);
    }

    .split-handle {
        display: none;
    }

    .workspace-toolbar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .workspace-toolbar .search-field,
    .workspace-toolbar .search-field input {
        width: 100%;
    }

    .workspace-toolbar .button {
        margin-left: 0;
    }

    .context-grid,
    .settings-grid,
    .progress-report-layout,
    .form-grid,
    .global-search-form,
    .progress-report-comparison {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .progress-report-comparison > section + section {
        padding-top: 1rem;
        padding-left: 0;
        border-top: 1px solid var(--line);
        border-left: 0;
    }
}

@media (max-width: 560px) {
    .app-header {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .button {
        flex: 1;
        justify-content: center;
    }
}

.button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.form-message {
    min-height: 1.5rem;
    margin-bottom: 0;
    color: #a03232;
}
