.km-workspace { width: 100%; color: var(--ink); }
.km-workspace [hidden] { display: none !important; }
.km-load-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.km-workspace .tool-panel { background: #fff; border: 1px solid var(--line); }
.km-workspace .km-main-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.km-input-panel { grid-column: 1; grid-row: 1; min-height: 320px; display: flex; flex-direction: column; }
.km-input-panel #kmForm { display: flex; flex-direction: column; flex: 1; min-height: 250px; }
.km-input-panel #kmForm > .action-row { margin-top: auto; padding-top: 18px; }
.km-result-panel { grid-column: 2; grid-row: 1; }
.km-result-footer { grid-column: 2; min-width: 0; }
.km-workspace input { width: 100%; max-width: 100%; font-family: inherit; }
.km-workspace input[type="text"] { border: 1px solid var(--line); border-radius: var(--radius); background: #fbfdff; color: var(--ink); outline: 0; padding: 0 12px; }
.km-workspace input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230, 126, 34, .16); }
.km-workspace .field-label { display: block; margin: 16px 0 8px; font-size: 14px; }
.km-workspace .field-label:first-child { margin-top: 0; }
.km-workspace .km-character-input { font-size: 24px; height: 58px; letter-spacing: 0; }
.km-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; min-width: 0; margin: 0 0 18px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #f6f7f7; }
.km-modes, .km-input-panel #kmForm > .action-row { flex-shrink: 0; }
.km-mode-option { position: relative; min-width: 0; cursor: pointer; }
.km-mode-option input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.km-mode-option span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px; border-radius: 4px; font-size: 14px; color: var(--muted); }
.km-mode-option input:checked + span { color: var(--brand-brown); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 700; }
.km-mode-option input:focus-visible + span { outline: 3px solid #0f766e; outline-offset: 2px; }
.km-muted { color: var(--muted); font-size: 12px; line-height: 1.7; }
.km-workspace .field-error { margin: 8px 0; }
.km-result-panel .tool-result-signature { margin: 0 0 16px; flex-shrink: 0; }
.km-result-panel { position: relative; min-height: 250px; display: flex; flex-direction: column; }
.km-result-panel #kmEmpty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 48px 20px; border: 0; border-radius: 0; background: transparent; pointer-events: none; }
.km-result-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; margin: 16px 0 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.km-lot-number { flex: 1 0 140px; font-size: 32px; font-weight: 800; margin: 0; color: var(--brand-brown); line-height: 1.4; }
.km-hexagram { display: flex; align-items: center; gap: 14px; min-width: 0; }
.km-trigram-labels { display: grid; gap: 12px; flex: 0 0 auto; }
.km-trigram-labels p { display: flex; align-items: baseline; gap: 8px; margin: 0; line-height: 1.2; }
.km-trigram-labels span { font-size: 12px; color: var(--muted); }
.km-trigram-labels strong { font-size: 20px; }
.km-hexagram-lines { display: flex; flex-direction: column; gap: 5px; width: 44px; flex: 0 0 44px; }
.km-hexagram-lines .km-yao:nth-child(4) { margin-top: 4px; }
.km-yao { display: flex; justify-content: space-between; height: 6px; flex: 0 0 6px; color: var(--brand-brown); }
.km-yao::before { content: ''; width: 100%; height: 100%; background: currentColor; }
.km-yao-yin::before, .km-yao-yin::after { content: ''; width: 42%; height: 100%; background: currentColor; }
.km-hexagram-name { max-width: 6em; margin: 0; font-size: 20px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
.km-poem { margin: 0 0 22px; font-size: 21px; font-weight: 700; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.km-disclaimer { margin: 22px 0 0; font-size: 12px; color: var(--muted); line-height: 1.8; }
.km-workspace .action-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 18px; }
.km-workspace #kmCalculate { width: 144px; min-width: 144px; flex: 0 0 144px; }
.km-result-footer .action-row { margin-top: 0; }
.km-result-footer .action-row[hidden] + .km-disclaimer { margin-top: 0; }
.km-history-panel { margin-top: 20px; }
.km-history-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.km-history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.km-history-item strong, .km-history-item p { overflow-wrap: anywhere; }
.km-history-item strong, .km-history-item small { display: block; }
.km-history-item p { margin: 5px 0; font-size: 13px; }
.km-history-buttons { display: flex; align-items: start; gap: 6px; }
.km-history-buttons .icon-button { flex: 0 0 36px; width: 36px; height: 36px; }
.km-action-status { margin: 12px 0; font-size: 13px; min-height: 21px; color: #0f6258; }
@media (max-width: 1100px) {
    .km-workspace .km-main-grid { grid-template-columns: minmax(0, 1fr); }
    .km-input-panel, .km-result-panel, .km-result-footer { grid-column: 1; grid-row: auto; }
}
@media (max-width: 460px) { .km-lot-number { font-size: 28px; } .km-history-item { grid-template-columns: minmax(0, 1fr); } .km-history-buttons { justify-content: flex-end; } }
