/* Shared dialog rules: Story information surfaces, Profile fields, Model tabs. */
.chat-tool-button { width: 40px; height: 40px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 50%; color: var(--text-secondary); background: transparent; }
.chat-tool-button:hover, .chat-tool-button[aria-expanded="true"] { background: rgb(255 255 255 / 6%); color: var(--text); }
.chat-tool-button:disabled { opacity: .35; cursor: default; }
.chat-tools-dialog { --tool-line: rgb(255 255 255 / 8%); --tool-fill: rgb(255 255 255 / 5%); box-sizing: border-box; width: min(720px, calc(100vw - 64px)); height: min(800px, calc(100dvh - 64px)); max-height: none; overflow: clip; padding: 0; border: 1px solid var(--tool-line); border-radius: 18px; background: #1c1a20; color: var(--text); box-shadow: 0 30px 100px rgb(0 0 0 / 45%); }
.chat-tools-dialog.inspector { width: min(1040px, calc(100vw - 64px)); }
.chat-tools-dialog::backdrop { background: rgb(6 5 9 / 78%); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chat-tools-dialog [hidden], .chat-tools-toast[hidden] { display: none !important; }
.chat-tools-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-tools-header, .chat-tools-navigation, .chat-tools-footer, .chat-inspector-source { flex-shrink: 0; }
.chat-tools-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--tool-line); }
.chat-tools-header h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.chat-tools-close, .chat-tools-icon { display: inline-grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); }
.chat-tools-icon > img { opacity: .65; }
.chat-tools-close:hover, .chat-tools-icon:hover:not(:disabled), .chat-tools-icon[aria-expanded="true"] { background: rgb(255 255 255 / 7%); color: var(--text); }
.chat-tools-icon:hover > img { opacity: 1; }
.chat-tools-icon:disabled { opacity: .3; cursor: default; }
.chat-tools-dialog button { transition: background .15s, color .15s; }
.chat-tools-dialog button:active:not(:disabled) { transform: scale(.98); }
.chat-tools-dialog button:focus-visible { outline: 2px solid rgb(255 255 255 / 50%); outline-offset: 2px; }
.chat-tools-navigation { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--tool-line); }
.chat-tools-tabs { display: inline-flex; gap: 4px; width: fit-content; padding: 4px; border: 1px solid var(--tool-line); border-radius: 999px; background: rgb(255 255 255 / 3%); }
.chat-tools-tab { padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--text-secondary); font: 600 12px/1.3 var(--font-ui); white-space: nowrap; }
.chat-tools-tab:hover { color: var(--text); }
.chat-tools-tab[aria-selected="true"] { background: rgb(255 255 255 / 12%); color: #fff; }
.chat-tools-toolbar { display: flex; align-items: center; gap: 4px; }
.chat-tools-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 24px; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 16%) transparent; }
.chat-tools-body[aria-busy="true"] { opacity: .5; pointer-events: none; }
.chat-tools-panel { display: grid; gap: 20px; }
.chat-tools-field { display: grid; gap: 8px; }
.chat-tools-field > label { color: var(--text-secondary); font-size: 12px; }
.chat-tools-field input, .chat-tools-field textarea { box-sizing: border-box; width: 100%; padding: 11px 13px; border: 1px solid rgb(255 255 255 / 10%); border-radius: 10px; color: var(--text); background: rgb(0 0 0 / 22%); font: 14px/1.7 var(--font-ui); }
.chat-tools-field input { height: 44px; }
.chat-tools-field textarea { min-height: 200px; resize: vertical; }
.chat-tools-field textarea::placeholder { color: var(--text-muted); opacity: .7; }
.chat-tools-field input:focus, .chat-tools-field textarea:focus { outline: none; border-color: rgb(255 255 255 / 30%); }
.chat-tools-count { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chat-tools-count.is-over-limit { color: #efa6b5; }
.player-settings-panel #session-player-details { min-height: 240px; }
.single-field-panel { height: 100%; }
.single-field-panel > .chat-tools-field { grid-template-rows: auto minmax(200px, 1fr) auto; }
.single-field-panel textarea { height: 100%; resize: none; }
.chat-tools-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--tool-line); }
.chat-tools-action { min-height: 36px; padding: 8px 16px; border: 0; border-radius: 999px; background: rgb(255 255 255 / 7%); color: var(--text); font: 600 12px/1.5 var(--font-ui); }
.chat-tools-action:hover:not(:disabled) { background: rgb(255 255 255 / 12%); }
.chat-tools-action.primary { background: #fff; color: #151515; }
.chat-tools-action.primary:hover:not(:disabled) { background: #e4e2e8; }
.chat-tools-footer .chat-tools-action { min-width: 100px; height: 40px; font-size: 13px; }
.chat-tools-action:disabled { opacity: .4; cursor: default; }
.chat-tools-text-action { padding-inline: 0; background: transparent; color: var(--text-secondary); }
.chat-tools-text-action:hover:not(:disabled) { background: transparent; color: var(--text); }
.chat-tools-status { display: inline-flex; align-items: center; width: fit-content; padding: 3px 8px; border-radius: 6px; background: var(--tool-fill); color: var(--text-secondary); font-size: 10px; line-height: 1.5; white-space: nowrap; }
.chat-tools-status[data-mode="draft"], .chat-tools-status[data-mode="restoring"] { color: var(--text); }
.chat-tools-error { margin: 16px 0 0; padding: 12px 14px; border: 1px solid rgb(239 166 181 / 25%); border-radius: 10px; color: #efa6b5; font-size: 12px; }
.chat-tools-empty { display: grid; place-items: center; min-height: 230px; margin: 0; color: var(--text-muted); font-size: 13px; }
.chat-tools-empty.compact { min-height: 60px; }
.chat-tools-toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%); margin: 0; padding: 13px 22px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 12px; color: var(--text); background: #29262e; box-shadow: 0 12px 40px rgb(0 0 0 / 30%); font-size: 13px; }

/* Memory: category, current value, optional history. */
.chat-tools-panel.memory-manager { gap: 12px; }
.memory-manager-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.memory-category-tabs { display: flex; gap: 3px; }
.memory-category-tab { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 8px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font: 600 12px/1.3 var(--font-ui); white-space: nowrap; }
.memory-category-tab[aria-selected="true"] { background: rgb(255 255 255 / 9%); color: #fff; }
.memory-category-tab:hover { color: #fff; }
.memory-category-count { padding: 1px 5px; border-radius: 4px; background: rgb(255 255 255 / 5%); font-size: 10px; font-variant-numeric: tabular-nums; }
.memory-coverage { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.memory-coverage progress { flex: 1; width: 0; height: 3px; border: 0; border-radius: 4px; background: var(--tool-fill); color: rgb(255 255 255 / 30%); appearance: none; overflow: hidden; }
.memory-coverage progress::-webkit-progress-bar { background: var(--tool-fill); }
.memory-coverage progress::-webkit-progress-value { background: rgb(255 255 255 / 30%); }
.memory-coverage progress::-moz-progress-bar { background: rgb(255 255 255 / 30%); }
.memory-category-panel { display: grid; gap: 10px; }
.memory-category-context { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.memory-field { gap: 6px; }
.memory-field textarea { height: 160px; min-height: 160px; }
.memory-current-content { margin: 0; padding: 14px; border: 1px solid var(--tool-line); border-radius: 10px; max-height: 280px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-secondary); font: 13px/1.8 var(--font-ui); }
.memory-current-content.is-empty { color: var(--text-muted); }
.memory-manual-entries, .memory-manual-entry { display: grid; gap: 14px; }
.memory-manual-entry { border-top: 1px solid var(--tool-line); padding-top: 12px; }
.memory-manual-entry textarea { min-height: 140px; }
.chat-tools-history details > summary, .memory-summary-tasks > summary, .memory-task > summary { display: flex; align-items: center; gap: 10px; min-height: 36px; list-style: none; cursor: pointer; }
.chat-tools-history summary::-webkit-details-marker, .memory-summary-tasks summary::-webkit-details-marker { display: none; }
.disclosure-label { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 12px; }
.disclosure-value { color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.disclosure-chevron { flex: 0 0 14px; opacity: .5; transition: transform .15s; }
.chat-tools-dialog details[open] > summary > .disclosure-chevron { transform: rotate(180deg); }
.memory-version-list, .memory-summary-tasks { border-top: 1px solid var(--tool-line); }
.memory-version, .memory-task { padding: 0 12px 10px; border-top: 1px solid var(--tool-line); }
.memory-version pre { margin: 10px 0; padding: 12px; max-height: 220px; overflow-y: auto; border-radius: 8px; background: rgb(0 0 0 / 18%); color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.8 var(--font-ui); }
.memory-record-date { margin: 6px 0; color: var(--text-muted); font-size: 10px; }
.memory-job-error { margin: 8px 0; color: #efa6b5; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.memory-summary-tasks > .chat-tools-action { margin-block: 8px; }
.memory-summary-tasks > .chat-tools-text-action { font-size: 11px; }
.chat-tools-icon.is-loading > img { animation: tool-refresh 1.2s linear infinite; }
@keyframes tool-refresh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chat-tools-icon.is-loading > img { animation: none; } }

/* Inspector: the content is primary; diagnostics open on demand. */
.chat-inspector-source { display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 12px; align-items: center; padding: 16px 24px 0; }
.chat-inspector-source > label { min-width: 0; }
.chat-inspector-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 14px; color: var(--text-muted); font-size: 11px; }
.chat-inspector-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0 0 16px; padding: 16px; border: 1px solid var(--tool-line); border-radius: 10px; background: rgb(0 0 0 / 12%); }
.chat-inspector-details dt { margin-bottom: 4px; color: var(--text-muted); font-size: 10px; }
.chat-inspector-details dd { margin: 0; color: var(--text-secondary); font-size: 12px; overflow-wrap: anywhere; }
.chat-inspector-details .chat-tools-error { grid-column: 1 / -1; }
.chat-inspector-code { margin: 0; padding: 18px; border: 1px solid rgb(255 255 255 / 6%); border-radius: 10px; background: rgb(0 0 0 / 18%); color: #d6d2da; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; font: 12px/1.9 ui-monospace, SFMono-Regular, monospace; }
.chat-inspector-keyword { padding-bottom: 18px; border-bottom: 1px solid var(--tool-line); }
.chat-inspector-keyword:last-child { border-bottom: 0; }
.chat-inspector-keyword header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.chat-inspector-keyword h3 { margin: 0; font-size: 14px; font-weight: 600; }
.chat-inspector-triggers { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-inspector-triggers span, .chat-inspector-command code { padding: 3px 7px; border-radius: 5px; background: var(--tool-fill); color: var(--text-secondary); font-size: 10px; }
.chat-inspector-keyword pre { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-secondary); font: 13px/1.8 var(--font-ui); }
.chat-inspector-command { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 11px; }

.memory-current-entries { display: grid; gap: 18px; }
.memory-summary-entry { padding: 14px 0; border-top: 1px solid var(--tool-line); }
.memory-summary-entry:first-child { border-top: 0; padding-top: 0; }
.memory-entry-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.memory-entry-heading h3 { margin: 0; font-size: 14px; line-height: 1.6; font-weight: 600; overflow-wrap: anywhere; }
.memory-entry-heading .chat-tools-action { flex-shrink: 0; padding: 5px 8px; font-size: 11px; }
.memory-summary-content { margin: 0 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-secondary); font-size: 13px; line-height: 1.8; }
.memory-entry-actions { display: flex; gap: 10px; margin-top: 12px; }
.memory-summary-entry .chat-tools-field { margin-top: 12px; }
@media (max-width: 600px) { .memory-entry-heading { flex-wrap: wrap; gap: 8px; } }
