/* ==========================================================================
   1. CONTAINER — Grok/Gemini style: page grows with chat (document scroll)
   ========================================================================== */
.joshua-ai {
    width: 100%;
}

.joshua-ai .ai-container.recruitment-banner,
.joshua-ai .ai-container {
    display: flex;
    flex-direction: column;
    height: auto;
    /* Compact start — do NOT force almost-full-viewport empty gap before first messages */
    min-height: 0;
    padding: 16px 20px 12px;
    box-sizing: border-box;
    text-align: left; /* override .recruitment-banner center for chat */
}

.joshua-ai .chat-interface {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid #333;
    overflow: visible; /* document scroll; sticky input rides the page */
    margin-top: 12px;
    min-height: 0;
}

/* legacy class kept for any other pages that share it */
.ai-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    padding: 20px;
    box-sizing: border-box;
}

.chat-interface {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid #333;
    overflow: visible;
    margin-top: 15px;
}

/* ==========================================================================
   2. TERMINAL WINDOW HEADER & WELCOME DASHBOARD
   ========================================================================== */
.joshua-doc-links {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.joshua-doc-link {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: #7dffa8;
    text-decoration: none;
    border: 1px solid rgba(125, 255, 168, 0.35);
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}
.joshua-doc-link:hover {
    background: rgba(125, 255, 168, 0.12);
    color: #b8ffd0;
}
.joshua-doc-link--inline {
    margin-left: 0;
    border: none;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.joshua-doc-refs {
    display: block;
    margin-top: 6px;
    color: #8aa;
    font-size: 0.85em;
}
.joshua-doc-refs a {
    color: #7dffa8;
}
.dash-row--docs {
    margin-top: 6px;
}
.dash-muted {
    color: #6a8a7a;
    font-size: 0.9em;
}
.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 15, 15, 0.9);
    border-bottom: 1px solid #333;
    padding: 8px 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 1px;
}
.system-title { color: #888888; }
.system-version { 
    color: #00ff00; 
    background: rgba(0, 255, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.joshua-status-bar {
    padding: 8px 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    background: rgba(40, 20, 0, 0.55);
    border-bottom: 1px solid rgba(255, 140, 0, 0.35);
    color: #ffcc88;
}
.joshua-status-bar.is-err {
    background: rgba(60, 0, 0, 0.55);
    border-color: #aa3333;
    color: #ffaaaa;
}
.joshua-status-bar.is-ok {
    background: rgba(0, 40, 10, 0.5);
    border-color: #00aa55;
    color: #88ffaa;
}
.joshua-status-bar.is-warn {
    color: #ffe088;
}

.joshua-owner-panel {
    padding: 8px 12px;
    background: rgba(0, 30, 20, 0.65);
    border-bottom: 1px solid rgba(0, 200, 100, 0.25);
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #a8e0c0;
}
.joshua-owner-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}
.joshua-owner-row strong {
    color: #00ff99;
    letter-spacing: 0.04em;
}
.joshua-select {
    min-width: 200px;
    max-width: 360px;
    flex: 1;
    background: #0a120e;
    color: #c8f0d8;
    border: 1px solid #2a5a40;
    border-radius: 4px;
    padding: 5px 8px;
    font: inherit;
}
.joshua-select--sm {
    min-width: 72px;
    max-width: 96px;
    flex: 0 0 auto;
}
#joshua-type-speed.joshua-select--sm {
    min-width: 104px;
    max-width: 128px;
}
.joshua-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #88bb99;
    cursor: pointer;
    white-space: nowrap;
}
.joshua-owner-hint {
    margin-top: 6px;
    font-size: 0.7rem;
    color: #6a9a7a;
    opacity: 0.95;
}

/* Brain sleep — same owner strip, terminal tone */
.joshua-sleep-panel {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 200, 140, 0.28);
}
.joshua-sleep-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}
.joshua-sleep-row strong {
    color: #7ad0ff;
    letter-spacing: 0.05em;
}
.joshua-sleep-tag {
    font-size: 0.65rem;
    color: #6a9aaa;
    letter-spacing: 0.03em;
}
.joshua-sleep-btn {
    font-size: 0.72rem;
    padding: 4px 10px;
    color: #7ad0ff;
    border-color: #3a7a9a;
}
.joshua-sleep-btn:hover {
    background: #3a7a9a;
    color: #041018;
    box-shadow: 0 0 10px rgba(80, 180, 220, 0.35);
}
.joshua-sleep-btn:disabled {
    opacity: 0.45;
    cursor: wait;
}
.joshua-sleep-out {
    margin: 8px 0 0;
    padding: 8px 10px;
    max-height: 180px;
    overflow: auto;
    background: rgba(0, 12, 20, 0.75);
    border: 1px solid rgba(80, 160, 200, 0.28);
    border-radius: 4px;
    color: #b0d8e8;
    font-size: 0.68rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}
.joshua-sleep-out.is-err {
    color: #ffb0a0;
    border-color: rgba(200, 80, 60, 0.4);
}
.joshua-sleep-out.is-ok {
    border-color: rgba(0, 200, 140, 0.35);
}
.joshua-sleep-hint {
    margin-top: 6px;
    font-size: 0.68rem;
    color: #5a8a9a;
}
.joshua-sleep-hint code {
    color: #88c8e0;
    font-size: 0.65rem;
}

/* ── Owner panel collapse (strip always visible) ─────────────────── */
.joshua-owner-panel {
    margin-bottom: 6px;
}
.joshua-owner-panel__strip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.joshua-owner-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 10px !important;
    border: 1px solid rgba(0, 200, 140, 0.45) !important;
    border-radius: 3px;
    background: rgba(0, 40, 32, 0.7) !important;
    color: #9ec8b8 !important;
    cursor: pointer;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
}
.joshua-owner-toggle:hover {
    border-color: rgba(125, 255, 168, 0.6) !important;
    color: #d0ffe0 !important;
    background: rgba(0, 70, 50, 0.75) !important;
}
.joshua-owner-toggle__chev {
    color: #7dffa8;
    font-size: 0.75rem;
    line-height: 1;
    transition: transform 0.12s ease;
}
.joshua-owner-toggle__title {
    color: #7dffa8;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
}
.joshua-owner-toggle__hint {
    margin-left: 4px;
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    color: #5a8870;
    text-transform: uppercase;
}
.joshua-owner-panel__strip-note {
    font-size: 0.62rem;
    color: #5a8070;
}
.joshua-owner-panel[data-collapsed="1"] .joshua-owner-body {
    display: none !important;
}
.joshua-owner-panel[data-collapsed="0"] .joshua-owner-body {
    display: block;
    margin-top: 8px;
}
.joshua-owner-panel[data-collapsed="0"] .joshua-owner-toggle__chev {
    /* expanded: chevron points down */
}

/* ── Brain MEMORY locations (STM / LTM · multi-node) ─────────────── */
.joshua-mem {
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid rgba(120, 180, 255, 0.35);
    border-radius: 4px;
    background: rgba(8, 14, 28, 0.78);
}
.joshua-mem__doctrine {
    margin: 0 0 8px;
    font-size: 0.68rem;
    color: #9ab4d0;
    line-height: 1.35;
}
.joshua-mem__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}
.joshua-mem__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.68rem;
    color: #b8cce0;
}
.joshua-mem__field--wide {
    grid-column: 1 / -1;
}
.joshua-mem__field--check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.joshua-mem__field span em {
    opacity: 0.65;
    font-style: normal;
    font-size: 0.62rem;
}
.joshua-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(120, 180, 255, 0.3);
    color: #d8e8ff;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.72rem;
    border-radius: 3px;
}
.joshua-mem__hint {
    color: #7a90a8;
    font-size: 0.6rem;
}
.joshua-mem__probe {
    margin-left: 6px;
    font-size: 0.6rem;
}
.joshua-mem__probe--ok {
    color: #7dffa8;
}
.joshua-mem__probe--bad {
    color: #ff8a8a;
}
.joshua-mem__counts {
    margin-top: 8px;
    font-size: 0.62rem;
    color: #a0c4e8;
}
.joshua-mem__installer {
    margin: 8px 0 0;
    padding: 6px 8px;
    font-size: 0.58rem;
    color: #8aa0b8;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 3px;
    overflow-x: auto;
    white-space: pre-wrap;
}
@media (max-width: 720px) {
    .joshua-mem__grid {
        grid-template-columns: 1fr;
    }
}

/* ── Brain Box TOOLBOX (owner) ───────────────────────────────────── */
.joshua-toolbox {
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 200, 140, 0.35);
    border-radius: 4px;
    background: rgba(0, 18, 16, 0.72);
}
.joshua-toolbox__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.joshua-toolbox__head strong {
    color: #7dffa8;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
}
.joshua-toolbox__tag {
    flex: 1 1 auto;
    font-size: 0.62rem;
    color: #6a9080;
}
.joshua-tb-vram {
    margin-bottom: 8px;
}
.joshua-tb-vram__label {
    font-size: 0.65rem;
    color: #9ec8b8;
    margin-bottom: 4px;
}
.joshua-tb-vram__bar {
    height: 6px;
    background: rgba(0, 40, 32, 0.8);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(0, 180, 120, 0.25);
}
.joshua-tb-vram__bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #1a8a5a, #7dffa8);
    min-width: 2px;
}
.joshua-toolbox__profiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.joshua-tb-profile {
    font-size: 0.62rem;
    padding: 3px 8px;
    border: 1px solid rgba(0, 180, 120, 0.35);
    border-radius: 3px;
    background: rgba(0, 30, 24, 0.6);
    color: #9ec8b8;
    cursor: pointer;
}
.joshua-tb-profile:hover,
.joshua-tb-profile.is-active {
    border-color: #7dffa8;
    color: #d0ffe0;
    background: rgba(0, 60, 40, 0.55);
}
.joshua-toolbox__slots {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    max-height: 160px;
    overflow: auto;
}
.joshua-tb-chip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding: 5px 8px;
    border-radius: 3px;
    border: 1px solid rgba(80, 120, 100, 0.35);
    background: rgba(0, 12, 14, 0.55);
    font-size: 0.65rem;
}
.joshua-tb-chip.is-warm {
    border-color: rgba(0, 220, 140, 0.5);
}
.joshua-tb-chip.is-cold {
    border-color: rgba(120, 90, 60, 0.4);
    opacity: 0.9;
}
.joshua-tb-chip__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #666;
    flex: 0 0 auto;
}
.joshua-tb-chip.is-warm .joshua-tb-chip__dot {
    background: #7dffa8;
    box-shadow: 0 0 6px #7dffa8;
}
.joshua-tb-chip.is-cold .joshua-tb-chip__dot {
    background: #c88a40;
}
.joshua-tb-chip__name {
    color: #d0e8e0;
    font-weight: 600;
}
.joshua-tb-chip__meta {
    color: #6a9080;
    flex: 1 1 auto;
}
.joshua-tb-chip__acts {
    display: flex;
    gap: 4px;
}
.joshua-tb-mini {
    font-size: 0.58rem;
    padding: 2px 6px;
    border: 1px solid rgba(0, 160, 120, 0.4);
    border-radius: 2px;
    background: transparent;
    color: #9ec8b8;
    cursor: pointer;
}
.joshua-tb-mini:hover {
    border-color: #7dffa8;
    color: #fff;
}
.joshua-tb-mini--danger {
    border-color: rgba(180, 80, 60, 0.5);
    color: #e8a090;
}
.joshua-tb-empty {
    margin: 0;
    font-size: 0.65rem;
    color: #6a8070;
}
.joshua-toolbox__add {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.joshua-owner-row--fallback {
    margin-top: 6px;
    opacity: 0.92;
    border-top: 1px dashed rgba(0, 120, 90, 0.3);
    padding-top: 8px;
}
.joshua-owner-row--fallback strong {
    color: #8aaa90;
    font-size: 0.68rem;
}

/* Foundry owner rail — side queue + guided process */
.joshua-body-row {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0;
}
.joshua-body-row--owner {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
}
.joshua-body-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.joshua-foundry-rail {
    flex: 0 0 300px;
    width: 300px;
    max-width: 36vw;
    border-left: 1px solid rgba(0, 200, 140, 0.28);
    background: rgba(0, 10, 16, 0.72);
    padding: 10px 10px 16px;
    font-size: 0.68rem;
    color: #9ec8b8;
    max-height: calc(100vh - 120px);
    overflow: auto;
    position: sticky;
    top: 8px;
    align-self: flex-start;
    transition: flex-basis 0.18s ease, width 0.18s ease, max-width 0.18s ease, padding 0.18s ease;
    box-sizing: border-box;
}
.joshua-foundry-rail[data-collapsed="1"] {
    flex: 0 0 48px !important;
    width: 48px !important;
    max-width: 48px !important;
    min-width: 48px;
    padding: 8px 4px !important;
    overflow: hidden;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-body,
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-refresh {
    display: none !important;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-rail__head {
    flex-direction: column;
    margin-bottom: 0;
    justify-content: flex-start;
    align-items: center;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-toggle {
    flex-direction: column;
    width: 100%;
    padding: 6px 2px !important;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-rail__title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.14em;
    font-size: 0.68rem;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-toggle__chev {
    transform: rotate(0deg);
}
.joshua-foundry-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}
.joshua-foundry-rail__head strong,
.joshua-foundry-rail__title {
    color: #7dffa8;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    font-weight: 700;
}
/* Explicit terminal-styled toggle — do not rely on browser default <button> */
.joshua-foundry-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 5px 8px !important;
    border: 1px solid rgba(0, 200, 140, 0.4) !important;
    border-radius: 3px;
    background: rgba(0, 40, 32, 0.65) !important;
    color: #9ec8b8 !important;
    cursor: pointer;
    text-align: left;
    font: inherit;
    line-height: 1.2;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}
.joshua-foundry-toggle:hover {
    background: rgba(0, 70, 50, 0.75) !important;
    border-color: rgba(125, 255, 168, 0.55) !important;
    color: #d0ffe0 !important;
}
.joshua-foundry-toggle:hover .joshua-foundry-rail__title {
    color: #b8ffd0;
}
.joshua-foundry-toggle__hint {
    margin-left: auto;
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    color: #5a8870;
    text-transform: uppercase;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-foundry-toggle__hint {
    display: none;
}
.joshua-foundry-toggle__chev {
    display: inline-block;
    color: #7dffa8;
    font-size: 0.8rem;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform 0.15s ease;
    flex: 0 0 auto;
}
/* Tools legend inside foundry rail */
.joshua-tools-legend {
    margin: 0 0 10px;
    border: 1px solid rgba(0, 200, 140, 0.28);
    border-radius: 3px;
    background: rgba(0, 24, 20, 0.55);
}
.joshua-tools-legend__sum {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    color: #7dffa8;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    user-select: none;
}
.joshua-tools-legend__sum::-webkit-details-marker {
    display: none;
}
.joshua-tools-legend__sum::before {
    content: '▶';
    font-size: 0.6rem;
    color: #5dffc0;
    transition: transform 0.12s ease;
}
.joshua-tools-legend[open] .joshua-tools-legend__sum::before {
    transform: rotate(90deg);
}
.joshua-tools-legend__title {
    font-weight: 700;
}
.joshua-tools-legend__hint {
    margin-left: auto;
    font-size: 0.58rem;
    color: #5a8870;
    text-transform: uppercase;
}
.joshua-tools-legend__body {
    padding: 0 8px 8px;
    border-top: 1px solid rgba(0, 200, 140, 0.15);
}
.joshua-tools-legend__lead,
.joshua-tools-legend__note {
    margin: 6px 0;
    font-size: 0.6rem;
    line-height: 1.35;
    color: #8ab8a8;
}
.joshua-tools-legend__links {
    margin: 4px 0 8px;
    font-size: 0.62rem;
}
.joshua-tools-legend__list {
    margin: 0;
    padding-left: 1rem;
    font-size: 0.6rem;
    line-height: 1.4;
    color: #9ec8b8;
}
.joshua-tools-legend__list li {
    margin-bottom: 5px;
}
.joshua-tools-legend__list strong {
    color: #b8ffd0;
}
.joshua-tools-legend__cmd {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 4px;
    background: rgba(0, 40, 32, 0.8);
    border-radius: 2px;
    color: #c8ffe8;
    font-size: 0.55rem;
    word-break: break-all;
}
.joshua-foundry-rail[data-collapsed="1"] .joshua-tools-legend {
    display: none !important;
}
.joshua-foundry-rail__note {
    margin: 0 0 8px;
    padding: 6px 8px;
    font-size: 0.62rem;
    line-height: 1.35;
    color: #6a9080;
    border: 1px solid rgba(0, 160, 120, 0.22);
    border-radius: 3px;
    background: rgba(0, 20, 16, 0.45);
}
.joshua-foundry-refresh {
    flex: 0 0 auto;
    min-width: 32px;
    padding: 4px 8px !important;
}
.joshua-foundry-batch {
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid rgba(0, 200, 140, 0.3);
    border-radius: 4px;
    background: rgba(0, 30, 24, 0.45);
}
.joshua-foundry-batch__title {
    color: #8ef0c0;
    font-weight: bold;
    margin-bottom: 6px;
}
.joshua-foundry-batch__bar {
    height: 8px;
    background: rgba(0, 40, 32, 0.9);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.joshua-foundry-batch__bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #1a8a5a, #4dffb0);
    transition: width 0.35s ease;
}
.joshua-foundry-batch__msg {
    line-height: 1.35;
    color: #c8f0dc;
}
.joshua-foundry-batch__meta {
    margin-top: 4px;
    color: #5a9a7a;
    font-size: 0.62rem;
}
.joshua-foundry-sec {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(0, 160, 120, 0.25);
}
.joshua-foundry-sec h4 {
    margin: 0 0 6px;
    color: #7ad0ff;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
}
.joshua-foundry-sec ul,
.joshua-foundry-process ol {
    margin: 0;
    padding-left: 1.1rem;
    line-height: 1.4;
}
.joshua-foundry-sec li,
.joshua-foundry-process li {
    margin-bottom: 3px;
}
.joshua-foundry-sched[data-status="not_scheduled"] {
    color: #b0c8d0;
}
.joshua-foundry-sched[data-status="planned"] {
    color: #ffe08a;
}
.joshua-foundry-sched[data-status="pile_ready"],
.joshua-foundry-sched[data-status="pile_ready_ft_off"] {
    color: #8ef0c0;
}
.joshua-foundry-when {
    margin: 4px 0;
    color: #88c8e0;
}
.joshua-foundry-never {
    margin: 0;
    color: #6a8a7a;
    font-size: 0.62rem;
}
.joshua-foundry-process {
    margin-bottom: 10px;
}
.joshua-foundry-process h4 {
    margin: 0 0 4px;
    color: #c0a060;
    font-size: 0.7rem;
}
.joshua-foundry-bucket {
    margin-bottom: 10px;
}
.joshua-foundry-bucket__h {
    font-weight: bold;
    color: #a0e0c0;
    margin-bottom: 4px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(0, 180, 120, 0.2);
}
.joshua-foundry-bucket[data-bucket="kill"] .joshua-foundry-bucket__h {
    color: #e09080;
}
.joshua-foundry-bucket[data-bucket="review"] .joshua-foundry-bucket__h {
    color: #e0c070;
}
.joshua-foundry-empty {
    margin: 0;
    opacity: 0.5;
    font-style: italic;
}
.joshua-foundry-card {
    margin: 6px 0;
    padding: 6px;
    border: 1px solid rgba(80, 140, 120, 0.25);
    border-radius: 3px;
    background: rgba(0, 16, 12, 0.5);
}
.joshua-foundry-card__top {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}
.joshua-foundry-score {
    color: #7dffa8;
    font-variant-numeric: tabular-nums;
}
.joshua-foundry-why {
    margin-top: 3px;
    color: #6a9a88;
    font-size: 0.62rem;
}
.joshua-foundry-card__acts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}
.joshua-foundry-mini {
    font-size: 0.6rem;
    padding: 2px 6px;
    cursor: pointer;
    background: transparent;
    color: #8ab;
    border: 1px solid #456;
    border-radius: 2px;
}
.joshua-foundry-mini:hover {
    background: #2a5a4a;
    color: #dff;
}
.joshua-foundry-mini--danger {
    color: #e89;
    border-color: #844;
}
.joshua-foundry-mini--danger:hover {
    background: #5a2a2a;
    color: #fdd;
}
@media (max-width: 960px) {
    .joshua-body-row--owner {
        flex-direction: column;
    }
    .joshua-foundry-rail {
        width: 100%;
        max-width: none;
        flex-basis: auto;
        max-height: 42vh;
        position: static;
        border-left: none;
        border-top: 1px solid rgba(0, 200, 140, 0.28);
    }
}

#joshua-state-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
}

/* OpenWebUI-style markdown / code blocks in replies */
.response-text.joshua-md {
    display: block;
    font-family: inherit;
    font-weight: normal;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
}
.joshua-md .joshua-p {
    margin: 0 0 0.55em;
}
.joshua-md .joshua-p:last-child {
    margin-bottom: 0;
}
.joshua-inline-code {
    font-family: ui-monospace, 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.88em;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 255, 120, 0.18);
    border-radius: 4px;
    padding: 0.1em 0.35em;
    color: #9dffc4;
}
.joshua-code {
    margin: 0.65em 0 0.85em;
    border: 1px solid rgba(0, 180, 90, 0.35);
    border-radius: 8px;
    overflow: hidden;
    background: #0b0f0c;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.joshua-code__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #141a16, #0e1210);
    border-bottom: 1px solid rgba(0, 180, 90, 0.22);
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
}
.joshua-code__lang {
    color: #6a9a7a;
    text-transform: lowercase;
    letter-spacing: 0.04em;
}
.joshua-code__copy {
    background: transparent;
    border: 1px solid rgba(0, 200, 100, 0.35);
    color: #88eeb0;
    border-radius: 4px;
    padding: 2px 8px;
    font: inherit;
    cursor: pointer;
}
.joshua-code__copy:hover {
    background: rgba(0, 255, 120, 0.08);
    border-color: rgba(0, 255, 120, 0.55);
}
.joshua-code__pre {
    margin: 0;
    padding: 12px 14px;
    overflow-x: auto;
    max-height: 360px;
    overflow-y: auto;
    font-family: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #d4f5e0;
    tab-size: 2;
    background: #080b09;
}
.joshua-code__pre code {
    font-family: inherit;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    white-space: pre;
}

.welcome-dashboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: rgba(255, 102, 0, 0.03); /* Subtle orange tint glow */
    border: 1px dashed rgba(255, 102, 0, 0.2);
    margin-bottom: 15px;
    font-family: 'Courier New', Courier, monospace;
}
.dash-row {
    display: flex;
    font-size: 0.9rem;
}
.dash-label {
    color: #888888;
    width: 160px;
    flex-shrink: 0;
}
.dash-value { color: #ffffff; }
.status-online { 
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00ff00; 
    font-weight: bold;
}
.core-glow {
    color: #00ff66 !important;
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.4);
}
.terminal-boot-log {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #aaaaaa;
    margin-left: 4px;
}
.text-success { color: #00ff00; font-weight: bold; }
.dash-divider {
    color: rgba(255, 102, 0, 0.3);
    letter-spacing: -1px;
}
.dash-instruction {
    color: #ff6600;
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.85;
}

/* ==========================================================================
   3. MESSAGE LOG — grows with the page (Grok-style); empty state is short
   ========================================================================== */
.joshua-ai .chat-history,
.chat-history {
    flex-grow: 0; /* do not inflate empty history to fill the viewport */
    flex-shrink: 0;
    overflow: visible;
    overflow-y: visible;
    padding: 12px 15px 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Was 42vh — left a huge blank canyon between welcome and input on first load */
    min-height: 0;
}

/* After conversation starts, a little air is fine; still no fake half-screen void */
.joshua-ai .chat-history:has(.message) {
    min-height: 0;
    padding-bottom: 28px; /* room above sticky composer */
}

.joshua-ai .welcome-dashboard {
    flex: 0 0 auto;
    margin: 0;
}

/* Message layouts forced left-aligned */
.message {
    line-height: 1.4;
    word-wrap: break-word;
    text-align: left !important;
    width: 100%;
    display: block;
    margin-bottom: 1rem; 
}
.system-msg { color: #00ff00; } /* Neon green */
.user-msg { color: #ffffff; }
.ai-msg { color: #ff6600; }     /* Orange response */

.sender {
    font-weight: bold;
    margin-right: 8px;
    opacity: 0.8;
}

.response-text {
    white-space: pre-wrap; /* Forces the browser to render newlines and spaces */
    display: inline-block;
    word-break: break-word;
    text-align: left;
}

/* ==========================================================================
   4. INPUT AREA — sticky bottom composer (Grok/Gemini feel, always reachable)
   ========================================================================== */
.joshua-ai .chat-input-area,
.chat-input-area {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-top: 1px solid #ff6600;
    background: rgba(0, 0, 0, 0.94);
    padding: 12px;
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 40;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}



.prompt-carat {
    color: #00ff00;
    font-family: monospace;
    font-size: 1.2rem;
    margin-right: 10px;
    animation: blink 1s step-end infinite;
}

#joshua-chat-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #00ff00; 
    padding: 4px 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    resize: none; /* Disables manual container distortion stretching */
    line-height: 1.4;
}
#joshua-chat-input:focus {
    outline: none;
}

.input-btn-cluster {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: center; /* Centers action column block heights vertically */
}

/* ==========================================================================
   5. COMPONENT BUTTONS
   ========================================================================== */
.neon-btn {
    background: transparent;
    color: #ff6600;
    border: 1px solid #ff6600;
    padding: 8px 16px;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}
.neon-btn:hover {
    background: #ff6600;
    color: #000;
    box-shadow: 0 0 10px #ff6600;
}

.terminal-btn {
    background: transparent;
    color: #ff3333;               /* Retro red/amber tint */
    border: 1px solid #ff3333;
    padding: 8px 16px;            /* Matches .neon-btn height perfectly */
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
}
.terminal-btn:hover {
    background: #ff3333;          /* Solid fill on hover just like EXECUTE */
    color: #000;                  /* Inverts text color to black */
    box-shadow: 0 0 10px #ff3333; /* Glow match */
}
.terminal-btn:active {
    transform: scale(0.96);
}

/* ==========================================================================
   6. HARDWARE LOADER & ANIMATION CORES
   ========================================================================== */
.status-dot {
    width: 8px;
    height: 8px;
    background-color: #00ff00;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #00ff00;
    animation: status-pulse 2s infinite ease-in-out;
}

.terminal-loader {
    display: inline-block;
    width: 10px;
    height: 15px;
    background-color: #00ff66; /* Match your neon green layout */
    margin-left: 5px;
    animation: terminal-blink 0.8s infinite steps(2);
    vertical-align: middle;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes status-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 12px #00ff00; }
}

@keyframes terminal-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Typewriter caret while revealing */
.joshua-type-caret {
    display: inline-block;
    width: 0.55ch;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: #00ff66;
    animation: terminal-blink 0.8s infinite steps(2);
}

/* --------------------------------------------------------------------------
   Turn gen stats — muted proof line under each JOSHUA bubble
   (thought · t/s · expand for per-spark mesh dies)
   -------------------------------------------------------------------------- */
.j-turn-stats {
    margin-top: 0.55rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 102, 0, 0.18);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    color: rgba(160, 160, 160, 0.85);
    line-height: 1.35;
    user-select: text;
}
.j-turn-stats__main {
    opacity: 0.9;
}
.j-turn-stats__subs {
    margin-top: 0.2rem;
}
.j-turn-stats__sum {
    cursor: pointer;
    list-style: none;
    color: rgba(0, 200, 120, 0.65);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.j-turn-stats__sum::-webkit-details-marker { display: none; }
.j-turn-stats__sum::before {
    content: '▸ ';
    opacity: 0.7;
}
.j-turn-stats__subs[open] > .j-turn-stats__sum::before {
    content: '▾ ';
}
.j-turn-stats__list {
    margin-top: 0.25rem;
    padding: 0.25rem 0 0.1rem 0.15rem;
    border-left: 1px solid rgba(0, 200, 120, 0.2);
}
.j-turn-stats__row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.12rem 0 0.12rem 0.45rem;
    color: rgba(140, 150, 140, 0.92);
}
.j-turn-stats__row.is-fail {
    color: rgba(220, 120, 90, 0.9);
}
.j-turn-stats__row--meta .j-turn-stats__val {
    color: rgba(120, 180, 200, 0.95);
    white-space: normal;
    text-align: right;
    max-width: 70%;
}
.j-turn-stats__row--rag .j-turn-stats__die {
    color: rgba(180, 160, 100, 0.95);
}
.j-turn-stats[data-kind="silicon"] .j-turn-stats__sum {
    color: rgba(120, 180, 220, 0.75);
}
.j-turn-stats[data-kind="mesh"] .j-turn-stats__sum {
    color: rgba(0, 200, 120, 0.7);
}
.j-turn-stats__die {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.j-turn-stats__val {
    flex-shrink: 0;
    color: rgba(180, 190, 170, 0.95);
    font-variant-numeric: tabular-nums;
}
.ai-msg .j-turn-stats {
    /* sit under response text, full bubble width */
    display: block;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Parent seal strip — after-turn SEAL → HOT / REJECT
   Scoped under .joshua-ai so terminal/global button resets cannot wipe it.
   -------------------------------------------------------------------------- */
.joshua-ai .j-parent-seal,
.ai-msg .j-parent-seal,
.j-parent-seal {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid rgba(255, 140, 40, 0.45);
    border-radius: 6px;
    background: rgba(28, 16, 6, 0.72);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    line-height: 1.35;
    color: rgba(220, 200, 160, 0.95);
}
.joshua-ai .j-parent-seal[data-plane="hot"],
.j-parent-seal[data-plane="hot"] {
    border-color: rgba(0, 200, 120, 0.55);
    background: rgba(6, 28, 18, 0.65);
}
.joshua-ai .j-parent-seal[data-plane="poison"],
.j-parent-seal[data-plane="poison"] {
    border-color: rgba(220, 80, 80, 0.55);
    background: rgba(28, 8, 8, 0.65);
}
.joshua-ai .j-parent-seal__row,
.j-parent-seal__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
}
.joshua-ai .j-parent-seal__label,
.j-parent-seal__label {
    color: rgba(255, 160, 60, 0.98);
    font-weight: 700;
    letter-spacing: 0.1em;
    font-size: 0.64rem;
    text-transform: uppercase;
}
.joshua-ai .j-parent-seal__slug,
.j-parent-seal__slug {
    color: rgba(210, 220, 180, 0.98);
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.joshua-ai .j-parent-seal__slug--empty,
.j-parent-seal__slug--empty {
    color: rgba(140, 140, 140, 0.9);
    font-style: italic;
}
.joshua-ai .j-parent-seal__net,
.joshua-ai .j-parent-seal__shelf,
.j-parent-seal__net,
.j-parent-seal__shelf {
    color: rgba(120, 190, 230, 0.95);
    font-size: 0.64rem;
}
.joshua-ai .j-parent-seal__actions,
.j-parent-seal__actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}
/* Explicit button chrome — do not inherit naked <button> / terminal resets */
.joshua-ai .j-parent-seal__btn,
.ai-msg .j-parent-seal__btn,
.j-parent-seal__btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-block;
    box-sizing: border-box;
    cursor: pointer;
    margin: 0;
    border: 1px solid rgba(255, 140, 40, 0.65) !important;
    background: rgba(40, 22, 8, 0.95) !important;
    color: rgba(255, 190, 100, 0.98) !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 0.64rem !important;
    font-weight: 700;
    letter-spacing: 0.07em;
    line-height: 1.2;
    padding: 0.28rem 0.55rem !important;
    border-radius: 4px;
    text-transform: uppercase;
    text-shadow: none;
    box-shadow: none;
    min-height: 0;
    height: auto;
}
.joshua-ai .j-parent-seal__btn:hover:not(:disabled),
.j-parent-seal__btn:hover:not(:disabled) {
    background: rgba(70, 36, 10, 0.98) !important;
    border-color: rgba(255, 170, 60, 0.9) !important;
    color: #fff !important;
}
.joshua-ai .j-parent-seal__btn:disabled,
.j-parent-seal__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.joshua-ai .j-parent-seal__btn--seal,
.j-parent-seal__btn--seal {
    border-color: rgba(0, 210, 130, 0.7) !important;
    color: rgba(130, 255, 190, 0.98) !important;
    background: rgba(8, 36, 24, 0.95) !important;
}
.joshua-ai .j-parent-seal__btn--seal:hover:not(:disabled),
.j-parent-seal__btn--seal:hover:not(:disabled) {
    background: rgba(12, 56, 36, 0.98) !important;
    border-color: rgba(80, 240, 160, 0.9) !important;
    color: #e8fff2 !important;
}
.joshua-ai .j-parent-seal__btn--reject,
.j-parent-seal__btn--reject {
    border-color: rgba(220, 100, 80, 0.65) !important;
    color: rgba(255, 170, 150, 0.98) !important;
    background: rgba(36, 12, 10, 0.95) !important;
}
.joshua-ai .j-parent-seal__btn--shelf,
.j-parent-seal__btn--shelf {
    border-color: rgba(120, 180, 220, 0.65) !important;
    color: rgba(170, 220, 250, 0.98) !important;
    background: rgba(10, 22, 36, 0.95) !important;
}
.joshua-ai .j-parent-seal__status,
.j-parent-seal__status {
    flex-basis: 100%;
    font-size: 0.64rem;
    color: rgba(170, 170, 170, 0.95);
    min-height: 0.9em;
}
.joshua-ai .j-parent-seal__status[data-kind="ok"],
.j-parent-seal__status[data-kind="ok"] {
    color: rgba(100, 230, 160, 0.98);
}
.joshua-ai .j-parent-seal__status[data-kind="err"],
.j-parent-seal__status[data-kind="err"] {
    color: rgba(250, 140, 120, 0.98);
}
.joshua-ai .j-parent-seal__status[data-kind="busy"],
.j-parent-seal__status[data-kind="busy"] {
    color: rgba(230, 210, 100, 0.95);
}

/* --------------------------------------------------------------------------
   Mentor radio — inspection window (watch baby AI talk to teacher dies)
   -------------------------------------------------------------------------- */
.j-mentor-inspect {
    margin-top: 0.45rem;
    border: 1px solid rgba(120, 180, 220, 0.28);
    border-radius: 6px;
    background: rgba(8, 14, 22, 0.55);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.66rem;
    color: rgba(170, 190, 200, 0.92);
    overflow: hidden;
}
.j-mentor-inspect.is-fail {
    border-color: rgba(220, 100, 80, 0.45);
}
.j-mentor-inspect__sum {
    cursor: pointer;
    list-style: none;
    padding: 0.4rem 0.55rem;
    color: rgba(120, 200, 240, 0.9);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.62rem;
    background: rgba(20, 40, 60, 0.45);
    user-select: none;
}
.j-mentor-inspect__sum::-webkit-details-marker { display: none; }
.j-mentor-inspect__sum::before {
    content: '▸ radio ';
    opacity: 0.75;
}
.j-mentor-inspect[open] > .j-mentor-inspect__sum::before {
    content: '▾ radio ';
}
.j-mentor-inspect__body {
    padding: 0.35rem 0.5rem 0.5rem;
    max-height: 28rem;
    overflow: auto;
}
.j-mentor-inspect__meta {
    color: rgba(140, 180, 160, 0.95);
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px dashed rgba(100, 140, 160, 0.25);
}
.j-mentor-inspect__blk {
    margin: 0.3rem 0;
}
.j-mentor-inspect__blk > summary {
    cursor: pointer;
    color: rgba(200, 160, 100, 0.95);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    list-style: none;
    padding: 0.15rem 0;
}
.j-mentor-inspect__blk > summary::-webkit-details-marker { display: none; }
.j-mentor-inspect__pre {
    margin: 0.2rem 0 0.35rem;
    padding: 0.45rem 0.5rem;
    background: rgba(0, 0, 0, 0.35);
    border-left: 2px solid rgba(120, 180, 220, 0.4);
    white-space: pre-wrap;
    word-break: break-word;
    color: rgba(200, 210, 200, 0.95);
    max-height: 12rem;
    overflow: auto;
    line-height: 1.4;
    font-size: 0.64rem;
}
.j-mentor-inspect__err {
    color: rgba(230, 120, 100, 0.95);
    margin-top: 0.25rem;
}
.ai-msg .j-mentor-inspect {
    display: block;
    width: 100%;
}