:root {
    --tai-primary: #0d6efd;
}

body {
    min-height: 100vh;
}

.font-monospace,
textarea.font-monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
}

.card {
    border-radius: 0.75rem;
}

/* Serial log panels (shared tools) */
.serial-log {
    background: #0d1117;
    color: #e6edf3;
    min-height: 200px;
    overflow-y: auto;
}

/* Serial terminal page — Bootstrap cards layout */
.serial-terminal-page .status-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #6c757d;
    vertical-align: middle;
}

.serial-terminal-page .status-dot.is-online {
    background: #198754;
    box-shadow: 0 0 0 2px rgba(25, 135, 84, 0.35);
}

.serial-terminal-page .terminal-legend .legend-rx {
    color: #198754;
    margin-right: 0.5rem;
}

.serial-terminal-page .terminal-legend .legend-tx {
    color: #0d6efd;
    margin-right: 0.5rem;
}

.serial-terminal-page .terminal-legend .legend-sys {
    color: #6f42c1;
    margin-right: 0.5rem;
}

.serial-terminal-page .terminal-legend .legend-ctrl {
    color: #6c757d;
}

.serial-log-card .card-body {
    background: #1e1e1e;
}

.serial-log-terminal {
    min-height: 260px;
    max-height: min(50vh, 420px);
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    margin: 0;
}

.serial-terminal-page .log-line,
.serial-terminal-page .log-chunk {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 0.15rem;
}

.serial-terminal-page .log-line.log-rx,
.serial-terminal-page .log-chunk.log-rx {
    color: #7ee787;
}

.serial-terminal-page .log-line.log-tx {
    color: #79c0ff;
}

.serial-terminal-page .log-line.log-tx::before {
    content: "→ ";
}

.serial-terminal-page .log-line.log-sys {
    color: #d2a8ff;
    font-style: italic;
}

.serial-terminal-page .log-line.log-sys::before {
    content: "● ";
}

/* Scale test — live weight card (compact) */
.scale-terminal-page .scale-live-weight-card {
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

.scale-terminal-page .scale-live-weight-card .card-header {
    border-bottom: none;
}

.scale-terminal-page .scale-live-body {
    padding: 0.85rem 1rem 1rem;
}

.scale-terminal-page .scale-live-flags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
}

.scale-terminal-page .scale-flag {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2rem 0.45rem;
    border-radius: 0.25rem;
    border: 1px solid var(--bs-border-color);
    color: var(--bs-secondary-color);
    background: var(--bs-body-bg);
    opacity: 0.45;
}

.scale-terminal-page .scale-flag.is-on {
    opacity: 1;
    border-color: transparent;
}

.scale-terminal-page .scale-flag[data-flag='stable'].is-on {
    background: #238636;
    color: #fff;
}

.scale-terminal-page .scale-flag[data-flag='unstable'].is-on,
.scale-terminal-page .scale-flag[data-flag='motion'].is-on {
    background: #9e6a03;
    color: #fff;
}

.scale-terminal-page .scale-flag[data-flag='negative'].is-on,
.scale-terminal-page .scale-flag[data-flag='underweight'].is-on,
.scale-terminal-page .scale-flag[data-flag='negTareEmpty'].is-on,
.scale-terminal-page .scale-flag[data-flag='outOfRange'].is-on {
    background: #da3633;
    color: #fff;
}

.scale-terminal-page .scale-flag[data-flag='gross'].is-on,
.scale-terminal-page .scale-flag[data-flag='net'].is-on {
    background: #1f6feb;
    color: #fff;
}

.scale-terminal-page .scale-flag[data-flag='tare'].is-on {
    background: #6e40c9;
    color: #fff;
}

.scale-terminal-page .scale-live-net {
    font-size: clamp(3.25rem, 14vw, 6rem);
    line-height: 1;
    letter-spacing: 0.02em;
    margin: 0.15rem 0 0.35rem;
}

.scale-terminal-page .scale-live-tare-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.15rem;
}

.scale-terminal-page .scale-live-tare-label {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.scale-terminal-page .scale-live-tare-value {
    font-size: clamp(1.35rem, 5vw, 2rem);
    font-weight: 600;
}

.scale-terminal-page #simString {
    min-height: 100px;
}

/* Highlight control tags inside lines */
.serial-terminal-page .log-line,
.serial-terminal-page .log-chunk {
    font-variant-ligatures: none;
}

/* RAG chat */
.chat-card {
    min-height: 70vh;
}

.chat-messages {
    flex: 1;
    min-height: 50vh;
    max-height: 65vh;
    overflow-y: auto;
    background: #f1f3f5;
}

.chat-bubble {
    max-width: 92%;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
}

.chat-user {
    margin-left: auto;
    background: #cfe2ff;
}

.chat-assistant {
    margin-right: auto;
    background: #fff;
    border: 1px solid #dee2e6;
}

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.rag-debug-pre {
    max-height: 42vh;
    overflow: auto;
    background: #0d1117;
    color: #c9d1d9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.45;
}

#touchCanvas {
    touch-action: none;
    display: block;
}

.touch-max-input {
    max-width: 5.5rem;
    min-width: 4.25rem;
}
