/* Context and approval settings use form styles rather than the code editor. */
#runtime-settings-modal { padding: 20px; box-sizing: border-box; }
#runtime-settings-modal .runtime-settings-dialog {
    width: 640px; max-width: 100%; max-height: min(840px, calc(100dvh - 40px));
    overflow: hidden; background:#fff; color: #1f2937; font-family: system-ui, -apple-system, sans-serif;
    border: 1px solid #e5e7eb; border-radius: 16px;
}
.runtime-settings-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; padding: 24px 28px 20px; flex-shrink: 0;
}
.runtime-settings-header h2 { margin: 0; font-size: 20px; font-weight: 650; line-height: 1.4; letter-spacing: -0.4px; }
.runtime-settings-header p, .runtime-settings-toggle-row p, .runtime-settings-section-intro p {
    margin: 5px 0 0; font-size: 12px; color: #6b7280; line-height: 1.6;
}
.runtime-settings-close {
    width: 30px; height: 30px; flex-shrink: 0; border: 0; border-radius: 7px;
    background: transparent; color: #6b7280; font-size: 24px; cursor: pointer; line-height: 1;
}
.runtime-settings-close:hover { background: #f3f4f6; color: #111827; }
.runtime-settings-scope-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    margin: 0 28px 18px; font-size: 12px;
}
.runtime-settings-scope-row > span { color: #9ca3af; font-size: 11px; }
.runtime-settings-scope-row .runtime-settings-input { width: auto; min-height: 34px; padding: 5px 28px 5px 10px; font-size: 12px; }
.runtime-settings-tabs { display: flex; gap: 24px; padding: 0 28px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.runtime-settings-tabs button {
    background: transparent; border: 0; border-bottom: 2px solid transparent;
    padding: 0 0 12px; margin-bottom: -1px; font: inherit; font-size: 13px;
    font-weight: 600; color: #6b7280; cursor: pointer;
}
.runtime-settings-tabs button[aria-selected="true"] { color: #2563eb; border-bottom-color: #2563eb; }
.runtime-settings-tabs button:hover { color: #1d4ed8; }
.runtime-settings-body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 28px; scrollbar-width: thin; }
.runtime-settings-body section[hidden] { display: none; }
.runtime-settings-capacity { margin-bottom: 22px; }
#tool-list { display: block; }
.tool-category { width: 100%; border-bottom: 1px solid #e5e7eb; padding: 10px 0; }
.tool-category:last-child { border-bottom: 0; }
.tool-category-heading { cursor: pointer; color: #475569; font-size: 12px; font-weight: 600; }
.tool-category-heading small { float: right; font-size: 10px; color: #94a3b8; font-weight: 400; }
.tool-category-items { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 2px; }
.tool-category-items button { font-family: inherit; }
.runtime-context-usage { margin: 0 0 22px; padding: 15px 16px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; }
.runtime-context-usage-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: #475569; }
.runtime-context-usage-heading strong { color: #2563eb; font-size: 15px; }
.runtime-context-usage-count { margin: 6px 0 12px; color: #64748b; font-size: 11px; font-variant-numeric: tabular-nums; }
.runtime-context-usage-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #e2e8f0; }
.runtime-context-usage-bar > span { flex-shrink: 0; height: 100%; }
.runtime-context-usage-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 10px; color: #64748b; }
.runtime-context-usage-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.runtime-context-usage-legend i { width: 7px; height: 7px; border-radius: 2px; }
.runtime-context-usage-legend b { font-weight: 500; }
.runtime-context-usage small { display: block; margin-top: 8px; color: #94a3b8; font-size: 10px; }
.runtime-settings-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.runtime-settings-toggle-row h3, .runtime-settings-section-intro h3 { margin: 0; font-size: 14px; font-weight: 600; }
.runtime-settings-section-intro { margin-bottom: 22px; }
.runtime-settings-switch { position: relative; display: inline-flex; width: 36px; height: 22px; flex-shrink: 0; }
.runtime-settings-switch input { position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.runtime-settings-switch span { width: 100%; height: 100%; border-radius: 20px; background: #d1d5db; transition: background 0.15s; }
.runtime-settings-switch span::before { content: ''; display: block; width: 16px; height: 16px; margin: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0002; transition: transform 0.15s; }
.runtime-settings-switch input:checked + span { background: #2563eb; }
.runtime-settings-switch input:checked + span::before { transform: translateX(14px); }
.runtime-settings-switch input:focus-visible + span { outline: 2px solid #2563eb; outline-offset: 3px; }
.runtime-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; margin-bottom: 22px; }
.runtime-settings-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; }
.runtime-settings-field > span { font-size: 12px; font-weight: 500; line-height: 1.5; }
.runtime-settings-field small { color: #9ca3af; font-size: 11px; line-height: 1.5; }
.runtime-settings-input {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 38px; padding: 8px 11px;
    border: 1px solid #d1d5db; border-radius: 7px; background: #fff; color: #374151;
    font: inherit; font-size: 13px; line-height: 1.5; transition: border-color 0.15s;
}
.runtime-settings-input::placeholder { color: #9ca3af; font-size: 12px; }
.runtime-settings-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px #2563eb12; }
.runtime-settings-textarea { min-height: 82px; resize: vertical; max-height: 240px; }
.runtime-settings-note { padding: 12px 14px; margin: 12px 0 22px; background: #f8fafc; border-radius: 8px; color: #64748b; font-size: 12px; line-height: 1.7; }
.runtime-settings-advanced { margin-top: 24px; border-top: 1px solid #e5e7eb; }
.runtime-settings-advanced > summary { padding: 16px 0 0; cursor: pointer; color: #4b5563; font-size: 12px; }
.runtime-settings-advanced > summary > span { margin-left: 10px; color: #9ca3af; font-size: 11px; }
.runtime-settings-advanced-body { padding: 18px 0 0; }
.runtime-settings-advanced-body > .runtime-settings-grid { margin: 18px 0 0; }
.runtime-settings-advanced-body.runtime-settings-grid { margin-bottom: 0; }
.runtime-settings-footer { flex-shrink: 0; padding: 14px 28px 18px; border-top: 1px solid #e5e7eb; background: #fff; }
#runtime-settings-result { font-size: 11px; color: #6b7280; line-height: 1.5; overflow-wrap: anywhere; }
#runtime-settings-result:not(:empty) { margin-bottom: 12px; }
.remembered-grant { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:12px 0; border-bottom:1px solid #e5e7eb; font-size:12px; }
.remembered-grant>div { min-width:0; flex:1; }
.remembered-grant p { margin:5px 0 0; color:#64748b; overflow-wrap:anywhere; }
.remembered-grant button { flex-shrink:0; }
.remembered-grant pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:180px; overflow:auto; padding:10px; background:#f8fafc; border-radius:8px; font-size:11px; }
.remembered-grant summary { cursor:pointer; margin-top:6px; color:#64748b; }
.remembered-inactive { display:block; margin-top:4px; color:#9ca3af; }
.remembered-add { margin-top:16px; padding:12px; border:1px solid #e5e7eb; border-radius:10px; }
.remembered-add>summary { font-size:12px; font-weight:600; cursor:pointer; }
.remembered-add form,.remembered-add [data-tool-fields] { display:grid; gap:12px; padding-top:12px; min-width:0; }
.remembered-add form>button { justify-self:start; }
.remembered-add [hidden],.remembered-permissions [hidden] { display:none!important; }
.remembered-empty,.remembered-status,.remembered-strict-note { font-size:12px; line-height:1.6; color:#64748b; overflow-wrap:anywhere; }
.remembered-strict-note { padding:10px 12px; border-radius:8px; background:#f8fafc; }
.runtime-settings-footer-actions { display: flex; justify-content: flex-end; gap: 10px; }
.runtime-settings-btn { padding: 8px 15px; border: 1px solid transparent; border-radius: 7px; font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.runtime-settings-btn-primary { background: #2563eb; color: white; }
.runtime-settings-btn-primary:hover { background: #1d4ed8; }
.runtime-settings-btn-secondary { background: white; color: #6b7280; border-color: #e5e7eb; }
.runtime-settings-btn-secondary:hover { background: #f9fafb; color: #374151; }
.runtime-settings-btn:disabled { opacity: 0.5; cursor: default; }
#runtime-settings-modal button:focus-visible, #runtime-settings-modal summary:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
@media (max-width: 540px) {
    #runtime-settings-modal { padding: 12px; }
    #runtime-settings-modal .runtime-settings-dialog { max-height: calc(100dvh - 24px); border-radius: 12px; }
    .runtime-settings-header { padding: 20px; }
    .runtime-settings-header h2 { font-size: 18px; }
    .runtime-settings-scope-row { margin: 0 20px 16px; }
    .runtime-settings-scope-row > span { flex-basis: 100%; }
    .runtime-settings-tabs { padding: 0 20px; }
    .runtime-settings-body { padding: 20px; }
    .runtime-settings-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .runtime-settings-toggle-row { gap: 12px; }
    .runtime-settings-advanced > summary > span { display: none; }
    .runtime-settings-footer { padding: 14px 20px; }
}
@keyframes settingsSlideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

#runtime-settings-modal { position:fixed; inset:0; z-index:14000; background:rgba(20,28,40,.35); align-items:center; justify-content:center; transform:none; }
#runtime-settings-modal .runtime-settings-dialog { display:flex; flex:0 1 auto; flex-direction:column; background:var(--ui-surface); }
#runtime-settings-modal .runtime-settings-body { min-height:0; overflow-x:hidden; }
#agent-settings-sheet-overlay { z-index:10020; }
#agent-settings-sheet { z-index:10021; }
#agent-settings-sheet .tc-sheet-body input, #agent-settings-sheet .tc-sheet-body textarea { width:100%; min-width:0; padding:12px; border:1px solid var(--border); border-radius:10px; font:inherit; }
#agent-settings-sheet .tc-sheet-body>label { margin-top:8px; font-size:13px; color:var(--text-secondary); }
#agent-settings-sheet #agent-native-settings { padding:12px; border:0; border-radius:10px; background:var(--ui-surface-2); color:var(--primary); font:inherit; }
#agent-detail-body .agent-detail-section { margin:10px 12px; border:0; border-radius:12px; }
#agent-detail-body .agent-detail-value { overflow-wrap:anywhere; }
#agent-history-body .ah-bubble.user { background:var(--ui-bubble-self); color:var(--text); }
#agent-history-body .ah-bubble { min-width:0; }
#agent-history-body .ah-system-context { padding:12px; margin-bottom:12px; border:1px solid var(--border); border-radius:10px; }
#agent-detail-overlay .agent-detail-header, #agent-history-overlay .agent-history-header { height:auto; min-height:48px; padding-top:env(safe-area-inset-top,0px); }
#agent-detail-body, #agent-history-body { padding-bottom:calc(16px + env(safe-area-inset-bottom,0px)); }
.ah-history-source { display:flex; align-items:center; gap:12px; padding:12px 16px; background:var(--bg-card); border-bottom:1px solid var(--border); flex-shrink:0; }
.ah-history-source select { min-height:36px; padding:6px; border:1px solid var(--border); border-radius:8px; color:var(--text); background:var(--bg-card); }
.ah-history-source span { color:var(--text-secondary); font-size:12px; line-height:1.5; min-width:0; }
