/*
 * agent-config local GUI — layout + component styles.
 *
 * All values reference tokens from `tokens.css`. No raw colours or
 * sizes inline; theme changes live in tokens. The GUI runs in a single
 * browser tab on `127.0.0.1` so no responsive complexity beyond the
 * 768px form max-width.
 */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

a {
    color: var(--color-accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

code {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    background: var(--color-surface-alt);
    padding: 0 var(--space-1);
    border-radius: var(--radius-sm);
}

#app { min-height: 100vh; }

.ac-dryrun-banner {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: var(--space-2) var(--space-4);
    background: var(--color-warning);
    color: #ffffff;
    border-bottom: 1px solid #b45309;
    font-size: var(--font-size-sm);
    text-align: center;
}
.ac-dryrun-banner strong {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/*
 * Global top navigation (road-to-unified-setup § Phase 1).
 * Six surfaces preserved from the legacy installer GUI: Setup, Tasks,
 * Council, Memory, Explain, Workspace. The Setup tab routes into the
 * modern WizardPage so install + post-install share the same shell.
 */
.ac-topnav {
    position: sticky;
    top: 0;
    z-index: 9;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.ac-topnav__inner {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: var(--space-3) var(--layout-side-padding);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}
.ac-topnav__brand {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-right: var(--space-2);
}
.ac-topnav__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    margin: 0;
    line-height: 1.2;
}
.ac-topnav__subtitle {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}
.ac-topnav__tabs {
    display: flex;
    gap: var(--space-1);
    flex: 1;
    flex-wrap: wrap;
}
.ac-topnav__tab {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    padding: var(--space-2) var(--space-3);
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    cursor: pointer;
}
.ac-topnav__tab:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}
.ac-topnav__tab--active {
    background: var(--color-surface-alt);
    color: var(--color-accent);
    border-color: var(--color-border);
}

.ac-page {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: var(--space-8) var(--layout-side-padding);
    display: flex;
    flex-direction: column;
    gap: var(--layout-content-gap);
}

.ac-page__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-3);
}

.ac-page h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
}

.ac-banner {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
}
.ac-banner--error { border-left-color: var(--color-danger); }
.ac-banner--success { border-left-color: var(--color-success); }

.ac-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
}
.ac-section__title { font-size: var(--font-size-lg); margin: 0 0 var(--space-2); }
.ac-section__description { color: var(--color-text-muted); margin: 0 0 var(--space-4); }
.ac-section__fields { display: flex; flex-direction: column; gap: var(--space-4); }

.ac-field { display: flex; flex-direction: column; gap: var(--space-1); }
.ac-field__label { font-weight: var(--font-weight-medium); font-size: var(--font-size-sm); }
.ac-field__description { color: var(--color-text-muted); font-size: var(--font-size-xs); margin: 0; }
.ac-field__error {
    color: var(--color-danger);
    font-size: var(--font-size-xs);
    margin: 0;
    border-left: 3px solid var(--color-danger);
    padding-left: var(--space-2);
}

.ac-input, .ac-textarea {
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    width: 100%;
}
.ac-input:focus, .ac-textarea:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--color-focus-ring); }
.ac-input[aria-invalid="true"], .ac-textarea[aria-invalid="true"] { border-color: var(--color-danger); }
.ac-input[aria-invalid="true"]:focus, .ac-textarea[aria-invalid="true"]:focus {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px var(--color-danger-soft, rgba(239, 68, 68, 0.18));
}
.ac-textarea { font-family: var(--font-mono); font-size: var(--font-size-sm); resize: vertical; }

.ac-toggle { display: inline-flex; gap: var(--space-2); align-items: center; cursor: pointer; }
.ac-radio-group { display: flex; flex-direction: column; gap: var(--space-2); }
.ac-radio { display: inline-flex; gap: var(--space-2); align-items: center; cursor: pointer; }

/* Toggle / Radio have no .ac-input host for the [aria-invalid] selector,
   so target the native input via the Field-wrapper's data-invalid flag. */
.ac-field[data-invalid="true"] .ac-toggle input[type="checkbox"],
.ac-field[data-invalid="true"] .ac-radio input[type="radio"] {
    outline: 2px solid var(--color-danger);
    outline-offset: 2px;
    border-radius: 2px;
}

.ac-button {
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    transition: background var(--duration-fast) var(--easing-standard);
}
.ac-button:hover { background: var(--color-surface-alt); }
.ac-button:disabled { opacity: 0.6; cursor: not-allowed; }
.ac-button--primary { background: var(--color-accent); color: var(--color-accent-fg); border-color: var(--color-accent); }
.ac-button--primary:hover { background: var(--color-accent-hover); }
.ac-button:focus { outline: none; box-shadow: var(--shadow-focus); }

.ac-form { display: flex; flex-direction: column; gap: var(--space-5); }
.ac-form__actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

.ac-modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: var(--z-modal);
}
.ac-modal__panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    max-width: 32rem; width: 90vw;
    max-height: 80vh; overflow: auto;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; gap: var(--space-4);
}
.ac-modal__actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

.ac-diff { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.ac-diff li {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    align-items: center;
}
.ac-diff__before { color: var(--color-text-muted); text-decoration: line-through; }
.ac-diff__arrow { color: var(--color-text-subtle); }
.ac-diff__after { color: var(--color-success); font-weight: var(--font-weight-medium); }

.ac-page__progress { color: var(--color-text-muted); margin: 0; }

.ac-wizard__header { display: flex; flex-direction: column; gap: var(--space-3); align-items: stretch; }
.ac-wizard__header-text { display: flex; flex-direction: column; gap: var(--space-1); }
.ac-wizard__subtitle { color: var(--color-text-muted); margin: 0; }
.ac-wizard__step-count { color: var(--color-text-muted); font-size: var(--font-size-sm); margin: 0; }

.ac-wizard__progress { display: flex; gap: var(--space-1); }
.ac-wizard__progress-segment {
    flex: 1;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--easing-standard);
}
.ac-wizard__progress-segment--filled { background: var(--color-accent); }

.ac-wizard__step { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-6); }
.ac-wizard__nav { justify-content: space-between; }
.ac-wizard__nav .ac-button:first-child { margin-right: auto; }
.ac-wizard__skip { color: var(--color-text-muted); }
.ac-wizard__hint { margin: var(--space-3) 0 0; color: var(--color-warning, #b45309); font-size: 0.875rem; }
.ac-wizard__review { display: flex; flex-direction: column; gap: var(--space-4); }

/* AI-tools step (Step 1) — rows with an installed/not-installed badge. */
.ac-wizard__tool-list { list-style: none; padding-left: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.ac-wizard__tool-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.ac-wizard__tool-label { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.ac-badge { font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); padding: 0.1rem var(--space-2); border-radius: var(--radius-sm); white-space: nowrap; }
.ac-badge--installed { background: var(--color-success-soft); color: var(--color-success); }
.ac-badge--missing { background: var(--color-surface-alt); color: var(--color-text-muted); }
.ac-badge--ws { font-size: 0.6875rem; padding: 0.05rem 0.4rem; background: var(--color-surface-alt); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.ac-badge--ws-active { background: var(--color-accent); color: var(--color-accent-fg); border-color: var(--color-accent); }

/* Capability-packs step (Step 2) — one tile per pack; languages expand to frameworks. */
.ac-wizard__pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.ac-pack-tile { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.ac-pack-tile__head { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; font-weight: var(--font-weight-medium); }
.ac-pack-tile__title { flex: 1; }
.ac-pack-tile__role { margin: 0; font-size: var(--font-size-xs); color: var(--color-text); }
.ac-pack-tile__role code { font-size: var(--font-size-xs); }
.ac-pack-tile__desc { margin: 0; color: var(--color-text-muted); font-size: var(--font-size-xs); }
.ac-pack-tile__ws { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.ac-pack-tile__children { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; padding: var(--space-2) 0 0 var(--space-4); border: 0; border-top: 1px solid var(--color-border); }
.ac-pack-tile__children:disabled { opacity: 0.5; }
.ac-pack-tile__child { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-sm); cursor: pointer; }

/* Module-roots step (Step 3) — styled, stacked input fields. */
.ac-wizard__module-fields { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-4); }

/* rtk row (Editor-and-tooling step) — detection-driven, with install hint. */
.ac-rtk-row { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); margin-bottom: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.ac-rtk-row__head { display: flex; align-items: center; gap: var(--space-2); }
.ac-rtk-row__label { font-weight: var(--font-weight-medium); }
.ac-rtk-row__install { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.ac-rtk-row__cmd { display: block; width: 100%; padding: var(--space-2) var(--space-3); background: var(--color-surface-alt); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--font-size-xs); user-select: all; }

/* AI Council step (Phase 8). */
.ac-council { display: flex; flex-direction: column; gap: var(--space-4); }
.ac-council__master { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--font-weight-medium); }
.ac-council__section { display: flex; flex-direction: column; gap: var(--space-4); border: 0; padding: 0; margin: 0; }
.ac-council__section:disabled { opacity: 0.55; }
.ac-council__h { margin: var(--space-2) 0 0; font-size: var(--font-size-sm); color: var(--color-text-muted); }

.ac-wizard__review-nav { display: flex; flex-direction: column; gap: var(--space-2); }
.ac-wizard__review-nav-label { color: var(--color-text-muted); font-size: var(--font-size-sm); margin: 0; }
.ac-wizard__review-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.ac-wizard__review-nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-success);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    transition: background var(--duration-fast) var(--easing-standard),
                border-color var(--duration-fast) var(--easing-standard);
}
.ac-wizard__review-nav-button:hover { background: var(--color-surface); border-color: var(--color-accent); border-left-color: var(--color-success); }
.ac-wizard__review-nav-button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.ac-wizard__review-nav-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background: var(--color-border);
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}
.ac-wizard__review-nav-text { flex: 1; }
.ac-wizard__review-nav-status {
    margin-left: auto;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.ac-wizard__review-nav-status--changed {
    background: var(--color-success-soft, rgba(34, 197, 94, 0.12));
    color: var(--color-success);
}
.ac-wizard__review-nav-status--error {
    background: var(--color-danger-soft, rgba(239, 68, 68, 0.12));
    color: var(--color-danger);
}
.ac-wizard__review-nav-button--error {
    border-left-color: var(--color-danger);
}
.ac-wizard__review-nav-button--error:hover { border-color: var(--color-accent); border-left-color: var(--color-danger); }


.ac-user-md-form { display: flex; flex-direction: column; gap: var(--space-5); }

.ac-chip-list {
    list-style: none;
    margin: 0 0 var(--space-2);
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.ac-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: var(--font-size-sm);
}
.ac-chip__remove {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 var(--space-1);
}
.ac-chip__remove:hover:not(:disabled) { color: var(--color-text); }
.ac-chip__remove:disabled { opacity: 0.4; cursor: not-allowed; }

.ac-role-add { display: flex; gap: var(--space-2); align-items: center; }
.ac-role-add .ac-input { flex: 1; }

/* Workspace surface — daily-workspace tab (ADR-025).
 * Three-column grid: roles · main (tasks + sessions) · right rail
 * (knowledge / docs / explain-toggle). Responsive collapse to single
 * column below 900 px so the narrow Workspace tab on small screens
 * stacks without horizontal scroll.
 */
.ac-workspace__grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr) minmax(260px, 1fr);
    gap: var(--space-4);
    margin-top: var(--space-4);
}
@media (max-width: 900px) {
    .ac-workspace__grid { grid-template-columns: 1fr; }
}

.ac-workspace__heading {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    margin: 0 0 var(--space-2) 0;
    color: var(--color-text);
}
.ac-workspace__empty {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.ac-workspace__role-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.ac-workspace__role {
    text-align: left;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-1);
    color: inherit;
    font: inherit;
}
.ac-workspace__role:hover { border-color: var(--color-border-strong); }
.ac-workspace__role--active {
    border-color: var(--color-primary, var(--color-text));
    background: var(--color-surface-alt);
}
.ac-workspace__role:focus-visible {
    outline: 2px solid var(--color-primary, var(--color-text));
    outline-offset: 2px;
}
.ac-workspace__role-name {
    font-weight: var(--font-weight-medium);
}
.ac-workspace__role-status {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ac-workspace__role-status[data-status="stable"] { color: var(--color-success, #15803d); }
.ac-workspace__role-status[data-status="beta"]   { color: var(--color-warn, #b45309); }
.ac-workspace__role-status[data-status="draft"]  { color: var(--color-text-muted); }
.ac-workspace__role-tagline {
    grid-column: 1 / -1;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.ac-workspace__main {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ac-workspace__task-list,
.ac-workspace__session-list,
.ac-workspace__doc-list,
.ac-workspace__skill-list,
.ac-workspace__citation-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.ac-workspace__task {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    background: var(--color-surface);
}
.ac-workspace__task-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
}
.ac-workspace__task-name { font-weight: var(--font-weight-medium); }
.ac-workspace__task-intent {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: var(--space-1) 0 0 0;
}
.ac-workspace__task-prompt {
    display: inline-block;
    margin-top: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.ac-workspace__session {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(80px, 1fr) 2fr;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.ac-workspace__session-id { font-family: var(--font-mono, monospace); color: var(--color-text-muted); }

.ac-workspace__rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ac-workspace__citation {
    border-left: 3px solid var(--color-border);
    padding: var(--space-1) var(--space-2);
}
.ac-workspace__citation-marker {
    font-weight: var(--font-weight-medium);
    margin-right: var(--space-1);
}
.ac-workspace__citation-source {
    text-decoration: none;
    color: var(--color-text);
    border-bottom: 1px dotted var(--color-border-strong);
}
.ac-workspace__citation-source:hover { color: var(--color-primary, var(--color-text)); }
.ac-workspace__citation-pin {
    margin-left: var(--space-1);
    color: var(--color-warn, #b45309);
}
.ac-workspace__citation-excerpt {
    margin: var(--space-1) 0 0 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.ac-workspace__doc {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-2);
    align-items: center;
    font-size: var(--font-size-sm);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}
.ac-workspace__doc-type {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-1);
}
.ac-workspace__doc-time {
    font-family: var(--font-mono, monospace);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.ac-workspace__explain {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
}
.ac-workspace__explain legend {
    padding: 0 var(--space-1);
}
.ac-workspace__explain-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    padding: var(--space-1) 0;
}
.ac-workspace__explain-hint {
    margin: var(--space-2) 0 0 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}
