.tool-guard-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.tool-guard-page [hidden] { display: none !important; }
.tool-guard-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-width: 0;
}
.tool-guard-policy,
.tool-guard-policy-info,
.tool-guard-section-header,
.tool-guard-heading-line,
.tool-guard-rule-header,
.tool-guard-rule-actions,
.tool-guard-editor-footer {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tool-guard-policy,
.tool-guard-section-header,
.tool-guard-editor-footer { justify-content: space-between; }
.tool-guard-policy { padding: 18px 20px; }
.tool-guard-policy-info { min-width: 0; }
.tool-guard-policy-copy h3,
.tool-guard-section-header h3 { font-size: 15px; margin: 0; }
.tool-guard-policy-copy p,
.tool-guard-section-header p,
.tool-guard-help-body,
.tool-guard-test-hint,
.tool-guard-empty {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.7;
}
.tool-guard-policy-copy p { margin: 3px 0 0; }
.tool-guard-policy-icon,
.tool-guard-test-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex-shrink: 0;
    color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 8%, transparent);
}
.tool-guard-policy-icon svg,
.tool-guard-test-icon svg { width: 21px; height: 21px; }
.tool-guard-policy:has(#tool-guard-enabled:not(:checked)) .tool-guard-policy-icon { color: var(--text-secondary); background: var(--bg-secondary); }
.tool-guard-section-header { margin-bottom: 16px; }
.tool-guard-section-header p { margin: 4px 0 0; }
.tool-guard-heading-line { gap: 10px; flex-wrap: wrap; }
.tool-guard-rule-count { font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.tool-guard-section-header > button { flex-shrink: 0; }
.tool-guard-add { display: inline-flex; align-items: center; gap: 5px; }
.tool-guard-add > span:first-child { font-size: 19px; line-height: 1; }
.tool-guard-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; flex-shrink: 0; white-space: nowrap; }
.tool-guard-page .tool-guard-switch input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 30px;
    height: 18px;
    min-width: 30px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--text-secondary);
    position: relative;
    cursor: pointer;
    margin: 0;
    transition: background .15s;
}
.tool-guard-page .tool-guard-switch input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s;
}
.tool-guard-page .tool-guard-switch input[type="checkbox"]:checked { background: var(--accent-color); border-color: var(--accent-color); }
.tool-guard-page .tool-guard-switch input[type="checkbox"]:checked::after { transform: translateX(12px); }
.tool-guard-page .tool-guard-switch input[type="checkbox"]::before { display: none; }
.tool-guard-rules { display: grid; gap: 8px; }
.tool-guard-rule { border-radius: 9px; border: 1px solid var(--border-color); min-width: 0; overflow: hidden; }
.tool-guard-rule:has(.tool-guard-rule-summary[aria-expanded="true"]) { border-color: color-mix(in srgb, var(--accent-color) 40%, var(--border-color)); }
.tool-guard-rule-header { gap: 8px; padding-right: 16px; min-width: 0; border-radius: 8px; transition: background-color .15s; }
.tool-guard-rule-header:hover,
.tool-guard-rule-header:has(> .tool-guard-rule-summary:focus-visible) { background: color-mix(in srgb, var(--accent-color) 5%, var(--card-bg)); }
.tool-guard-rule-header:has(> .tool-guard-rule-summary:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent-color); }
.tool-guard-rule.is-expanded .tool-guard-rule-header { border-radius: 8px 8px 0 0; }
.tool-guard-rule-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    padding: 14px 10px 14px 16px;
    text-align: left;
    cursor: pointer;
    font: inherit;
}
.tool-guard-rule-number { flex-shrink: 0; color: var(--text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }
.tool-guard-rule-overview { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.tool-guard-rule-name { color: var(--text-primary); font-weight: 600; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool-guard-rule-preview { color: var(--text-secondary); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool-guard-rule-badge { flex-shrink: 0; color: var(--accent-color); background: color-mix(in srgb, var(--accent-color) 8%, transparent); border-radius: 4px; padding: 2px 6px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.tool-guard-chevron { flex-shrink: 0; color: var(--text-secondary); font-size: 23px; font-weight: 400; line-height: 1; transition: transform .15s; }
.tool-guard-rule-summary[aria-expanded="true"] .tool-guard-chevron,
.tool-guard-help[open] > summary .tool-guard-chevron,
.tool-guard-test-panel[open] > summary .tool-guard-chevron { transform: rotate(90deg); }
.tool-guard-rule-editor { padding: 18px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); }
.tool-guard-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.tool-guard-editor-grid > .tool-guard-field--name { grid-column: 1 / -1; max-width: 480px; width: 100%; }
.tool-guard-editor-grid .tool-guard-field { margin: 0; }
.tool-guard-editor-grid textarea { flex: 1; min-height: 108px; }
.tool-guard-editor-footer { margin-top: 16px; }
.tool-guard-delete { color: var(--error-color); }
.tool-guard-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.tool-guard-field:last-child { margin-bottom: 0; }
.tool-guard-field label { font-size: 12px; font-weight: 500; }
.tool-guard-field-hint { color: var(--text-secondary); font-size: 11px; line-height: 1.6; }
.tool-guard-field input,
.tool-guard-field textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    line-height: 1.6;
}
.tool-guard-field textarea { resize: vertical; min-height: 66px; }
.tool-guard-field [aria-invalid="true"] { border-color: var(--error-color); }
.tool-guard-page :is(button, input, textarea, summary):focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.tool-guard-page .tool-guard-rule-summary:focus-visible { outline: none; }
.tool-guard-field .tool-guard-pattern,
#tool-guard-test-arguments,
.tool-guard-test-arguments,
.tool-guard-result-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tool-guard-page :is(button, input, textarea):disabled { opacity: .55; cursor: not-allowed; }
.tool-guard-save-state { font-size: 12px; color: var(--text-secondary); }
.tool-guard-save-state.is-dirty { color: var(--accent-color); }
.tool-guard-feedback,
.tool-guard-test-result { padding: 14px 16px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid var(--border-color); font-size: 13px; overflow-wrap: anywhere; }
.tool-guard-feedback.is-error,
.tool-guard-test-result.is-blocked { border-color: var(--error-color); }
.tool-guard-feedback.is-error,
.tool-guard-test-result.is-blocked > strong { color: var(--error-color); }
.tool-guard-result-label { margin-top: 12px; margin-bottom: 4px; color: var(--text-secondary); font-size: 12px; }
.tool-guard-result-value { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow-y: auto; font-size: 13px; }
.tool-guard-help { border-top: 1px solid var(--border-color); margin-top: 16px; padding-top: 12px; }
.tool-guard-help > summary,
.tool-guard-test-panel > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; }
.tool-guard-help > summary::-webkit-details-marker,
.tool-guard-test-panel > summary::-webkit-details-marker { display: none; }
.tool-guard-help > summary { color: var(--text-secondary); width: fit-content; font-size: 12px; }
.tool-guard-help > summary .tool-guard-chevron { font-size: 18px; }
.tool-guard-help-body { margin-top: 10px; }
.tool-guard-help-body p + p { margin-top: 6px; }
.tool-guard-test-panel { padding: 0; scroll-margin-top: 80px; }
.tool-guard-test-panel > summary { padding: 18px 20px; border-radius: 12px; }
.tool-guard-test-panel > summary:hover { background: var(--bg-secondary); }
.tool-guard-disclosure-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.tool-guard-disclosure-copy strong { font-size: 14px; font-weight: 600; }
.tool-guard-disclosure-copy > span { color: var(--text-secondary); font-size: 12px; }
.tool-guard-test-icon { color: var(--text-secondary); background: var(--bg-secondary); }
.tool-guard-test-body { padding: 18px 20px 20px; border-top: 1px solid var(--border-color); }
.tool-guard-test-hint { margin-bottom: 14px; }
.tool-guard-test-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.tool-guard-editor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-guard-rule-validate { color: var(--accent-color); }
.tool-guard-test-result.is-single.is-blocked { border-color: var(--accent-color); }
.tool-guard-test-result.is-single.is-blocked > strong { color: var(--accent-color); }
.tool-guard-single-result-hint { color: var(--text-secondary); font-size: 12px; line-height: 1.6; margin-top: 8px; }
.tool-guard-hint { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.7; }
.tool-guard-inline-test { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-color); scroll-margin-top: 90px; }
.tool-guard-local-test { padding: 18px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; min-width: 0; }
.tool-guard-local-test h4 { margin: 0; font-size: 14px; font-weight: 600; }
.tool-guard-local-test > .tool-guard-hint { margin: 5px 0 16px; }
.tool-guard-local-output { margin-top: 14px; min-width: 0; }
.tool-guard-test-placeholder { padding: 16px; color: var(--text-secondary); font-size: 12px; line-height: 1.7; }
.tool-guard-test-run { min-width: 120px; }
.tool-guard-local-test .tool-guard-test-arguments { min-height: 108px; }
.tool-guard-add-dialog {
    width: min(1040px, calc(100vw - 40px));
    max-width: none;
    height: min(90vh, 900px);
    height: min(90dvh, 900px);
    max-height: min(90vh, 900px);
    max-height: min(90dvh, 900px);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
}
.tool-guard-add-dialog::backdrop { background: rgba(5, 10, 20, .58); }
.tool-guard-add-dialog > form { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.tool-guard-add-header,
.tool-guard-add-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 24px; flex-shrink: 0; }
.tool-guard-add-header { border-bottom: 1px solid var(--border-color); align-items: flex-start; }
.tool-guard-add-header h3 { margin: 0 0 5px; font-size: 18px; line-height: 1.5; }
.tool-guard-dialog-close { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.tool-guard-dialog-close:hover { background: var(--bg-secondary); color: var(--text-primary); }
.tool-guard-dialog-close svg { width: 20px; height: 20px; }
.tool-guard-add-body { display: grid; flex: 1; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; align-content: start; gap: 20px 24px; padding: 24px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; min-height: 0; }
.tool-guard-add-fields { min-width: 0; }
.tool-guard-add-fields .tool-guard-field { margin-bottom: 20px; }
.tool-guard-add-fields .tool-guard-field:last-child { margin-bottom: 0; }
.tool-guard-add-fields textarea { min-height: 116px; }
.tool-guard-add-test { padding: 18px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-secondary); min-width: 0; }
.tool-guard-add-test .tool-guard-local-test { padding: 0; border: 0; background: transparent; }
.tool-guard-add-test .tool-guard-local-output { min-height: 180px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--card-bg); }
.tool-guard-add-test .tool-guard-local-output:has(.is-single.is-blocked:not([hidden])) { border-color: var(--accent-color); }
.tool-guard-add-test .tool-guard-local-output:has(.is-error:not([hidden])) { border-color: var(--error-color); }
.tool-guard-add-test .tool-guard-result-value { max-height: none; overflow: visible; }
.tool-guard-add-test .tool-guard-test-result,
.tool-guard-add-test .tool-guard-feedback { border: 0; background: transparent; }
#tool-guard-add-feedback { grid-column: 1 / -1; }
.tool-guard-add-footer { border-top: 1px solid var(--border-color); }
.tool-guard-add-footer > .tool-guard-hint { max-width: 540px; }
.tool-guard-dialog-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

@media (max-width: 760px) {
    .tool-guard-card { padding: 16px; }
    .tool-guard-policy { flex-wrap: wrap; }
    .tool-guard-section-header { align-items: flex-start; flex-wrap: wrap; }
    .tool-guard-page .page-header { flex-wrap: wrap; gap: 12px; }
    .tool-guard-rule-header { padding-right: 10px; gap: 4px; }
    .tool-guard-rule-summary { padding: 12px 8px 12px 10px; gap: 8px; }
    .tool-guard-rule-number { display: none; }
    .tool-guard-rule-actions { gap: 6px; }
    .tool-guard-rule-actions .tool-guard-toggle > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .tool-guard-editor-grid { grid-template-columns: minmax(0, 1fr); }
    .tool-guard-editor-footer { flex-wrap: wrap; }
    .tool-guard-editor-grid > .tool-guard-field--name { max-width: none; }
    .tool-guard-rule-editor { padding: 14px; }
    .tool-guard-rule-badge { padding: 2px 4px; font-size: 10px; }
    .tool-guard-test-panel { padding: 0; }
    .tool-guard-test-panel > summary,
    .tool-guard-test-body { padding: 16px; }
    .tool-guard-add-dialog { width: calc(100vw - 24px); height: calc(100vh - 24px); height: calc(100dvh - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 12px; }
    .tool-guard-add-header,
    .tool-guard-add-footer { padding: 16px; gap: 12px; }
    .tool-guard-add-header h3 { font-size: 16px; }
    .tool-guard-add-body { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 20px; }
    .tool-guard-add-test,
    .tool-guard-local-test { padding: 14px; }
    .tool-guard-add-footer { flex-wrap: wrap; }
    .tool-guard-dialog-actions { width: 100%; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
    .tool-guard-rule-header,
    .tool-guard-chevron,
    .tool-guard-page .tool-guard-switch input[type="checkbox"],
    .tool-guard-page .tool-guard-switch input[type="checkbox"]::after { transition: none; }
}
