@font-face {
    font-family: Noto;
    src: url("/fonts/NotoSans-Regular.ttf");
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font:
        14px Noto,
        system-ui,
        sans-serif;
    color: #24382d;
    background: #f6f7f2;
}
button,
input,
textarea {
    font: inherit;
}
button,
a,
label.upload {
    touch-action: manipulation;
}
button {
    border: 1px solid #d5ded2;
    background: #fff;
    color: #294636;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
}
button:hover {
    background: #edf1e9;
}
button:disabled {
    opacity: 0.45;
    cursor: default;
}
button:focus-visible,
a:focus-visible,
textarea:focus-visible {
    outline: 3px solid #d99739;
    outline-offset: 2px;
}
a {
    color: #2b6546;
}
small {
    display: block;
    color: #67756a;
    font-size: 11px;
    margin-top: 4px;
}
.primary {
    background: #285a40;
    color: white;
    border-color: #285a40;
}
.primary:hover {
    background: #1b412d;
}
.brand {
    text-decoration: none;
    font-weight: bold;
    letter-spacing: 2px;
    font-size: 15px;
    white-space: nowrap;
}
.welcome {
    max-width: 850px;
    margin: 15vh auto;
    padding: 35px;
}
.welcome h1,
.project-list h1 {
    font-size: clamp(32px, 4vw, 54px);
    letter-spacing: -2px;
    line-height: 1.15;
    font-weight: 500;
}
.welcome p,
.project-list > p {
    color: #647064;
    max-width: 580px;
    line-height: 1.7;
}
.project-list {
    max-width: 1100px;
    margin: auto;
    padding: 36px;
}
.project-list header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 80px;
}
.project-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 40px;
}
.project-cards a {
    padding: 24px;
    text-decoration: none;
    background: #e8eee3;
    border: 1px solid #d3ddce;
    border-radius: 8px;
}
.project-cards h2 {
    font-size: 19px;
    font-weight: 500;
}
.studio {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}
.studio-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 22px;
    border-bottom: 1px solid #d6dfd3;
    background: #fafbf7;
}
.studio-header strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
.revision {
    font-size: 12px;
    color: #6b786c;
}
.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}
.studio-body {
    display: grid;
    grid-template-columns: 205px minmax(350px, 1fr) 350px;
    min-height: 0;
    flex: 1;
}
.feature-panel {
    overflow: auto;
    padding: 20px 12px;
    background: #f2f4ed;
    border-right: 1px solid #d6dfd3;
}
.panel-label {
    font-size: 10px;
    letter-spacing: 1.8px;
    color: #71806f;
    margin: 14px 8px;
}
.tree {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: none;
    padding: 10px 8px;
    margin-bottom: 3px;
}
.tree.selected {
    background: #dde8d8;
    border-left: 3px solid #36714b;
}
.tree span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.source {
    overflow-wrap: anywhere;
    font-size: 12px;
    padding: 0 8px;
}
.muted {
    color: #778174;
    font-size: 12px;
    line-height: 1.6;
    padding: 0 8px;
}
.upload {
    display: block;
    padding: 10px;
    border: 1px dashed #bacab4;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
}
.upload input {
    display: none;
}
.inspection {
    min-width: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.view-tabs {
    display: flex;
    gap: 2px;
    padding: 12px 16px;
    border-bottom: 1px solid #d6dfd3;
}
.view-tabs button {
    border: 0;
    background: none;
}
.view-tabs button[aria-pressed="true"] {
    background: #dce7d6;
    font-weight: bold;
}
.view-tabs span {
    margin: auto 0 auto auto;
    font-size: 11px;
    color: #74806f;
}
.viewport {
    position: relative;
    flex: 1;
    min-height: 350px;
    background: #eaf0e9;
}
.viewport > svg,
.three-viewport {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    padding: 55px 25px 35px;
}
.three-viewport {
    padding: 0;
}
.three-viewport canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.viewport-controls {
    position: absolute;
    top: 12px;
    left: 14px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
}
.viewport-controls button {
    padding: 5px 9px;
    font-size: 11px;
}
.viewport-controls button[aria-pressed="true"] {
    background: #284d37;
    color: #fff;
}
.viewport-controls label {
    display: flex;
    align-items: center;
    gap: 3px;
}
.viewport-empty {
    position: absolute;
    top: 47%;
    width: 100%;
    text-align: center;
    pointer-events: none;
    font-size: 20px;
    color: #6d806b;
}
.viewport-empty span {
    display: block;
    font-size: 12px;
    margin-top: 12px;
}
.viewport-caption {
    position: absolute;
    bottom: 12px;
    left: 18px;
    font-size: 10px;
    color: #697d68;
    pointer-events: none;
}
.details,
.playback,
.results {
    padding: 14px 18px;
    border-top: 1px solid #d6dfd3;
    font-size: 12px;
}
.details p {
    line-height: 1.6;
}
.details pre {
    max-height: 200px;
    overflow: auto;
}
.playback > div:first-child {
    display: flex;
    gap: 10px;
    align-items: center;
}
.playback input {
    min-width: 40px;
    flex: 1;
    accent-color: #326748;
}
.playback p {
    font-size: 10px;
    color: #687c65;
}
.stages {
    display: flex;
    gap: 6px;
    overflow: auto;
    padding-top: 10px;
}
.stages button {
    font-size: 11px;
    min-width: 85px;
}
.findings {
    max-height: 170px;
    overflow: auto;
}
.finding {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 0;
    font-size: 11px;
    padding: 10px 18px;
    background: #f4ead6;
}
.finding.error {
    background: #f4ded8;
    color: #902f27;
}
.finding.unverified {
    background: #e9eee4;
    color: #526748;
}
.results > div {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
}
.results span {
    font-size: 11px;
}
.chat {
    border-left: 1px solid #d6dfd3;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fafbf7;
}
.chat-title {
    padding: 19px 20px;
    border-bottom: 1px solid #e0e6dc;
    font-weight: bold;
}
.chat-title small {
    font-weight: normal;
}
.messages {
    overflow: auto;
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.messages article {
    display: contents;
}
.assistant-message,
.user-message {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.7;
}
.user-message {
    background: #e5eddc;
    border-radius: 9px;
    padding: 13px;
}
.cnc-markdown { white-space: normal; }
.cnc-markdown p { margin: 0 0 0.75em; white-space: pre-line; }
.cnc-markdown > :last-child, .cnc-markdown li > :last-child { margin-bottom: 0; }
.cnc-markdown h3, .cnc-markdown h4, .cnc-markdown h5, .cnc-markdown h6 { margin: 1em 0 0.4em; font-size: 1.1em; }
.cnc-markdown > :first-child { margin-top: 0; }
.cnc-markdown ul, .cnc-markdown ol { margin: 0 0 0.75em; padding-left: 1.7em; }
.cnc-markdown li { margin: 0.25em 0; }
.cnc-markdown li > p { margin-bottom: 0.25em; }
.cnc-markdown code { font-size: 0.95em; background: #e5eddf; padding: 0.1em 0.25em; border-radius: 3px; }
.cnc-markdown pre { white-space: pre; overflow-x: auto; padding: 10px; background: #e5eddf; border-radius: 5px; }
.cnc-markdown pre code { padding: 0; }
.cnc-markdown a { color: inherit; text-decoration: underline; }
.chat form {
    padding: 14px;
    border-top: 1px solid #dde5d7;
}
.chat textarea {
    resize: vertical;
    min-height: 100px;
    max-height: 240px;
    width: 100%;
    border: 1px solid #cfdbca;
    border-radius: 7px;
    padding: 12px;
    background: white;
    font-size: 13px;
}
.composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    font-size: 11px;
}
.composer-actions details {
    max-width: 210px;
}
.selection {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 8px;
    background: #e8eddf;
    padding: 6px 10px;
}
.selection button {
    padding: 0 6px;
    border: 0;
    background: none;
}
.error-bar,
.stale {
    padding: 10px 18px;
    background: #f6decf;
    color: #792c20;
    font-size: 12px;
}
.error-bar button {
    float: right;
    padding: 1px 8px;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: #15261988;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}
.modal {
    background: #fafbf7;
    max-height: 85vh;
    width: 760px;
    overflow: auto;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 20px 80px #12291633;
}
.close {
    float: right;
}
.modal h2 {
    font-size: 22px;
    font-weight: 500;
}
.comparison > details > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.comparison pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #eaf0e4;
    padding: 12px;
    font-size: 11px;
}
.token {
    overflow-wrap: anywhere;
    font-family: monospace;
    background: #e6eede;
    padding: 14px;
}
.modal summary {
    cursor: pointer;
    padding: 8px 0;
}
.llm-handoff label {
    display: block;
    margin-top: 20px;
    font-weight: 600;
}
.llm-handoff p {
    margin: 6px 0 12px;
}
.llm-handoff textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-bottom: 12px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}
.llm-handoff [role="status"] {
    margin-left: 12px;
}
.cnc-navigation {
    display: flex;
    gap: 24px;
    padding: 12px 24px;
    border-bottom: 1px solid #ccd7c9;
    height: 48px;
    box-sizing: border-box;
}
.cnc-navigation .active { font-weight: 700; }
.cnc-navigation + .studio { height: calc(100dvh - 48px); }
.equipment-page { max-width: 1040px; margin: 32px auto; padding: 0 24px 40px; }
.equipment-page header, .equipment-toolbar { display: flex; gap: 24px; align-items: center; justify-content: space-between; }
.equipment-button { padding: 12px 18px; border: 1px solid #a2b49c; border-radius: 4px; }
.equipment-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 20px 0; }
.equipment-field { display: flex; flex-direction: column; }
.equipment-page .equipment-field label, .project-equipment .equipment-field label { margin: 0 0 6px; }
.equipment-page label, .project-equipment label { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.equipment-page input, .equipment-page select, .equipment-page textarea,
.project-equipment input, .project-equipment select { padding: 9px; border: 1px solid #a6b79e; border-radius: 4px; min-width: 0; }
.equipment-page fieldset { margin: 24px 0; border: 1px solid #cad5c5; padding: 18px; }
.equipment-page pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 400px; overflow: auto; }
.equipment-actions, .equipment-conflict { margin-top: 24px; padding-top: 20px; border-top: 1px solid #cad5c5; }
.equipment-actions button, .project-equipment button { margin: 4px 8px 4px 0; }
.project-equipment { padding: 12px 0; }
.workspace-report { overflow-x: auto; padding: 12px 0; }
.workspace-report table { border-collapse: collapse; text-align: left; }
.workspace-report th, .workspace-report td { padding: 6px 18px 6px 0; white-space: nowrap; }
.workspace-report td { font-variant-numeric: tabular-nums; }
.workspace-report label { display: block; margin: 16px 0 8px; }
.tool-installation { padding: 12px; margin: 10px 0; border: 1px solid #cad5c5; border-radius: 6px; }
.tool-installation > p { overflow-wrap: anywhere; }
.tool-installation h3 { margin: 0 0 6px; }
.tool-installation > p { margin: 6px 0; }
.project-equipment details, .machining-requirements { margin: 12px 0; }
.project-equipment summary, .machining-requirements summary { cursor: pointer; padding: 6px 0; }
.design-notice { margin: 0; padding: 12px 18px; background: #e5eddf; font-size: 12px; }
@media (max-width: 1150px) {
    .studio-body {
        grid-template-columns: 165px minmax(300px, 1fr) 290px;
    }
    .studio-header {
        gap: 10px;
        padding: 10px;
    }
    .header-actions button {
        font-size: 11px;
        padding: 7px;
    }
    .brand {
        font-size: 12px;
    }
}
@media (max-width: 850px) {
    .studio {
        height: auto;
        min-height: 100dvh;
    }
    .studio-header {
        flex-wrap: wrap;
    }
    .header-actions {
        width: 100%;
        margin: 0;
    }
    .studio-body {
        grid-template-columns: 130px minmax(0, 1fr);
    }
    .chat {
        grid-column: 1/-1;
        min-height: 400px;
        max-height: 700px;
        border-top: 1px solid #ccd8c4;
    }
    .viewport {
        height: 450px;
        flex: auto;
    }
    .feature-panel {
        max-height: 750px;
    }
    .modal-backdrop {
        padding: 10px;
    }
    .modal {
        padding: 18px;
    }
    .comparison > details > div {
        grid-template-columns: 1fr;
    }
}
.solid-inspection {
    flex-shrink: 0;
    background: #f4f6f1;
    border-radius: 12px;
    overflow: hidden;
}
.solid-controls, .solid-part-list, .solid-measurements {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px;
}
.solid-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
}
.solid-controls input[type="number"] {
    width: 110px;
}
.solid-controls select, .solid-controls input[type="number"] {
    padding: 5px 8px;
    border: 1px solid #bacab4;
    border-radius: 4px;
    background: #fbfcf8;
}
.solid-caption {
    padding: 12px;
    margin: 0;
    font-size: 11px;
    color: #71806f;
}
.solid-controls input[type="range"] {
    flex: 1;
    min-width: 160px;
}
.solid-canvas {
    height: 420px;
    min-height: 280px;
    width: 100%;
}
.solid-canvas canvas {
    display: block;
}
.solid-part-list > div {
    display: flex;
    gap: 4px;
    margin-right: 12px;
}
.solid-measurements {
    border-top: 1px solid #d3ddd3;
}
.section-measurement {
    padding: 16px;
    border-top: 1px solid #d3ddd3;
}
.section-measurement svg {
    display: block;
    width: 100%;
    height: 300px;
    cursor: crosshair;
    margin-top: 8px;
    background: #fbfcf8;
}
.section-measurement output {
    display: block;
    font-variant-numeric: tabular-nums;
    padding: 8px 0;
}
.loading-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.loading-spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid #c1cec0;
    border-top-color: #294e3d;
    border-radius: 50%;
    animation: cnc-loading 0.8s linear infinite;
}
@keyframes cnc-loading {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .loading-spinner { animation-duration: 2s; }
}
.preview-status {
    padding: 12px 18px;
}
.preview-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    padding: 24px;
    text-align: center;
}
