/* ==========================================================================
   Legacy Modernization Assistant (LMA) — brand theme
   Blue + white with a gold accent. Adjust tokens in one place here.
   ========================================================================== */
:root {
    /* Brand palette: blue + white with a gold accent. */
    --brand-primary: #1C6EA4;
    --brand-primary-dark: #14547E;
    --brand-accent: #FDB81E;
    --brand-link: #1C6EA4;
    --surface: #FFFFFF;
    --surface-alt: #F1F5F8;
    --border: #D5DDE4;
    --text: #1B1B1B;
    --text-muted: #5A6470;

    --font-sans: "Public Sans", "Source Sans Pro", -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--surface-alt);
}

#app { height: 100%; }

a, .link { color: var(--brand-link); }

h1:focus { outline: none; }

/* --- Loading splash ------------------------------------------------------- */
.app-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100vh; gap: 1rem; color: var(--text-muted);
}
.app-loading-bar {
    width: 180px; height: 4px; border-radius: 2px; overflow: hidden; background: var(--border);
    position: relative;
}
.app-loading-bar::after {
    content: ""; position: absolute; left: -40%; top: 0; height: 100%; width: 40%;
    background: var(--brand-primary); animation: cma-slide 1.1s infinite ease-in-out;
}
@keyframes cma-slide { 0% { left: -40%; } 100% { left: 100%; } }

/* --- App shell ------------------------------------------------------------ */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.app-header {
    background: var(--brand-primary);
    color: #fff;
    display: flex; align-items: center; gap: .9rem;
    padding: .7rem 1.1rem;
    box-shadow: var(--shadow);
}
.app-header .wordmark {
    font-weight: 700; font-size: 1rem; line-height: 1.1; letter-spacing: .2px;
}
.app-header .wordmark small { display: block; font-weight: 400; opacity: .85; font-size: .72rem; }
.app-header .app-title {
    margin-left: auto; font-weight: 600; font-size: 1.05rem;
    border-left: 1px solid rgba(255,255,255,.35); padding-left: .9rem;
}
.app-body { display: flex; flex: 1; min-height: 0; }

/* --- Sidebar -------------------------------------------------------------- */
.sidebar {
    width: 280px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.sidebar .new-chat {
    margin: .9rem; padding: .55rem .8rem; border: none; border-radius: var(--radius);
    background: var(--brand-primary); color: #fff; font-weight: 600; cursor: pointer; font-size: .9rem;
}
.sidebar .new-chat:hover { background: var(--brand-primary-dark); }
/* Drop zone / file picker in the sidebar */
.dropzone {
    position: relative; margin: 0 .9rem .6rem; border: 1.5px dashed var(--border); border-radius: var(--radius);
    background: var(--surface-alt); min-height: 74px; display: grid; place-items: center; text-align: center;
    color: var(--text-muted); transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--brand-primary); background: #e8f1f8; }
.dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-label { display: flex; align-items: center; gap: .5rem; font-size: .8rem; padding: .5rem; pointer-events: none; }
.dropzone-icon {
    width: 26px; height: 26px; border-radius: 50%; background: var(--brand-primary); color: #fff;
    display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.dropzone-label small { color: var(--text-muted); }

.sidebar-error {
    margin: 0 .9rem .5rem; padding: .45rem .6rem; font-size: .78rem;
    background: #fdecea; border: 1px solid #f5c6cb; color: #8a1c14; border-radius: 6px;
}

.user-text { white-space: pre-wrap; }

.sidebar .files-heading {
    padding: .3rem 1rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); font-weight: 700;
}
.sidebar .file-list { list-style: none; margin: 0; padding: 0 .6rem; overflow-y: auto; flex: 1; }
.file-item {
    display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem; border-radius: var(--radius);
    margin-bottom: .25rem;
}
.file-item:hover { background: var(--surface-alt); }
.file-item .file-meta { min-width: 0; flex: 1; }
.file-item .file-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .file-sub { font-size: .7rem; color: var(--text-muted); }
.file-item .remove {
    border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 1rem; line-height: 1;
}
.file-item .remove:hover { color: #b3261e; }
.sidebar .empty-files { padding: .6rem 1rem; color: var(--text-muted); font-size: .8rem; }

.kind-badge {
    display: inline-block; font-size: .62rem; font-weight: 700; text-transform: uppercase;
    padding: .1rem .35rem; border-radius: 4px; margin-bottom: .15rem;
    background: var(--surface-alt); color: var(--brand-primary-dark); border: 1px solid var(--border);
}
.kind-CobolProgram { color: #14547E; }
.kind-Copybook { color: #1B6CB3; }
.kind-Jcl { color: #8a5a00; }
.kind-Unknown { color: var(--text-muted); }

/* --- Main / transcript ---------------------------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.transcript { flex: 1; overflow-y: auto; padding: 1.4rem clamp(1rem, 6vw, 4rem); }

.empty-state {
    height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; color: var(--text-muted); gap: .6rem;
}
.empty-state h2 { color: var(--text); margin: 0; }
.empty-state .hint { max-width: 460px; font-size: .92rem; }

.msg { display: flex; margin-bottom: 1.1rem; }
.msg.user { justify-content: flex-end; }
.bubble {
    max-width: min(760px, 88%); padding: .75rem 1rem; border-radius: 12px; box-shadow: var(--shadow);
    font-size: .93rem; line-height: 1.55;
}
.msg.user .bubble { background: var(--brand-primary); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg .role-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .25rem; }

/* Markdown content inside assistant bubbles */
.bubble :first-child { margin-top: 0; }
.bubble :last-child { margin-bottom: 0; }
.bubble p { margin: .5rem 0; }
.bubble pre {
    background: #f6f8fa; border: 1px solid var(--border); border-radius: var(--radius);
    padding: .8rem .9rem; overflow-x: auto; margin: .6rem 0;
}
.bubble code { font-family: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace; font-size: .85rem; }
.bubble p code, .bubble li code { background: var(--surface-alt); padding: .1rem .3rem; border-radius: 4px; }
/* Tables can be wider than the bubble — let them scroll horizontally instead of overflowing the page. */
.bubble table {
    border-collapse: collapse; margin: .6rem 0; font-size: .85rem;
    display: block; max-width: 100%; overflow-x: auto;
}
.bubble th, .bubble td { border: 1px solid var(--border); padding: .3rem .5rem; vertical-align: top; }
.bubble th { text-align: left; background: var(--surface-alt); }

.cma-copy-btn {
    position: absolute; top: .4rem; right: .4rem; font-size: .68rem; padding: .15rem .5rem;
    border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--text-muted);
    cursor: pointer;
}
.cma-copy-btn:hover { color: var(--brand-primary); border-color: var(--brand-primary); }

.typing { display: inline-flex; gap: 4px; padding: .3rem 0; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); opacity: .5;
    animation: cma-blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cma-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

.working { display: flex; align-items: center; gap: .55rem; margin-top: .45rem; color: var(--text-muted); }
.working-label { font-size: .8rem; }

.error-banner {
    background: #fdecea; border: 1px solid #f5c6cb; color: #8a1c14; padding: .6rem .9rem;
    border-radius: var(--radius); margin: 0 clamp(1rem, 6vw, 4rem) .6rem; font-size: .88rem;
}

/* --- Interactive question card (Claude-desktop style) --------------------- */
.ask-card {
    margin-top: .8rem; border: 1px solid var(--border); border-radius: 10px; padding: .9rem;
    background: var(--surface-alt);
}
.ask-question { margin-bottom: .6rem; }
.ask-question:last-of-type { margin-bottom: .6rem; }

/* Wizard navigation */
.ask-nav { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.ask-arrow {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
    color: var(--brand-primary-dark); font-size: 1.1rem; line-height: 1; cursor: pointer; flex-shrink: 0;
    display: grid; place-items: center;
}
.ask-arrow:hover:not(:disabled) { border-color: var(--brand-primary); color: var(--brand-primary); }
.ask-arrow:disabled { opacity: .35; cursor: default; }
.ask-dots { display: flex; align-items: center; gap: .35rem; flex: 1; }
.ask-dot {
    width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
    padding: 0; cursor: pointer;
}
.ask-dot.done { background: #b8d4e6; border-color: #b8d4e6; }
.ask-dot.active { background: var(--brand-primary); border-color: var(--brand-primary); transform: scale(1.25); }
.ask-count { font-size: .72rem; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.ask-header {
    display: inline-block; font-size: .66rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--brand-primary-dark); background: #e3eef6;
    border-radius: 5px; padding: .1rem .4rem; margin-bottom: .35rem;
}
.ask-prompt { font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.ask-options { display: flex; flex-direction: column; gap: .4rem; }
.ask-option {
    display: flex; align-items: flex-start; gap: .55rem; text-align: left; width: 100%;
    border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
    padding: .55rem .7rem; cursor: pointer; transition: border-color .12s, background .12s;
}
.ask-option:hover { border-color: var(--brand-primary); }
.ask-option.selected { border-color: var(--brand-primary); background: #e8f1f8; box-shadow: 0 0 0 1px var(--brand-primary) inset; }
.ask-option-check { color: var(--brand-primary); font-size: .95rem; line-height: 1.35; }
.ask-option-body { display: flex; flex-direction: column; min-width: 0; }
.ask-option-label { font-size: .86rem; font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.ask-option-desc { font-size: .76rem; color: var(--text-muted); margin-top: .1rem; }
.ask-rec {
    font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: #7a5300; background: var(--brand-accent); border-radius: 4px; padding: .05rem .3rem;
}
.ask-other-input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem;
    font-family: var(--font-sans); font-size: .85rem; margin-top: .1rem;
}
.ask-other-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,110,164,.18); }
.ask-actions { display: flex; justify-content: flex-end; margin-top: .6rem; }
.ask-submit {
    border: none; background: var(--brand-primary); color: #fff; font-weight: 600; font-size: .85rem;
    border-radius: 8px; padding: .5rem .9rem; cursor: pointer;
}
.ask-submit:hover { background: var(--brand-primary-dark); }

/* --- Document-actions card ------------------------------------------------- */
.doc-card {
    margin-top: .8rem; border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem;
    background: var(--surface-alt);
}
.doc-card-title { font-weight: 600; font-size: .88rem; }
.doc-card-sub { font-size: .76rem; color: var(--text-muted); margin-top: .1rem; margin-bottom: .6rem; }
.doc-card-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.doc-btn {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-family: var(--font-sans); font-weight: 600; font-size: .82rem; border-radius: 8px;
    padding: .45rem .8rem; cursor: pointer; transition: border-color .12s, background .12s, color .12s;
}
.doc-btn:hover:not(:disabled) { border-color: var(--brand-primary); color: var(--brand-primary); }
.doc-btn:disabled { opacity: .45; cursor: default; }
.doc-btn.primary { border-color: var(--brand-primary); background: #e8f1f8; color: var(--brand-primary-dark); }
.doc-btn.primary:hover:not(:disabled) { background: var(--brand-primary); color: #fff; }
.doc-btn.ghost { color: var(--text-muted); }
.doc-btn.active { border-color: var(--brand-primary); background: #e8f1f8; color: var(--brand-primary-dark); }
.doc-refine { margin-top: .6rem; }
.doc-refine-input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem;
    font-family: var(--font-sans); font-size: .85rem; resize: vertical;
}
.doc-refine-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,110,164,.18); }
.doc-refine-actions { display: flex; justify-content: flex-end; gap: .4rem; margin-top: .4rem; }

/* --- Composer ------------------------------------------------------------- */
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: .8rem clamp(1rem, 6vw, 4rem); position: relative; }

/* "/" command menu (composer autocomplete) */
.slash-menu {
    position: absolute; left: clamp(1rem, 6vw, 4rem); right: clamp(1rem, 6vw, 4rem);
    bottom: calc(100% - .4rem); background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 -4px 16px rgba(0,0,0,.14); overflow: hidden; z-index: 30;
}
.slash-menu-hint {
    font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
    padding: .45rem .75rem .2rem;
}
.slash-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; width: 100%;
    text-align: left; border: none; background: transparent; padding: .45rem .75rem; cursor: pointer;
}
.slash-item:hover, .slash-item.active { background: var(--surface-alt); }
.slash-name {
    font-weight: 700; font-size: .85rem; color: var(--brand-primary-dark);
    font-family: "Cascadia Code", Consolas, monospace;
}
.slash-summary { font-size: .76rem; color: var(--text-muted); }
.composer.dragover { outline: 2px dashed var(--brand-primary); outline-offset: -8px; background: #e8f1f8; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; background: var(--surface-alt);
    border: 1px solid var(--border); border-radius: 999px; padding: .2rem .6rem;
}
.chip button { border: none; background: transparent; cursor: pointer; color: var(--text-muted); font-size: .85rem; line-height: 1; }

.composer-row { display: flex; gap: .6rem; align-items: flex-end; }
.composer textarea {
    flex: 1; resize: none; border: 1px solid var(--border); border-radius: var(--radius);
    padding: .6rem .7rem; font-family: var(--font-sans); font-size: .92rem; line-height: 1.4; min-height: 44px; max-height: 200px;
}
.composer textarea:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,110,164,.18); }

.icon-btn, .send-btn {
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
    padding: .55rem .8rem; cursor: pointer; font-size: .9rem; color: var(--text);
}
.icon-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.send-btn { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); font-weight: 600; }
.send-btn:hover:not(:disabled) { background: var(--brand-primary-dark); }
.send-btn:disabled, .icon-btn:disabled { opacity: .5; cursor: not-allowed; }

.composer-controls { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; font-size: .8rem; color: var(--text-muted); }
.composer-controls select { font-family: var(--font-sans); font-size: .8rem; padding: .2rem .4rem; border-radius: 6px; border: 1px solid var(--border); }
.composer-controls .spacer { flex: 1; }
.msg-model { margin-top: .4rem; font-size: .72rem; color: var(--text-muted); }

/* --- Artifacts: toggle, drawer, cards, preview ---------------------------- */
.artifacts-toggle {
    border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
    padding: .25rem .6rem; cursor: pointer; font-size: .8rem; color: var(--text);
}
.artifacts-toggle:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.artifact-drawer {
    width: 340px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.artifact-drawer-head {
    display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem;
    border-bottom: 1px solid var(--border); font-weight: 700; color: var(--brand-primary-dark);
}
.drawer-close { border: none; background: transparent; cursor: pointer; font-size: 1rem; color: var(--text-muted); }
.drawer-close:hover { color: #b3261e; }
.artifact-empty { padding: 1rem; color: var(--text-muted); font-size: .85rem; line-height: 1.5; }

.artifact-list { list-style: none; margin: 0; padding: .6rem; overflow-y: auto; }
.artifact-card {
    display: flex; align-items: center; gap: .6rem; padding: .55rem; border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: .5rem; background: var(--surface);
}
.artifact-icon { font-size: 1.4rem; flex-shrink: 0; }
.artifact-info { flex: 1; min-width: 0; }
.artifact-name { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artifact-sub { font-size: .7rem; color: var(--text-muted); }
.artifact-actions { display: flex; flex-direction: column; gap: .3rem; }
.mini-btn {
    border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: .2rem .5rem;
    font-size: .72rem; cursor: pointer; color: var(--brand-primary-dark);
}
.mini-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.preview-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1200;
    display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.preview-modal {
    background: var(--surface); border-radius: 10px; width: min(920px, 94vw); height: min(80vh, 900px);
    display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.preview-head {
    display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem;
    border-bottom: 1px solid var(--border); background: var(--surface-alt);
}
.preview-title { font-weight: 700; font-size: .95rem; }
.preview-head-actions { display: flex; align-items: center; gap: .6rem; }
.preview-body { flex: 1; min-height: 0; overflow: auto; background: #fafbfb; }
.preview-frame { width: 100%; height: 100%; border: 0; }
.preview-image { max-width: 100%; display: block; margin: 1rem auto; }
.preview-markdown { margin: 1rem; box-shadow: none; border: none; max-width: none; }
.preview-text { margin: 0; padding: 1rem; font-size: .82rem; white-space: pre; }
.preview-none { padding: 2rem; text-align: center; color: var(--text-muted); }

/* --- Footer --------------------------------------------------------------- */
.app-footer {
    background: var(--brand-primary-dark); color: #dfeee7; font-size: .72rem; text-align: center; padding: .45rem;
}

#blazor-error-ui {
    background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none;
    left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* --- Landing (New / Open Project) ----------------------------------------- */
.landing { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.landing-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow); padding: 2.2rem 2.4rem; width: min(620px, 100%); text-align: center;
}
.landing-card h1 { color: var(--brand-primary-dark); margin: 0 0 .4rem; font-size: 1.6rem; }
.landing-sub { color: var(--text-muted); margin: 0 auto 1.6rem; max-width: 460px; font-size: .95rem; line-height: 1.5; }
.landing-actions { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.landing-btn {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 10px; padding: .7rem 1.3rem; font-size: .95rem; font-weight: 600; cursor: pointer;
    transition: border-color .12s, background .12s;
}
.landing-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.landing-btn.primary { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.landing-btn.primary:hover { background: var(--brand-primary-dark); color: #fff; }

/* --- Mock login screen ------------------------------------------------------ */
.login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem; background: var(--surface-alt);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow); padding: 2.6rem 2.4rem; width: min(440px, 100%); text-align: center;
}
.login-wordmark {
    display: inline-flex; align-items: baseline; gap: .5rem; font-weight: 800; font-size: 1.5rem;
    color: var(--brand-primary); letter-spacing: .5px; margin-bottom: 1.3rem;
}
.login-wordmark small { font-size: .7rem; font-weight: 600; color: var(--text-muted); letter-spacing: .3px; }
.login-card h1 { color: var(--brand-primary-dark); margin: 0 0 .4rem; font-size: 1.35rem; }
.login-sub { color: var(--text-muted); margin: 0 auto 1.8rem; max-width: 340px; font-size: .92rem; line-height: 1.5; }
.login-sso-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .6rem; width: 100%;
    background: var(--brand-primary); border: 1px solid var(--brand-primary); color: #fff;
    border-radius: 10px; padding: .8rem 1.3rem; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.login-sso-btn:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); }
.login-sso-icon { flex-shrink: 0; }
.login-password-form { display: flex; flex-direction: column; gap: .7rem; }
.login-password {
    width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px;
    padding: .75rem .9rem; font-size: 1rem; background: var(--surface); color: inherit;
}
.login-password:focus { outline: 2px solid var(--brand-primary); outline-offset: 1px; }
.login-note { color: var(--text-muted); font-size: .78rem; margin: 1rem 0 0; }
.login-error { background: #fdecec; color: #a1272c; border: 1px solid #f3c0c2; border-radius: 8px; padding: .55rem .7rem; font-size: .82rem; margin: 0 0 1rem; }

.project-list { margin-top: 1.6rem; border-top: 1px solid var(--border); padding-top: 1rem; text-align: left; }
.project-empty { color: var(--text-muted); font-size: .88rem; text-align: center; padding: .8rem; }
.project-row {
    display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
    border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
    padding: .7rem .9rem; margin-bottom: .5rem; cursor: pointer; transition: border-color .12s, background .12s;
}
.project-row:hover { border-color: var(--brand-primary); background: var(--surface-alt); }
.project-row-main { flex: 1; min-width: 0; }
.project-row-name { font-weight: 700; font-size: .95rem; color: var(--brand-primary-dark); }
.project-row-sub { font-size: .74rem; color: var(--text-muted); margin-top: .1rem; }
.project-row-phases { font-size: .95rem; letter-spacing: .1em; flex-shrink: 0; }

/* --- Workspace panel ------------------------------------------------------- */
.workspace-name {
    padding: 0 1rem .5rem; font-weight: 700; font-size: .95rem; color: var(--brand-primary-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reset-workspace {
    margin: 0 .9rem .6rem; padding: .45rem .7rem; border: 1px solid #f0c2c0; border-radius: var(--radius);
    background: #fdf3f2; color: #a3241c; font-weight: 600; font-size: .82rem; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.reset-workspace:hover:not(:disabled) { background: #fbe6e4; border-color: #e39c98; }
.reset-workspace:disabled { opacity: .5; cursor: not-allowed; }

/* --- Phase accordion ------------------------------------------------------- */
.phase-accordion { padding: 0 .6rem; overflow-y: auto; flex: 1; }
.phase-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; overflow: hidden; background: var(--surface); }
.phase-item.open { border-color: var(--brand-primary); box-shadow: 0 0 0 1px rgba(28,110,164,.12); }
.phase-head { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; cursor: pointer; }
.phase-head:hover { background: var(--surface-alt); }
.phase-title { flex: 1; font-weight: 600; font-size: .86rem; }
.phase-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; border: 2px solid var(--border); background: var(--surface); }
.phase-dot.notstarted { border-color: var(--border); background: var(--surface); }
.phase-dot.inprogress { border-color: var(--brand-accent); background: var(--brand-accent); animation: cma-blink 1.2s infinite both; }
.phase-dot.done { border-color: var(--brand-primary); background: var(--brand-primary); }
.phase-exec {
    border: 1px solid var(--brand-primary); background: var(--brand-primary); color: #fff; border-radius: 6px;
    padding: .28rem .7rem; font-size: .78rem; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.phase-exec:hover:not(:disabled) { background: var(--brand-primary-dark); }
.phase-exec:disabled { opacity: .45; cursor: not-allowed; background: var(--text-muted); border-color: var(--text-muted); }
.phase-body { padding: .3rem .8rem .8rem; border-top: 1px solid var(--border); }
.phase-desc { font-size: .8rem; color: var(--text-muted); line-height: 1.45; margin: .5rem 0 0; }

.config-form { display: flex; flex-direction: column; gap: .5rem; padding-top: .5rem; }
.config-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.config-input {
    border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .6rem;
    font-family: var(--font-sans); font-size: .86rem;
}
.config-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,110,164,.18); }
.config-input:disabled { background: var(--surface-alt); color: var(--text-muted); }
.config-form .dropzone { margin: 0; }
.config-form .new-chat { margin: 0; }
.config-count { font-size: .78rem; color: var(--brand-primary-dark); font-weight: 600; }
.config-hint { font-size: .74rem; color: var(--text-muted); line-height: 1.4; margin: .35rem 0 .1rem; }
.config-or { text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 1rem 0 .5rem; }
.s3-status {
    display: flex; align-items: center; gap: .5rem; margin: .6rem 0 0; font-size: .8rem; color: var(--text-muted);
}
.s3-spinner {
    width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--brand-primary);
    animation: cma-spin .7s linear infinite;
}
@keyframes cma-spin { to { transform: rotate(360deg); } }
.s3-success {
    display: flex; align-items: center; gap: .55rem; margin: .6rem 0 0; padding: .6rem .7rem;
    background: #e7f6ec; border: 1px solid #a6d9b8; color: #14683a; border-radius: 6px;
    font-size: .82rem; line-height: 1.4;
}
.s3-success strong { font-weight: 700; }
.s3-success-check {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 20px; height: 20px; border-radius: 50%; background: #1e9e5a; color: #fff;
    font-size: .72rem; font-weight: 700;
}
.config-files { list-style: none; margin: .3rem 0 0; padding: 0; max-height: 160px; overflow-y: auto; }
.config-files li { font-size: .78rem; padding: .15rem 0; display: flex; align-items: center; gap: .4rem; }

/* --- Reset confirmation dialog -------------------------------------------- */
.confirm-modal {
    background: var(--surface); border-radius: 12px; width: min(460px, 92vw); padding: 1.4rem 1.6rem;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.confirm-modal h3 { margin: 0 0 .6rem; color: #a3241c; font-size: 1.15rem; }
.confirm-modal p { margin: 0 0 1.2rem; font-size: .9rem; line-height: 1.55; color: var(--text); }
.confirm-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.confirm-actions .mini-btn { padding: .5rem 1rem; font-size: .84rem; }
.danger-btn {
    border: 1px solid #a3241c; background: #a3241c; color: #fff; border-radius: 8px;
    padding: .5rem 1rem; font-size: .84rem; font-weight: 600; cursor: pointer;
}
.danger-btn:hover { background: #86190f; }

/* --- Mermaid diagrams ------------------------------------------------------ */
.mermaid-svg { margin: .8rem 0; text-align: center; overflow-x: auto; }
.mermaid-svg svg { max-width: 100%; height: auto; }

/* Placeholder shown in the streaming bubble while a diagram's fence is still open. */
.mermaid-pending {
    margin: .8rem 0; padding: .6rem .75rem; border: 1px dashed #c9d3e0; border-radius: 8px;
    color: #6b7a90; font-size: .82rem; text-align: center;
}

/* A diagram whose (model-generated) source failed to parse — clean fallback, no error graphic. */
.mermaid-failed {
    margin: .8rem 0; border: 1px solid #f2d999; background: #fff8e6; border-radius: 8px;
    padding: .6rem .75rem; font-size: .82rem;
}
.mermaid-failed-note { color: #7a5300; font-weight: 600; }
.mermaid-failed details { margin-top: .4rem; }
.mermaid-failed summary { cursor: pointer; color: var(--brand-primary-dark); font-size: .78rem; }
.mermaid-failed pre {
    margin: .4rem 0 0; background: #fbf3dc; border: 1px solid #f0e2b8; border-radius: 6px;
    padding: .5rem .6rem; overflow-x: auto; font-size: .78rem; white-space: pre-wrap; word-break: break-word;
}

/* --- Partial (stale) phase status ----------------------------------------- */
.phase-dot.partial { border-color: var(--brand-accent); background: repeating-linear-gradient(45deg, var(--brand-accent), var(--brand-accent) 2px, #fff 2px, #fff 4px); }

.config-filehead { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: .3rem; }
.config-fname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-del { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: .85rem; line-height: 1; padding: 0 .2rem; flex-shrink: 0; }
.file-del:hover:not(:disabled) { color: #b3261e; }
.file-del:disabled { opacity: .3; cursor: not-allowed; }
.config-warn {
    margin-top: .5rem; padding: .45rem .6rem; font-size: .76rem; line-height: 1.4;
    background: #fff8e6; border: 1px solid #f2d999; color: #7a5300; border-radius: 6px;
}
.config-warn em { font-style: normal; font-weight: 700; }

/* --- Settings (gear + dialog) --------------------------------------------- */
.settings-gear {
    margin-left: .9rem; border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.12);
    color: #fff; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 1.05rem;
    line-height: 1; display: grid; place-items: center; flex-shrink: 0;
}
.settings-gear:hover { background: rgba(255,255,255,.24); }
.settings-modal {
    background: var(--surface); border-radius: 12px; width: min(500px, 94vw); padding: 0;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    /* Responsive: never taller than the viewport — the body scrolls, head/foot stay pinned. */
    max-height: calc(100vh - 4rem); overflow-y: auto;
}
.settings-head {
    display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.2rem;
    border-bottom: 1px solid var(--border); background: var(--surface-alt);
    position: sticky; top: 0; z-index: 2;
}
.settings-head h3 { margin: 0; font-size: 1.1rem; color: var(--brand-primary-dark); }
.settings-section { padding: 1.2rem; }
.settings-label { font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
.settings-hint { font-size: .8rem; color: var(--text-muted); line-height: 1.5; margin: 0 0 .8rem; }
.settings-hint code { background: var(--surface-alt); padding: .05rem .3rem; border-radius: 4px; font-size: .78rem; }
.settings-status { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.settings-badge {
    font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: .12rem .45rem; border-radius: 5px;
}
.settings-badge.user { background: #e3f4e8; color: #1c6b3a; border: 1px solid #b6dfc3; }
.settings-badge.env { background: #e3eef6; color: var(--brand-primary-dark); border: 1px solid #b8d4e6; }
.settings-badge.none { background: #fdecea; color: #8a1c14; border: 1px solid #f5c6cb; }
.settings-mask { font-family: "Cascadia Code", Consolas, monospace; font-size: .82rem; color: var(--text-muted); }
.settings-path { word-break: break-all; white-space: normal; }
.settings-input {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem;
    font-family: "Cascadia Code", Consolas, monospace; font-size: .84rem;
}
.settings-input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(28,110,164,.18); }
.settings-model { margin-top: 1rem; }
.settings-model .settings-hint { margin: .4rem 0 0; }
.settings-model-row { display: flex; gap: .5rem; align-items: stretch; }
.settings-model-row .settings-input { flex: 1; }
.settings-model-row .ask-submit { white-space: nowrap; }
.settings-sublabel { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }
select.settings-input { font-family: inherit; cursor: pointer; }
.settings-saved { color: #1c6b3a; font-size: .8rem; font-weight: 600; margin-top: .5rem; }
.settings-actions { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; }
.settings-actions .spacer { flex: 1; }

.settings-section-top { border-top: 1px solid var(--border); padding-top: 1rem; }

/* Provider selection (radio-style option cards, reusing .ask-option) */
.provider-options { margin-bottom: .8rem; }
.provider-options .ask-option:disabled { opacity: .7; cursor: default; }
.settings-foot { display: flex; justify-content: flex-end; padding: .8rem 1.2rem; border-top: 1px solid var(--border); background: var(--surface-alt); position: sticky; bottom: 0; z-index: 2; }

/* Phase enable/disable rows with toggle switches */
.toggle-row { display: flex; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.toggle-row:first-of-type { border-top: none; }
.toggle-text { flex: 1; min-width: 0; }
.toggle-name { font-weight: 600; font-size: .9rem; color: var(--text); }
.toggle-desc { font-size: .76rem; color: var(--text-muted); margin-top: .1rem; line-height: 1.4; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: var(--border); border-radius: 24px; transition: background .15s; }
.switch .slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--brand-primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .5; cursor: default; }

@media (max-width: 720px) {
    .sidebar { width: 210px; }
    .app-header .app-title { font-size: .9rem; }
}

/* --- Design-locked banner (appears when the Design phase completes) --- */
.design-lock {
    width: 100%;
    background: var(--surface);
    border: 1px solid #dbe8df;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(20, 40, 70, .06);
    overflow: hidden;
    margin: .2rem 0 1.1rem;
}
.dl-ribbon {
    display: flex; align-items: center; gap: .8rem;
    padding: .8rem 1.1rem;
    background: linear-gradient(90deg, #eaf6ee, #f4faf6);
    border-bottom: 1px solid #dbeee1;
}
.dl-seal {
    width: 34px; height: 34px; border-radius: 50%;
    background: #1f9d55; color: #fff; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; box-shadow: 0 0 0 4px #d8f0e0;
}
.dl-heading { flex: 1 1 auto; min-width: 0; }
.dl-title { font-weight: 800; color: #14603a; font-size: .98rem; }
.dl-check { color: #1f9d55; }
.dl-sub { color: #4b7a60; font-size: .78rem; margin-top: 1px; }
.dl-actions { display: flex; gap: .5rem; flex: 0 0 auto; }
.dl-btn {
    font-weight: 700; font-size: .82rem; border-radius: 8px;
    padding: .5rem 1rem; border: 1px solid transparent; cursor: pointer;
}
.dl-btn.ghost { background: var(--surface); border-color: var(--border); color: var(--brand-primary-dark); }
.dl-btn.ghost:hover:not(:disabled) { background: var(--surface-alt); }
.dl-btn.primary { background: var(--brand-primary); color: #fff; }
.dl-btn.primary:hover:not(:disabled) { background: var(--brand-primary-dark); }
.dl-btn.primary:not(:disabled) { animation: dl-pulse 2.2s infinite; }
.dl-btn:disabled { opacity: .5; cursor: not-allowed; }
.dl-body { padding: .9rem 1.1rem 1rem; }
.dl-body-head { font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .7rem; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; }
.dl-tile { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: .65rem .7rem; background: var(--surface-alt); }
.dl-crit-sub { margin-top: 1rem; }
.dl-tile-crit { background: #fdf6e6; border-color: #f0d489; }
.dl-tile-crit .dl-k { color: #a9791a; }
.dl-k { font-size: .62rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--brand-primary); margin-bottom: .3rem; padding-right: 1rem; }
.dl-v { font-size: .82rem; font-weight: 700; color: var(--text); line-height: 1.3; padding-right: 1rem; }
.dl-lock { position: absolute; top: .55rem; right: .6rem; font-size: .7rem; opacity: .5; }
.dl-note { margin-top: .8rem; font-size: .74rem; color: var(--text-muted); }
.dl-note strong { color: var(--brand-primary-dark); }

/* Redesign "choose a path" cards */
.dl-choose { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.dl-choice {
    display: flex; align-items: flex-start; gap: .7rem; text-align: left;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-alt);
    padding: .85rem .9rem; cursor: pointer; transition: border-color .12s, background .12s;
}
.dl-choice:hover:not(:disabled) { border-color: var(--brand-primary); background: #eaf3fc; }
.dl-choice:disabled { opacity: .55; cursor: not-allowed; }
.dl-choice-ic { font-size: 1.4rem; line-height: 1; flex: 0 0 auto; }
.dl-choice-t { font-weight: 700; font-size: .9rem; color: var(--text); }
.dl-choice-d { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.35; }

/* Interactive design-criteria input */
.dl-crit {
    width: 100%; resize: vertical; min-height: 4.5rem;
    border: 1px solid var(--border); border-radius: 10px; padding: .6rem .7rem;
    font: inherit; font-size: .85rem; color: var(--text); background: var(--surface);
}
.dl-crit:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 2px rgba(28,110,164,.15); }
.dl-crit-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .6rem; }
.dl-crit-list { margin: 0 0 .6rem; padding-left: 1.35rem; font-size: .82rem; color: var(--text); }
.dl-crit-list li { margin: .18rem 0; line-height: 1.35; }

@keyframes dl-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(28, 110, 164, .45); }
    70%  { box-shadow: 0 0 0 8px rgba(28, 110, 164, 0); }
    100% { box-shadow: 0 0 0 0 rgba(28, 110, 164, 0); }
}

/* The Generate step "lights up" once Design is locked */
.phase-item.ready { border-color: var(--brand-primary); box-shadow: 0 0 0 1px rgba(28, 110, 164, .15); }
.phase-item.ready .phase-exec:not(:disabled) { animation: dl-pulse 2.2s infinite; }

/* Entry / "lock click" animation when the Design-locked banner appears */
.design-lock { animation: dl-in .4s ease both; }
@keyframes dl-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
.dl-seal { animation: dl-seal-pop .55s cubic-bezier(.2, .9, .3, 1.5) .05s both; }
@keyframes dl-seal-pop {
    0%   { transform: scale(.3) rotate(-12deg); opacity: 0; }
    55%  { transform: scale(1.18) rotate(4deg);  opacity: 1; }
    100% { transform: scale(1) rotate(0);        opacity: 1; }
}

/* Blue "generate complete" variant of the banner */
.design-lock.gen { border-color: #d6e3ef; }
.design-lock.gen .dl-ribbon { background: linear-gradient(90deg, #e9f2fb, #f4f9fe); border-bottom-color: #dbe8f4; }
.design-lock.gen .dl-seal { background: var(--brand-primary); box-shadow: 0 0 0 4px #d6e6f2; }
.design-lock.gen .dl-title { color: var(--brand-primary-dark); }
.design-lock.gen .dl-check { color: var(--brand-primary); }
.design-lock.gen .dl-sub { color: #4a6a86; }
.dl-tile { animation: dl-tile-in .45s ease both; }
.dl-tile:nth-child(1) { animation-delay: .10s; }
.dl-tile:nth-child(2) { animation-delay: .17s; }
.dl-tile:nth-child(3) { animation-delay: .24s; }
.dl-tile:nth-child(4) { animation-delay: .31s; }
@keyframes dl-tile-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .design-lock, .dl-seal, .dl-tile,
    .dl-btn.primary:not(:disabled),
    .phase-item.ready .phase-exec:not(:disabled) { animation: none; }
}

/* --- Change workbench (impact analysis & ChangeMan packaging) --- */
.chg-starters { margin-top: .6rem; display: flex; flex-direction: column; gap: .35rem; }
.chg-starters-h { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.chg-chip { text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 8px; padding: .4rem .55rem; font-size: .8rem; cursor: pointer; }
.chg-chip:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--brand-primary); }
.chg-chip:disabled { opacity: .5; cursor: not-allowed; }

.change-mode-hint { display: flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--brand-primary-dark);
    background: #eaf3fa; border: 1px solid #cfe3f2; border-radius: 8px; padding: .3rem .55rem; margin-bottom: .5rem; }

/* "No tests yet — create a DYL-280 suite?" offer on the Change screen */
.test-offer { display: flex; align-items: flex-start; gap: .8rem; margin: .5rem 0;
    border: 1px solid #cfe3f2; border-radius: 14px; background: linear-gradient(90deg, #eef6fc, #f6fafd);
    padding: .9rem 1rem; box-shadow: 0 1px 2px rgba(20,32,46,.05); }
.test-offer-icon { font-size: 1.5rem; line-height: 1.4; }
.test-offer-body { flex: 1 1 auto; min-width: 0; }
.test-offer-title { font-weight: 700; color: var(--brand-primary-dark); font-size: .95rem; }
.test-offer-sub { font-size: .82rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.45; }
.test-offer-sub code { font-family: var(--font-mono, monospace); font-size: .78rem; background: #e3eef7;
    border-radius: 4px; padding: 0 .25rem; color: var(--brand-primary-dark); }
.test-offer-actions { display: flex; flex-direction: column; gap: .4rem; flex: 0 0 auto; }

.chg-panel { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden;
    box-shadow: 0 1px 2px rgba(20,32,46,.05), 0 6px 20px rgba(20,32,46,.06); margin: .5rem 0; }
.chg-head { display: flex; gap: .7rem; align-items: center; padding: .8rem 1rem;
    background: linear-gradient(90deg, #eaf3fa, #f5f9fd); border-bottom: 1px solid #dbe8f4; }
.chg-seal { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 1.1rem;
    background: var(--brand-primary); box-shadow: 0 0 0 4px #d6e6f2; }
.chg-title { font-weight: 700; color: var(--brand-primary-dark); font-size: 1rem; }
.chg-count { display: inline-block; min-width: 1.4rem; text-align: center; margin-left: .25rem; padding: 0 .4rem;
    border-radius: 999px; background: var(--brand-primary); color: #fff; font-size: .78rem; }
.chg-sub { font-size: .78rem; color: #4a6a86; margin-top: .1rem; }
.chg-empty { padding: 1rem; font-size: .85rem; color: var(--text-muted); }

.chg-list { padding: .5rem 1rem; display: flex; flex-direction: column; gap: .6rem; max-height: 320px; overflow-y: auto; }
.chg-group-h { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
    margin-bottom: .25rem; }
.chg-row { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--surface-alt); }
.chg-el { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .82rem; font-weight: 600; color: var(--text); }
.chg-type { font-size: .72rem; color: var(--text-muted); }
.chg-reason { margin-left: auto; font-size: .68rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; }
.chg-direct { background: #dcefe5; color: #1f6a44; }
.chg-copybook { background: #fdf3d9; color: #9a6b12; }
.chg-dataset { background: #e0eef6; color: #1c5f88; }
.chg-job, .chg-other { background: var(--surface-alt); color: var(--text-muted); }

.chg-actions { display: flex; gap: .5rem; justify-content: flex-end; padding: .7rem 1rem; border-top: 1px solid var(--surface-alt); }
.chg-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 0 1rem 1rem; }
.chg-tier { text-align: left; border: 1px solid var(--border); border-radius: 11px; padding: .7rem; background: var(--surface);
    cursor: pointer; display: flex; flex-direction: column; gap: .35rem; }
.chg-tier:hover:not(:disabled) { border-color: var(--brand-primary); background: var(--surface-alt); }
.chg-tier:disabled { opacity: .55; cursor: not-allowed; }
.chg-tier.now { border-color: #2c7a58; box-shadow: 0 0 0 1px #2c7a58 inset; }
.chg-tier-t { font-weight: 700; font-size: .86rem; color: var(--text); }
.chg-tier-d { font-size: .74rem; color: var(--text-muted); }
.chg-badge { align-self: flex-start; margin-top: auto; font-size: .66rem; font-weight: 600; padding: .12rem .45rem; border-radius: 6px; }
.chg-badge.good { background: #dcefe5; color: #2c7a58; }
.chg-badge.prev { background: var(--surface-alt); color: var(--text-muted); }
@media (max-width: 720px) { .chg-tiers { grid-template-columns: 1fr; } }

.chg-preview-modal { max-width: 760px; }
.chg-preview-banner { background: #fdf3d9; color: #8a5a12; border-bottom: 1px solid #f0d489; padding: .55rem 1rem; font-size: .8rem; }
.chg-preview-note { font-size: .85rem; color: var(--text-muted); margin: 0 0 .6rem; }
.chg-preview-code { background: #0f151d; color: #d7e3ee; border-radius: 10px; padding: .8rem; font-size: .76rem;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace; overflow-x: auto; white-space: pre; }

.chg-gate { margin-top: .6rem; font-size: .8rem; color: #8a5a12; background: #fdf3d9;
    border: 1px solid #f0d489; border-radius: 8px; padding: .5rem .6rem; }

/* --- Change workbench: info icon, manual add, remove --- */
.chg-row { position: relative; }
.chg-info { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: .9rem;
    line-height: 1; padding: 0 .1rem; }
.chg-info:hover { color: var(--brand-primary); }
.chg-reason { margin-left: auto; }
.chg-remove { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: .85rem;
    padding: 0 .1rem; }
.chg-remove:hover { color: #b3261e; }
.chg-info-pop { margin: .1rem 0 .4rem 0; background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: 8px; padding: .5rem .6rem; font-size: .78rem; color: var(--text); display: flex;
    flex-direction: column; gap: .2rem; }
.chg-info-h { font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); margin-bottom: .1rem; }
.chg-info-k { display: inline-block; min-width: 3.4rem; font-weight: 600; color: var(--brand-primary-dark); }

.chg-addbar { padding: 0 1rem .4rem; }
.chg-addlink { border: 1px dashed var(--border); background: var(--surface); color: var(--brand-primary-dark);
    border-radius: 8px; padding: .35rem .6rem; font-size: .8rem; cursor: pointer; }
.chg-addlink:hover:not(:disabled) { border-color: var(--brand-primary); background: var(--surface-alt); }
.chg-addlink:disabled { opacity: .5; cursor: not-allowed; }
.chg-addnote { margin-left: .5rem; font-size: .74rem; color: var(--text-muted); }
.chg-addform { border: 1px solid var(--border); border-radius: 10px; padding: .7rem; display: flex;
    flex-direction: column; gap: .45rem; background: var(--surface-alt); }
.chg-addform-h { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.chg-addinput { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: .4rem .5rem;
    font-size: .82rem; background: var(--surface); color: var(--text); }
.chg-addform-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.chg-addhint { font-size: .72rem; color: var(--text-muted); }

/* --- Change workbench: source badge, remove-confirm, spinner, tier buttons --- */
.chg-src { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 5px; display: inline-grid; place-items: center;
    font-size: .66rem; font-weight: 700; color: #fff; margin-right: .1rem; }
.chg-src-t { background: var(--brand-primary); }          /* Tool (LMA) */
.chg-src-m { background: #2c7a58; }                        /* Manual (analyst) */

.chg-remove-link { border: none; background: none; color: #b3261e; cursor: pointer; font-size: .78rem;
    padding: .2rem 0 0; text-align: left; }
.chg-remove-link:hover { text-decoration: underline; }
.chg-info-confirm { margin-top: .35rem; padding-top: .35rem; border-top: 1px dashed var(--border);
    display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; }
.chg-confirm-actions { display: flex; gap: .4rem; }
.chg-danger { border: 1px solid #b3261e; background: #b3261e; color: #fff; border-radius: 7px;
    padding: .25rem .6rem; font-size: .78rem; cursor: pointer; }
.chg-danger:hover:not(:disabled) { background: #97160f; }
.chg-danger:disabled { opacity: .5; cursor: not-allowed; }

.chg-working { display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem; font-size: .82rem;
    color: var(--brand-primary-dark); }

.chg-tier-actions { display: flex; align-items: center; gap: .4rem; margin-top: auto; }
.chg-tbtn { border: 1px solid var(--border); background: var(--surface); color: var(--brand-primary-dark);
    border-radius: 7px; padding: .3rem .65rem; font-size: .78rem; font-weight: 600; cursor: pointer; }
.chg-tbtn:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--brand-primary); }
.chg-tbtn.primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.chg-tbtn.primary:hover:not(:disabled) { background: var(--brand-primary-dark); }
.chg-tbtn:disabled { opacity: .5; cursor: not-allowed; }
.chg-tier-actions .chg-badge { margin-right: auto; margin-top: 0; }

/* --- Code-editing review panel (Change screen) --- */
.rev-panel { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden;
    box-shadow: 0 1px 2px rgba(20,32,46,.05), 0 6px 20px rgba(20,32,46,.06); margin: .5rem 0; }
.rev-head { display: flex; gap: .7rem; align-items: center; padding: .8rem 1rem;
    background: linear-gradient(90deg, #eaf3fa, #f5f9fd); border-bottom: 1px solid #dbe8f4; }
.rev-seal { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 1.1rem;
    background: var(--brand-primary); }
.rev-heading { flex: 1 1 auto; }
.rev-title { font-weight: 700; color: var(--brand-primary-dark); font-size: 1rem; }
.rev-count { display: inline-block; min-width: 1.4rem; text-align: center; margin-left: .25rem; padding: 0 .4rem;
    border-radius: 999px; background: var(--brand-primary); color: #fff; font-size: .78rem; }
.rev-sub { font-size: .76rem; color: #4a6a86; margin-top: .1rem; }
.rev-empty { padding: 1rem; font-size: .85rem; color: var(--text-muted); }

.rev-list { padding: .4rem .6rem; display: flex; flex-direction: column; }
.rev-row { display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem; border-top: 1px solid var(--surface-alt); }
.rev-row:first-child { border-top: none; }
.rev-stat { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; display: inline-grid; place-items: center;
    font-size: .68rem; font-weight: 700; color: #fff; }
.rev-modified { background: #b5892a; }
.rev-added { background: #2c7a58; }
.rev-path { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; color: var(--text); cursor: pointer; }
.rev-path:hover { color: var(--brand-primary); text-decoration: underline; }
.rev-counts { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; margin-left: auto; }
.rev-add { color: #2c7a58; } .rev-del { color: #b3261e; }
.rev-assure { font-size: .66rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; }
.rev-a-ok { background: #dcefe5; color: #1f6a44; }
.rev-a-warn { background: #fdf3d9; color: #9a6b12; }
.rev-a-err { background: #f7dcda; color: #a3271e; }
.rev-a-none { background: var(--surface-alt); color: var(--text-muted); }
.rev-mini { border: 1px solid var(--border); background: var(--surface); color: var(--brand-primary-dark);
    border-radius: 6px; padding: .18rem .5rem; font-size: .72rem; cursor: pointer; }
.rev-mini:hover:not(:disabled) { background: var(--surface-alt); }
.rev-mini.danger { color: #b3261e; }
.rev-mini:disabled { opacity: .5; cursor: not-allowed; }

.rev-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem .6rem;
    background: #fdf3d9; border-top: 1px solid #f0d489; font-size: .8rem; }
.rev-confirm-actions { display: flex; gap: .4rem; margin-left: auto; }

.rev-diffbox { border-top: 1px solid var(--surface-alt); background: var(--surface-alt); padding: .4rem; }
.rev-diff-loading { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--text-muted); padding: .4rem; }
.rev-issues { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .4rem; }
.rev-issue { display: flex; gap: .5rem; align-items: baseline; font-size: .76rem; padding: .3rem .5rem; border-radius: 6px; }
.rev-iss-error { background: #f7dcda; color: #7d1b15; }
.rev-iss-warning { background: #fdf3d9; color: #7a5410; }
.rev-iss-info { background: var(--surface); color: var(--text-muted); }
.rev-iss-sev { font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.rev-iss-msg { flex: 1 1 auto; }
.rev-iss-src { font-family: ui-monospace, Consolas, monospace; font-size: .68rem; opacity: .7; }

.diffview { background: #0f151d; border-radius: 8px; overflow-x: auto; font-family: ui-monospace, Consolas, monospace;
    font-size: .76rem; line-height: 1.45; padding: .3rem 0; }
.dl { display: flex; white-space: pre; }
.dl-no { flex: 0 0 auto; width: 2.6rem; text-align: right; padding: 0 .4rem; color: #5b6b7d; user-select: none; }
.dl-sign { flex: 0 0 auto; width: 1rem; text-align: center; color: #8494a4; }
.dl-txt { flex: 1 1 auto; padding-right: .6rem; color: #d7e3ee; }
.dl-added { background: rgba(46,125,50,.22); }
.dl-added .dl-txt { color: #b6e6c4; }
.dl-removed { background: rgba(179,38,30,.22); }
.dl-removed .dl-txt { color: #f2c4c0; }

.rev-foot { padding: .7rem 1rem; border-top: 1px solid var(--surface-alt); display: flex; justify-content: flex-end; }
.rev-pkg { padding: 0 1rem 1rem; }
.rev-pkg-h { font-size: .78rem; color: var(--text-muted); margin: .2rem 0 .5rem; }

.rev-pkgtoggle { display: inline-flex; align-items: center; gap: .2rem; font-size: .68rem; color: var(--text-muted);
    cursor: pointer; user-select: none; }
.rev-pkgtoggle input { margin: 0; }

.pkg-picklist { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); padding: .3rem .4rem; display: flex; flex-direction: column; gap: .1rem; }
.pkg-pick { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text);
    font-family: ui-monospace, Consolas, monospace; padding: .15rem .2rem; cursor: pointer; border-radius: 4px; }
.pkg-pick:hover { background: var(--surface-alt); }
.pkg-pick input { margin: 0; }
.pkg-pick-all { font-family: inherit; font-weight: 600; color: var(--brand-primary-dark); }

.pkg-pick-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pkg-empty { font-size: .78rem; color: var(--text-muted); padding: .3rem .2rem; }

.chg-fileicon { flex: 0 0 auto; font-size: .95rem; line-height: 1; }

/* Persistent per-response export (Word / PDF / Markdown) */
.msg-export { display: flex; align-items: center; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.msg-export-lbl { font-size: .72rem; color: var(--text-muted); }
.msg-export-btn { font-size: .72rem; border: 1px solid var(--border); background: var(--surface);
    color: var(--brand-primary-dark); border-radius: 6px; padding: .12rem .5rem; cursor: pointer; }
.msg-export-btn:hover:not(:disabled) { background: var(--surface-alt); border-color: var(--brand-primary); }
.msg-export-btn:disabled { opacity: .5; cursor: not-allowed; }
