/* The module's own styles. The shell links this once, from the descriptor's Stylesheets.
   Colours come from the shell's --shell-* tokens, never hard-coded, so the module follows
   light/dark and the installation's accent by construction. */

.planner-muted {
    color: var(--shell-content-secondary);
}

.planner-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.planner-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.planner-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    min-width: 160px;
}

.planner-field > span {
    font-size: 0.85em;
    color: var(--shell-content-secondary);
}

/* In a toolbar the row's own margin spaces it; the field's would lift it above the buttons
   the toolbar aligns at its bottom. */
.planner-toolbar > .planner-field { margin-bottom: 0; }

.planner-project { min-width: 260px; }
.planner-title { flex: 1 1 320px; }
.planner-code { width: 96px; min-width: 96px; }
.planner-size { width: 80px; min-width: 80px; }
.planner-grow { flex: 1 1 220px; }

.planner-section {
    margin: 0 0 4px;
    font-size: 1.05em;
}

.planner-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.planner-row-buttons {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

/* A read-only proposal's areas, as a filter of its tasks. */
.planner-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 12px;
}

.planner-filter-item {
    padding: 4px 12px;
    border: 1px solid var(--shell-border);
    border-radius: 999px;
    background: transparent;
    color: var(--shell-content-secondary);
    font: inherit;
    cursor: pointer;
}

.planner-filter-on {
    border-color: var(--shell-accent);
    background: var(--shell-accent-tint);
    color: var(--shell-accent);
    font-weight: 600;
}

.planner-task {
    border: 1px solid var(--shell-border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.planner-row-problem {
    border-color: var(--shell-warning-fg);
    box-shadow: inset 3px 0 0 var(--shell-warning-fg);
}

.planner-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.85em;
    border: 1px solid var(--shell-border);
    color: var(--shell-content-secondary);
}

.planner-status-draft { color: var(--shell-accent); border-color: var(--shell-accent); }
.planner-status-approved { color: var(--shell-success-fg); border-color: var(--shell-success-fg); }
.planner-status-discarded { opacity: 0.7; }

.planner-callout {
    margin: 8px 0 0;
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--shell-border);
    background: var(--shell-surface-muted);
}

.planner-callout-ok { border-left-color: var(--shell-success-fg); }
.planner-callout-warn { border-left-color: var(--shell-warning-fg); }
.planner-callout-error { border-left-color: var(--shell-danger); }

.planner-unsaved {
    color: var(--shell-warning-fg);
    font-size: 0.9em;
}

.planner-link {
    color: var(--shell-accent);
}

.planner-list {
    width: 100%;
    border-collapse: collapse;
}

.planner-list td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--shell-border);
}

.planner-list-title a {
    color: var(--shell-accent);
    text-decoration: none;
}

.planner-warnings {
    margin: 4px 0 0;
    padding-left: 18px;
}

/* The page's two columns (2026-10-21): the list or the open proposal, and the chat beside it;
   AI Agents Workflow uses the same layout for the map and the chat.
   The page itself never scrolls: the shell's scrolling area (.shell-page, or a tab's
   .tab-content) becomes a column the layout fills to its last pixel, and each of the two
   columns scrolls on its own - the left one its content, the chat only its messages. Measured
   by the browser, never by a calc() of the shell's bars. Wide screens only: below 75rem the
   two become tabs. */
.shell-page:has(> .planner-layout),
.tab-content:has(> .planner-layout) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* What sits above the two columns (the page's header, the map's toolbar, the tabs) keeps its
   height; the layout takes the rest. */
.shell-page:has(> .planner-layout) > :not(.planner-layout),
.tab-content:has(> .planner-layout) > :not(.planner-layout) { flex-shrink: 0; }

.planner-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28rem;
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    flex: 1 1 auto;
    min-height: 0;
}

/* The chat's Card carries the shell's span class (shell-span-12: grid-column: span 12), which
   any grid obeys, not only <CardGrid>: in this grid it made twelve implicit columns and pushed
   the chat under the list. Each column is placed explicitly instead. */
.planner-layout > .planner-main { grid-column: 1; grid-row: 1; }
.planner-layout > .planner-side.shell-card { grid-column: 2; grid-row: 1; }

.planner-layout.planner-chat-closed { grid-template-columns: minmax(0, 1fr); }
.planner-layout.planner-chat-closed > .planner-side { display: none; }

.planner-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

/* The column scrolls, so its cards keep their own height: a shell card clips its overflow,
   which lets a flex item shrink to nothing, and an open proposal's cards were squeezed into
   the screen instead of scrolling. */
.planner-main > * { flex-shrink: 0; }

.planner-side { min-height: 0; }

.planner-side > .shell-card-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.planner-side-pickers {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--shell-border);
}

.planner-side-model { width: 11rem; flex: 0 0 auto; }

.planner-side-note { margin: 12px; }
.planner-side-fill { flex: 1 1 auto; }

.planner-tabs { display: none; }
.planner-chat-toggle-on { font-weight: 600; }

@media (max-width: 75rem) {
    .planner-layout,
    .planner-layout.planner-chat-closed { grid-template-columns: minmax(0, 1fr); }

    .planner-layout.planner-narrow-main > .planner-side,
    .planner-layout.planner-narrow-chat > .planner-main { display: none; }

    .planner-layout.planner-narrow-chat > .planner-side { display: flex; }
    .planner-layout > .planner-side.shell-card { grid-column: 1; }

    .planner-chat-toggle { display: none; }

    .planner-tabs {
        display: flex;
        flex: 0 0 auto;
        margin-bottom: 12px;
        border: 1px solid var(--shell-border);
        border-radius: 8px;
        overflow: hidden;
    }

    .planner-tab {
        flex: 1;
        min-height: 44px;
        border: 0;
        background: transparent;
        color: var(--shell-content-secondary);
        font: inherit;
        cursor: pointer;
    }

    .planner-tab-on {
        background: var(--shell-accent-tint);
        color: var(--shell-accent);
        font-weight: 600;
    }
}

/* The chat (phase 1b): the messages scroll, anchored at their end (column-reverse keeps the
   newest line in view as it streams, with no script); the box to write in stays below. */
.planner-chat {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    padding: 12px;
}

.planner-chat-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.planner-chat-line {
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 92%;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.planner-chat-person {
    white-space: pre-wrap;
    align-self: flex-end;
    max-width: 85%;
    background: var(--shell-accent-tint);
    border: 1px solid var(--shell-accent);
}

.planner-chat-model {
    align-self: flex-start;
    background: var(--shell-surface-muted);
    border: 1px solid var(--shell-border);
}

.planner-chat-tool {
    align-self: flex-start;
    font-size: 0.85em;
    color: var(--shell-content-secondary);
    padding-left: 12px;
    border-left: 2px solid var(--shell-border);
}

.planner-chat-proposal {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--shell-border);
    border-radius: 8px;
}

.planner-chat-proposal > span { flex: 1; }

.planner-chat-foot {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--shell-border);
}

.planner-chat-cost { font-size: 0.8em; }

.planner-chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.planner-chat-input > :first-child { flex: 1; }

/* The planner's box (2026-10-24): the whole width, the buttons on a line under it, attach on the
   left and send on the right. */
.planner-chat-input-stacked {
    flex-direction: column;
    align-items: stretch;
}

.planner-chat-input-stacked > :first-child { flex: 0 0 auto; }

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

.planner-chat-actions .planner-chat-send { margin-left: auto; }

/* The model's Markdown (ChatMarkdown): lines, list items with their marker, code. */
.planner-md-gap { height: 0.6em; }
.planner-md-heading { font-weight: 600; margin-top: 2px; }

.planner-md-item {
    display: flex;
    gap: 6px;
}

.planner-md-marker {
    flex: 0 0 auto;
    min-width: 1em;
    color: var(--shell-content-secondary);
}

.planner-md-level-1 { padding-left: 1.2em; }
.planner-md-level-2 { padding-left: 2.4em; }
.planner-md-level-3 { padding-left: 3.6em; }

.planner-md-inline-code,
.planner-md-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.9em;
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 4px;
}

.planner-md-inline-code { padding: 0 4px; }

.planner-md-code {
    margin: 4px 0;
    padding: 8px;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Files attached to the chat (2026-10-24): thumbnails in the person's lines and above the box. */
.planner-chat-attachment {
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 85%;
}

.planner-chat-thumb {
    display: block;
    max-width: 160px;
    max-height: 120px;
    border-radius: 6px;
    border: 1px solid var(--shell-border);
    object-fit: cover;
    background: var(--shell-surface);
}

.planner-chat-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--shell-border);
    color: inherit;
    text-decoration: none;
}

.planner-chat-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planner-chat-download { font-size: 0.85em; }

.planner-chat-pending {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.planner-chat-pending .planner-chat-attachment { align-self: auto; max-width: 100%; }

.planner-chat-files-note { font-size: 0.85em; }

.planner-chat-attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--shell-content-secondary);
}

.planner-chat-attach:hover { background: var(--shell-accent-tint); color: var(--shell-accent); }

/* The paperclip and the document: drawn in the text's colour, as the shell's icons are. */
.planner-chat-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The picker itself stays out of sight: the label opens it. */
.planner-chat-attach input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.planner-chat-input.planner-chat-dropping {
    outline: 2px dashed var(--shell-accent);
    outline-offset: 4px;
    border-radius: 6px;
}
