/* T-073 read-only history popup; all rules scoped to the sidecar. */
.history-dialog {
  box-sizing: border-box;
  width: min(960px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  height: min(740px, calc(100vh - 24px));
  height: min(740px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--panel-line, #245d3c);
  border-radius: 14px;
  background: var(--bg, #020604);
  color: var(--text, #d2f5df);
  font: 13px/1.5 var(--mono, ui-monospace, monospace);
  color-scheme: dark;
  box-shadow: 0 24px 100px #000b;
}
.history-dialog::backdrop { background: #000b; backdrop-filter: blur(5px); }
.history-dialog *, .history-dialog *::before, .history-dialog *::after { box-sizing: border-box; min-width: 0; }
.history-dialog [hidden] { display: none !important; }
.history-shell { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.history-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--panel-line, #245d3c); }
.history-header h2 { margin: 0; font: 700 22px/1.2 var(--hud, system-ui, sans-serif); }
.history-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); overflow: hidden; }
.history-sidebar { padding: 14px; overflow: auto; overscroll-behavior: contain; border-right: 1px solid var(--panel-line, #245d3c); }
.history-sidebar h3, .history-preview h3 { margin: 14px 0 10px; font-size: 14px; overflow-wrap: anywhere; }
.history-sidebar > .history-button { width: 100%; }
.history-sessions { display: grid; gap: 8px; }
.history-button {
  max-width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--panel-line, #245d3c);
  border-radius: 8px;
  background: var(--panel, #07170f);
  color: var(--text, #d2f5df);
  font: inherit;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.history-button:hover:not(:disabled), .history-button[aria-current="true"] { border-color: var(--cyan, #2bff88); background: #0b2b1b; }
.history-button[aria-current="true"] { box-shadow: inset 3px 0 var(--cyan, #2bff88); }
.history-button:disabled { opacity: .6; cursor: wait; }
.history-session { text-align: left; width: 100%; }
.history-dialog :focus-visible { outline: 2px solid var(--cyan, #2bff88); outline-offset: -3px; }
.history-preview { display: flex; flex-direction: column; min-height: 0; padding: 14px; overflow: auto; overscroll-behavior: contain; }
.history-preview > h3 { margin-top: 0; }
.history-notice, .history-status, .history-empty { margin: 8px 0; color: var(--text, #d2f5df); opacity: .8; overflow-wrap: anywhere; }
.history-notice:empty, .history-status:empty { display: none; }
.history-notice { font-size: 12px; }
.history-messages { flex: 1 0 120px; overflow-wrap: anywhere; }
.history-message { margin: 0 0 12px; padding: 12px; border: 1px solid var(--panel-line, #245d3c); border-radius: 10px; background: var(--panel, #07170f); }
.history-message-user { border-left: 3px solid var(--cyan, #2bff88); }
.history-role { margin: 0 0 6px; color: var(--cyan, #2bff88); font-size: 12px; }
.history-content { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-message-error { border-color: var(--red, #f87171); }
.history-message-error .history-role, .history-status.history-error { color: var(--red, #f87171); opacity: 1; }
.history-detail-action, .history-list-action { display: grid; gap: 8px; }
.history-preview > .history-button { flex-shrink: 0; margin-top: 10px; border-color: var(--cyan, #2bff88); }
.history-footer { flex-shrink: 0; padding: 10px 16px; border-top: 1px solid var(--panel-line, #245d3c); font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .history-header { padding: 12px; }
  .history-header h2 { font-size: 20px; }
  .history-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(100px, 32%) minmax(0, 1fr); }
  .history-sidebar { padding: 10px; border-right: 0; border-bottom: 1px solid var(--panel-line, #245d3c); }
  .history-preview { padding: 10px; }
  .history-footer { padding: 10px; }
}
