:root {
  color-scheme: light;
  --fallback-page-bg: #f5f6f7;
  --fallback-panel-bg: #ffffff;
  --fallback-panel-subtle: #eef1f3;
  --fallback-text: #172126;
  --fallback-muted: #617078;
  --fallback-border: #d7dfe2;
  --fallback-border-strong: #b8c4c8;
  --page-bg: var(--fallback-page-bg);
  --panel-bg: var(--fallback-panel-bg);
  --panel-subtle: var(--fallback-panel-subtle);
  --control-bg: var(--fallback-panel-bg);
  --text: var(--fallback-text);
  --muted: var(--fallback-muted);
  --border: var(--fallback-border);
  --border-strong: var(--fallback-border-strong);
  --accent-color: #167d80;
  --on-accent-color: #ffffff;
  --accent-soft: #e0f0ef;
  --danger: #b33f47;
  --danger-soft: #fae8e9;
  --warning-color: #c18400;
  --warning-error: #b42318;
  --shadow: 0 18px 60px rgba(20, 35, 40, 0.08);
  --small-shadow: 0 8px 28px rgba(20, 35, 40, 0.09);
  --accent-text-color: var(--accent-color-text, var(--accent-color));
  --accent-icon-shadow: none;
  --accent-transition: background-color 3333ms ease 0ms, border-color 3333ms ease 0ms, color 3333ms ease 0ms, fill 3333ms ease 0ms, stroke 3333ms ease 0ms;
  --font-micro: 0.6875rem;
  --font-supporting: 0.75rem;
  --font-base: 0.9375rem;
  --font-section: 1.125rem;
  --font-display: clamp(1.75rem, 3vw, 2.5rem);
  --icon-size-standard: 1rem;
  --icon-size-action: 1.25rem;
  --icon-size-prominent: 1.5rem;
  --radius: 18px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --host-safe-area-top: 0px;
  --host-safe-area-right: 0px;
  --host-safe-area-bottom: 0px;
  --host-safe-area-left: 0px;
}

/* Homepage streams its displayed accent across the full 3333ms timeline. Follow each host frame directly instead of restarting a second app transition. */
html[data-embed][data-host-context-ready="true"] {
  --accent-transition: background-color 0s linear 0ms, border-color 0s linear 0ms, color 0s linear 0ms, fill 0s linear 0ms, stroke 0s linear 0ms;
}

html[data-theme="dark"],
html[data-brightness="dark"] {
  color-scheme: dark;
  --page-bg: #101719;
  --panel-bg: #182124;
  --panel-subtle: #202c30;
  --control-bg: #182124;
  --text: #edf4f4;
  --muted: #a7b8ba;
  --border: #334449;
  --border-strong: #52666b;
  --accent-soft: #173b3d;
  --danger-soft: #44282b;
  --warning-color: #ffd65a;
  --warning-error: #ff8a80;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
  --small-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.ui-icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { display: block; width: 1.15em; height: 1.15em; flex: 0 0 auto; overflow: visible; color: var(--accent-text-color); transition: var(--accent-transition); }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--page-bg);
  font-family: var(--font-ui);
  font-size: var(--font-base);
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }

button, a, input, select, textarea, [role="option"], .reference-dropzone { transition: var(--accent-transition); }

a { color: inherit; text-underline-offset: 3px; }

button { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: 0.52; }

:focus-visible { outline: 3px solid var(--accent-color); outline-offset: 3px; }

#app-direct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
}

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--font-base); }
.breadcrumb a { text-decoration-color: transparent; }
.breadcrumb a:hover { text-decoration-color: currentColor; }

.logo-trigger { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 0; border-radius: 50%; color: var(--text); background: transparent; }
.logo-trigger:hover { background: var(--panel-subtle); }
#homepage-logo { display: block; width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent-color) 82%, transparent)); }

#app { min-height: 0; }

.app-shell { width: min(1240px, 100%); margin: 0 auto; padding: 50px clamp(18px, 4vw, 52px) 32px; }
.direct-intro { max-width: 780px; margin: 0 0 32px; }
.direct-intro h1 { max-width: 780px; margin: 4px 0 8px; font-size: var(--font-display); letter-spacing: -0.04em; line-height: 1.06; }
.direct-intro p:last-child,
.template-manager-lede { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.45; }
.api-key-requirement { display: inline; }
.direct-intro .intro-inline-link { min-height: 0; padding: 0; line-height: inherit; vertical-align: baseline; }
.eyebrow { margin: 0; color: var(--muted); font-size: var(--font-micro); font-weight: 720; letter-spacing: 0.12em; line-height: 1.2; text-transform: uppercase; }

.template-manager { width: min(1240px, 100%); margin: 0 auto; padding: 50px clamp(18px, 4vw, 52px) 32px; overflow-anchor: none; }
.template-manager-header { margin-bottom: 32px; }
.template-manager-header h1 { max-width: 780px; margin: 4px 0 8px; font-size: var(--font-display); letter-spacing: -0.04em; line-height: 1.06; }
.template-manager-title-row { display: flex; align-items: center; gap: 15px; }
.template-manager-title-row h1 { flex: 1 1 auto; }
.template-manager-storage-note { margin-top: 6px; }
.template-manager-close { flex: 0 0 auto; margin: 0; }
.template-manager-grid { display: grid; grid-template-areas: "catalog editor" "preview editor"; grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr); grid-template-rows: auto auto; gap: 22px; align-items: start; }
.template-manager-catalog { grid-area: catalog; }
.template-manager-editor { grid-area: editor; }
.template-manager-preview { grid-area: preview; min-width: 0; padding: clamp(20px, 3vw, 30px); }
.template-manager-preview .template-preview { border: 0; padding: 0; background: transparent; box-shadow: none; }
.template-manager-catalog, .template-manager-editor { padding: clamp(20px, 3vw, 30px); }
.template-manager-note { margin: 16px 0 0; color: var(--muted); font-size: var(--font-supporting); }
.template-manager .template-actions { justify-content: flex-start; align-items: center; gap: 12px; margin-top: 22px; }
.template-catalog-heading, .template-editor-heading { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.template-catalog-footer { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-top: 16px; }
.template-catalog-footer .template-manager-note { margin: 0; }
.template-catalog-footer-actions { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.template-catalog-heading h2, .template-editor-heading h2 { margin: 3px 0 0; font-size: var(--font-section); }
.template-preview-heading { margin-bottom: 16px; }
.template-preview-heading h2 { margin: 3px 0 0; font-size: var(--font-section); }
.template-manager-note .template-import-export-link { min-height: auto; padding: 0; font-size: inherit; vertical-align: baseline; }
.template-manager-note .count-badge { margin: 0 4px; vertical-align: middle; }
.template-picker-shell { margin-top: 20px; }
.template-picker-shell.is-expanded { margin-top: 0; }
.template-picker-trigger { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 52px; padding: 8px 10px; margin-top: 0; border: 1px solid transparent; border-radius: 11px; color: var(--text); background: transparent; text-align: left; }
.template-picker-trigger:hover, .template-picker-trigger:focus-visible { color: var(--accent-text-color); }
.template-picker-trigger:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 3px; border-radius: 7px; }
.template-picker-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--accent-text-color); background: var(--panel-subtle); font-size: var(--icon-size-standard); line-height: 1; }
.template-manager .template-picker-mark { width: auto; height: auto; border: 0; border-radius: 0; color: var(--accent-text-color); background: transparent; font-size: var(--icon-size-action); }
.template-picker-copy { display: grid; min-width: 0; gap: 2px; }
.template-picker-title { overflow: hidden; font-size: var(--font-base); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.template-picker-description { overflow: hidden; color: var(--muted); font-size: var(--font-supporting); text-overflow: ellipsis; white-space: nowrap; transition: var(--accent-transition); }
.template-picker-trigger:hover .template-picker-description, .template-picker-trigger:focus-visible .template-picker-description { color: currentColor; }
.template-picker-chevron { color: var(--muted); font-size: var(--icon-size-action); line-height: 1; transition: var(--accent-transition), transform 150ms ease; }
.template-picker-trigger:hover .template-picker-chevron, .template-picker-trigger:focus-visible .template-picker-chevron { color: currentColor; }
.template-picker-source { display: grid; width: 30px; min-width: 30px; height: 30px; place-items: center; border: 0; border-radius: 9px; color: var(--accent-text-color); background: transparent; font-size: var(--icon-size-standard); line-height: 1; opacity: 1; transition: var(--accent-transition); }
.template-catalog-list { display: grid; gap: 8px; margin-top: 20px; }
.template-catalog-list[hidden] { display: none; }
.template-catalog-item { display: grid; grid-template-columns: minmax(0, 1fr) 30px auto; gap: 10px; align-items: center; width: 100%; min-height: 56px; padding: 8px 10px; border: 1px solid transparent; border-radius: 11px; color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.template-catalog-item:hover { border-color: var(--border); background: var(--panel-subtle); }
.template-catalog-item.is-selected { border-color: var(--accent-color); background: var(--accent-soft); }
.template-catalog-main { position: relative; z-index: 1; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: center; min-width: 0; width: 100%; padding: 3px 0; border: 0; color: inherit; background: transparent; font: inherit; text-align: left; }
.template-catalog-item:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 3px; }
.template-catalog-item-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--accent-text-color); background: var(--panel-subtle); font-size: var(--icon-size-standard); }
.template-catalog-item-copy { min-width: 0; }
.template-catalog-item-title { display: block; overflow: hidden; font-size: var(--font-base); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.template-catalog-item-description { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: var(--font-supporting); text-overflow: ellipsis; white-space: nowrap; }
.template-catalog-actions { position: relative; z-index: 2; display: flex; align-items: center; justify-content: flex-end; gap: 0; }
.template-catalog-source { display: grid; grid-column: 2; width: 30px; min-width: 30px; height: 30px; place-items: center; color: var(--accent-text-color); }
.template-catalog-badges { display: none; }
.template-catalog-item .template-catalog-edit, .template-catalog-item .template-catalog-copy, .template-catalog-item .template-catalog-delete { display: none; visibility: hidden; width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; color: var(--muted); background: transparent; box-shadow: none; opacity: 0; pointer-events: none; transition: var(--accent-transition), opacity 150ms ease; }
.template-catalog-item:hover .template-catalog-edit, .template-catalog-item:focus-within .template-catalog-edit,
.template-catalog-item:hover .template-catalog-copy, .template-catalog-item:focus-within .template-catalog-copy,
.template-catalog-item:hover .template-catalog-delete, .template-catalog-item:focus-within .template-catalog-delete,
.template-catalog-delete.is-confirming, .template-catalog-delete:focus-visible { display: grid; visibility: visible; opacity: 0.66; pointer-events: auto; }
.template-catalog-item .template-catalog-edit:hover, .template-catalog-item .template-catalog-edit:focus-visible,
.template-catalog-item .template-catalog-copy:hover, .template-catalog-item .template-catalog-copy:focus-visible,
.template-catalog-item .template-catalog-delete:hover, .template-catalog-item .template-catalog-delete:focus-visible,
.template-catalog-delete.is-confirming { opacity: 1; }
.template-catalog-edit:hover, .template-catalog-edit:focus-visible,
.template-catalog-copy:hover, .template-catalog-copy:focus-visible { border-color: transparent; color: var(--accent-text-color); background: transparent; box-shadow: none; }
.template-catalog-delete:hover, .template-catalog-delete:focus-visible, .template-catalog-delete.is-confirming { border-color: transparent; color: var(--accent-text-color); background: transparent; box-shadow: none; }
.template-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 6px; border-radius: 999px; color: var(--muted); background: var(--panel-subtle); font-size: var(--font-micro); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.template-badge-cloud { color: var(--accent-text-color); background: var(--accent-soft); }
.template-catalog-selector-compat { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.template-editor-heading { margin-bottom: 20px; }
.template-editor-heading, .template-preview-heading { margin-top: 10px; }
.template-editor-mode { display: inline-flex; gap: 14px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.mode-button { min-height: 30px; padding: 4px 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: var(--font-base); }
.mode-button:hover, .mode-button.is-active { color: var(--text); background: var(--panel-bg); box-shadow: var(--small-shadow); }
.template-manager .mode-button:hover, .template-manager .mode-button.is-active { color: var(--accent-text-color); background: transparent; box-shadow: none; }
.template-editor-grid { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; align-items: start; }
.template-editor-grid .field-wide { grid-column: 1 / -1; }
.template-manager-editor input,
.template-manager-editor textarea,
.template-manager-editor select { pointer-events: auto; user-select: text; -webkit-user-select: text; }
#template-icon { width: 48px; height: 48px; min-height: 48px; padding: 0; text-align: center; line-height: 1; }
.field-label-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.field-label-row .text-button { min-height: auto; padding: 0; }
.template-fields-editor { display: grid; gap: 8px; margin-top: 7px; }
.template-field-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 5fr); gap: 7px; align-items: start; }
.template-field-row { position: relative; z-index: 0; isolation: isolate; }
.template-field-key-wrap, .template-field-value-wrap { position: relative; min-width: 0; }
.template-field-row input, .template-field-row textarea, .template-field-row select { position: relative; z-index: 1; min-width: 0; pointer-events: auto !important; user-select: text; -webkit-user-select: text; }
.template-field-row input, .template-field-row textarea { cursor: text; }
.template-field-row select { min-height: calc(1.45em + 26px); cursor: pointer; }
.template-field-row input:focus, .template-field-row textarea:focus, .template-field-row select:focus { position: relative; z-index: 2; }
.template-field-key-wrap > .template-field-label { padding-right: 74px; }
.template-field-row textarea { min-width: 2lh; min-height: calc(1lh + 26px); overflow-y: hidden; resize: vertical; }
.template-field-value-wrap > .template-field-default { display: block; padding-right: 40px; }
.template-field-value-wrap > select.template-field-default { padding-right: 74px; background-position: calc(100% - 48px) 50%, calc(100% - 42px) 50%; }
.template-field-drag-handle { position: absolute; top: 50%; right: 4px; z-index: 3; display: grid; width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 0; place-items: center; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 0; line-height: 0; transform: translateY(-50%); cursor: grab; user-select: none; -webkit-user-select: none; visibility: hidden; transition: var(--accent-transition); }
.template-field-drag-icon { display: block; width: 12px; height: 18px; overflow: visible; fill: currentColor; pointer-events: none; }
.template-field-row:hover .template-field-drag-handle, .template-field-row:focus-within .template-field-drag-handle { visibility: visible; }
.template-field-drag-handle:hover, .template-field-drag-handle:focus-visible { color: var(--accent-text-color); background: var(--accent-soft); }
.template-field-drag-handle:active { cursor: grabbing; }
.template-field-row.is-dragging { opacity: 0.55; }
.template-manager .template-field-row .template-field-description-toggle { position: absolute; top: 50%; right: 30px; z-index: 3; display: grid; width: 24px; height: 24px; min-height: 24px; padding: 0; place-items: center; isolation: isolate; border: 0 !important; border-radius: 50%; color: var(--muted); background: transparent !important; box-shadow: none !important; font: 700 8px/1 var(--font-ui); text-indent: 0; transform: translateY(-50%); visibility: hidden; transition: var(--accent-transition); }
.template-manager .template-field-row .template-field-description-toggle::before { position: absolute; top: 50%; left: 50%; width: 12px; height: 12px; z-index: -1; border: 1px solid currentColor; border-radius: 50%; background: transparent; content: ""; transform: translate(-50%, -50%); pointer-events: none; transition: var(--accent-transition); }
.template-field-row:hover .template-field-description-toggle, .template-field-row:focus-within .template-field-description-toggle { visibility: visible; }
.template-manager .template-field-row .template-field-description-toggle[aria-expanded="true"] { color: var(--muted); background: transparent !important; }
.template-manager .template-field-row .template-field-description-toggle:hover, .template-manager .template-field-row .template-field-description-toggle:focus-visible { color: var(--accent-text-color); background: transparent !important; }
.template-manager .template-field-row .template-field-description-toggle:hover::before, .template-manager .template-field-row .template-field-description-toggle:focus-visible::before { background: var(--accent-soft); }
@media (hover: none) {
  .template-field-row .template-field-drag-handle, .template-field-row .template-field-description-toggle { visibility: visible; }
}
.template-field-remove { position: absolute; top: 50%; right: 5px; z-index: 3; display: grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 0; border-radius: 6px; color: var(--muted); background: transparent; transform: translateY(-50%); }
.template-field-remove .ui-icon { color: inherit; }
.template-field-remove:hover, .template-field-remove:focus-visible { color: var(--accent-text-color); background: transparent; }
.template-field-description { grid-column: 1 / -1; width: 100%; }
.prompt-editor { min-width: 0; }
.prompt-textarea-wrap { position: relative; min-width: 0; }
.prompt-textarea-wrap > textarea { display: block; min-width: 2lh; min-height: calc(2lh + 26px); overflow-y: hidden; }
.prompt-field-picker { position: absolute; top: 0; right: 0; z-index: 3; }
.prompt-field-picker-trigger {
  position: relative;
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 9px;
  place-items: center;
  border: 0;
  border-radius: 0;
  color: var(--accent-text-color);
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}
.prompt-field-picker-trigger:hover,
.prompt-field-picker-trigger:focus-visible {
  color: var(--accent-text-color);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.prompt-field-picker-trigger:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}
.prompt-field-picker-trigger .ui-icon { width: 1.3em; height: 1.3em; }
.prompt-field-picker-menu {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  display: grid;
  width: max-content;
  min-width: 0;
  max-width: min(300px, calc(100vw - 32px));
  max-height: 240px;
  padding: 5px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--control-bg);
  box-shadow: var(--small-shadow);
}
.prompt-field-option,
.prompt-field-empty {
  display: block;
  width: auto;
  min-height: 36px;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.prompt-field-option:hover { color: var(--accent-text-color); background: transparent; outline: 0; text-decoration: underline; text-underline-offset: 3px; }
.prompt-field-option:focus-visible { color: var(--accent-text-color); background: var(--accent-soft); outline: 0; }
.prompt-field-empty { color: var(--muted); cursor: default; }
.prompt-field-picker > #template-prompt-field { pointer-events: none; }
.template-output-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-top: 14px; }
.template-output-grid .field-wide { grid-column: 1 / -1; }
.template-output-grid .section-help { margin: 3px 0 0; }
.template-preview { display: grid; gap: 7px; padding: 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel-subtle); }
.template-preview pre { width: 100%; min-width: 0; max-width: none; max-height: none; margin: 0; overflow: visible; overflow-wrap: anywhere; color: var(--muted); font: var(--font-supporting)/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.template-preview-value { padding: 0.08em 0.32em; border-radius: 5px; color: var(--on-accent-color); background: var(--accent-color); font: inherit; }
.template-editor-view[hidden] { display: none; }
.template-editor-view textarea { min-width: 2lh; min-height: calc(2lh + 26px); overflow-y: hidden; }
.template-editor-view .template-field-row textarea { min-height: calc(1lh + 26px); }
.compat-hidden-control { display: none; position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.code-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-top: 10px; }
#template-code { min-width: 2lh; min-height: calc(2lh + 26px); font: var(--font-supporting)/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.template-code-error { color: var(--danger); }
.template-editor-status { margin: 14px 0 -10px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr); gap: 22px; align-items: start; }
.result-column { display: grid; gap: 22px; min-width: 0; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--shadow); }
.builder-panel, .preview-panel, .history-panel { padding: clamp(20px, 3vw, 30px); }
.panel-heading, .section-heading, .preferences-section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.panel-heading { margin-bottom: 25px; }
.builder-panel > .panel-heading { align-items: flex-end; margin-bottom: 18px; }
.panel-heading h2, .section-heading h2, .preferences-section-heading h3 { margin: 3px 0 0; font-size: var(--font-section); letter-spacing: -0.015em; }
.section-heading { margin-top: 28px; margin-bottom: 14px; }
.section-heading.compact { align-items: end; }
.section-heading h2 { font-size: var(--font-section); }
.output-summary { margin: -4px 0 16px; cursor: default; }
.hosted-only-note { display: none; margin: 4px 0 0; }

.text-button, .icon-button { border: 0; color: var(--accent-text-color); background: transparent; }
.text-button { padding: 4px 0; font-size: var(--font-base); font-weight: 400; }
.output-summary .output-summary-change {
  display: inline;
  margin-left: 3px;
  padding: 0;
  font: inherit;
  line-height: inherit;
  vertical-align: baseline;
}
.text-button:hover { color: var(--accent-text-color); text-decoration: underline; text-underline-offset: 3px; }
.reset-template-action { color: var(--muted); }
.reset-template-action:hover { color: var(--accent-text-color); }
.icon-button { display: inline-grid; min-width: 34px; min-height: 34px; padding: 5px 9px; place-items: center; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--panel-bg); font-size: var(--icon-size-action); line-height: 1; }
.icon-button:hover, .icon-button[aria-pressed="true"] { border-color: var(--accent-color); color: var(--accent-text-color); background: var(--accent-soft); }
#history-favorites-filter, #history-favorites-filter:hover, #history-favorites-filter[aria-pressed="true"] { border-color: transparent; background: transparent; }

.field { display: grid; gap: 7px; min-width: 0; }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.field-wide { grid-column: 1 / -1; }
.field-label { color: var(--text); font-size: var(--font-base); font-weight: 700; }
.template-manager-editor #template-editor-editor-mode .field-label { font-weight: 400; }
.field-help, .section-help { color: var(--muted); font-size: var(--font-supporting); }
.field-help { display: flex; justify-content: flex-end; margin-top: -2px; }
.textarea-wrap { position: relative; min-width: 0; }
.textarea-wrap textarea { display: block; min-width: 2lh; min-height: calc(2lh + 26px); overflow-y: hidden; }
.textarea-wrap .field-help { position: absolute; right: 12px; bottom: 8px; z-index: 1; width: max-content; margin: 0; pointer-events: none; user-select: none; white-space: nowrap; }
textarea, input, select { width: 100%; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: var(--control-bg); }
textarea, input { padding: 12px 13px; }
select { min-height: 44px; padding: 9px 42px 9px 12px; -webkit-appearance: none; appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-repeat: no-repeat; background-size: 6px 6px, 6px 6px; }
select:disabled { cursor: not-allowed; }
textarea { resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 0.9; }
textarea:hover, input:hover, select:hover { border-color: var(--border-strong); }
textarea:focus, input:focus, select:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 18%, transparent); outline: 0; }
#prompt-input:hover,
#prompt-input:focus,
#prompt-input:focus-visible { border-color: var(--accent-color); background: var(--accent-soft); box-shadow: none; outline: 0; }
#prompt-input:focus:not(:hover):placeholder-shown {
  border-color: var(--border);
  background: var(--control-bg);
}

.generator-template-picker { position: relative; min-width: 0; }
.generator-template-picker-trigger {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 12px 24px;
  grid-template-rows: minmax(42px, auto);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--control-bg);
  text-align: left;
  transition: var(--accent-transition);
}
.generator-template-picker-trigger:hover,
.generator-template-picker-trigger[aria-expanded="true"] { border-color: var(--accent-color); background: var(--accent-soft); }
.generator-template-picker-trigger[aria-expanded="true"] { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.generator-template-picker-trigger:focus-visible { border-color: var(--accent-color); outline: 3px solid color-mix(in srgb, var(--accent-color) 24%, transparent); outline-offset: 2px; }
.generator-template-picker-mark,
.generator-template-picker-option-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-text-color);
  background: var(--panel-subtle);
  font-size: var(--icon-size-prominent);
  line-height: 1;
  transition: var(--accent-transition);
}
.generator-template-picker-copy,
.generator-template-picker-option-copy { display: grid; min-width: 0; gap: 3px; }
.generator-template-picker-title,
.generator-template-picker-option-title { overflow: hidden; font-size: var(--font-base); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.generator-template-picker-description,
.generator-template-picker-option-description { overflow: hidden; color: var(--muted); font-size: var(--font-supporting); text-overflow: ellipsis; white-space: nowrap; transition: var(--accent-transition); }
.generator-template-picker-trigger:hover .generator-template-picker-description,
.generator-template-picker-trigger[aria-expanded="true"] .generator-template-picker-description { color: var(--text); }
.template-source-indicator {
  display: grid;
  width: 24px;
  min-width: 24px;
  height: 24px;
  place-items: center;
  font-size: var(--icon-size-action);
  line-height: 1;
  transition: var(--accent-transition);
}
.template-source-indicator .ui-icon { width: 22px; height: 22px; }
.generator-template-picker-source {
  grid-column: 4;
  justify-self: end;
  color: var(--muted);
}
.generator-template-picker-option-source {
  grid-column: 3;
  justify-self: end;
  color: var(--muted);
}
.generator-template-picker-trigger:hover .generator-template-picker-source,
.generator-template-picker-trigger[aria-expanded="true"] .generator-template-picker-source,
.generator-template-picker-option:hover .generator-template-picker-option-source,
.generator-template-picker-option:focus-visible .generator-template-picker-option-source { color: var(--accent-text-color); }
.generator-template-picker-chevron {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  width: 10px;
  height: 10px;
  margin-top: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: var(--muted);
  transform: rotate(45deg);
  transition: var(--accent-transition), transform 150ms ease;
}
.generator-template-picker-trigger:hover .generator-template-picker-chevron,
.generator-template-picker-trigger[aria-expanded="true"] .generator-template-picker-chevron { color: var(--accent-text-color); }
.generator-template-picker-trigger[aria-expanded="true"] .generator-template-picker-chevron { margin-top: 0; transform: rotate(225deg); }
.generator-template-picker-list {
  position: relative;
  display: grid;
  gap: 0;
  height: 0;
  margin-top: 0;
  padding: 0;
  overflow: hidden;
  border: 0 solid transparent;
  border-radius: 0 0 14px 14px;
  background: var(--panel-bg);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: height 200ms ease, margin-top 200ms ease, opacity 200ms ease, var(--accent-transition), box-shadow 200ms ease, visibility 0s linear 200ms;
}
.generator-template-picker-list.is-open {
  margin-top: -1px;
  border-width: 1px;
  border-color: var(--accent-color);
  box-shadow: var(--shadow);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: height 200ms ease, margin-top 200ms ease, opacity 200ms ease, var(--accent-transition), box-shadow 200ms ease, visibility 0s linear 0s;
}
.generator-template-picker-list[hidden] { display: none; }
.generator-template-picker-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.generator-template-picker-option:hover,
.generator-template-picker-option:focus-visible { background: var(--accent-soft); outline: 0; }
.generator-template-picker-option:last-child { border-bottom-right-radius: 13px; border-bottom-left-radius: 13px; }
.generator-template-picker-option.is-selected { background: var(--accent-soft); }
.generator-template-picker-option:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-color) 24%, transparent); outline-offset: 1px; }
.generator-template-picker-option:hover .generator-template-picker-option-description,
.generator-template-picker-option:focus-visible .generator-template-picker-option-description,
.generator-template-picker-option.is-selected .generator-template-picker-option-description { color: var(--text); }

.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-actions { display: flex; align-items: center; gap: 15px; margin-top: 15px; }
.primary-button, .secondary-button { min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 500; }
.primary-button { color: var(--on-accent-color); background: var(--accent-color); }
.primary-button:hover:not(:disabled) { filter: brightness(0.94); }
.secondary-button { border-color: var(--border); color: var(--text); background: var(--control-bg); }
.secondary-button:hover:not(:disabled) { border-color: var(--accent-color); color: var(--accent-text-color); background: var(--accent-soft); }
.secondary-button.small, .primary-button.small { min-height: 34px; padding: 7px 11px; font-size: var(--font-base); }
.template-delete-button { min-width: 84px; }
.secondary-button.danger { color: var(--danger); }
.secondary-button.danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.generation-timer, .generation-help { color: var(--muted); font-size: var(--font-supporting); }
.generation-help { max-width: 300px; }

.template-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-height: 0; margin-top: 0; overflow: hidden; padding: 0; border: 1px solid var(--border); border-width: 0; border-radius: 14px; background: var(--panel-subtle); opacity: 0; pointer-events: none; transition: max-height 200ms ease, margin-top 200ms ease, padding 200ms ease, border-width 200ms ease, opacity 200ms ease; }
.template-fields.is-open { max-height: var(--template-fields-height, 2000px); margin-top: 12px; padding: 15px; border-width: 1px; opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .template-fields { transition: none; }
}
.template-fields.single-field .template-value-field { grid-column: 1 / -1; }
.template-value-field { display: grid; gap: 7px; min-width: 0; }
.field-control-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.template-value-field .field-control-heading { align-items: center; justify-content: flex-start; gap: 8px; }
.template-value-field .template-value-help { flex: 0 0 18px; width: 18px; min-width: 18px; height: 18px; min-height: 18px; border-color: var(--border); color: var(--muted); background: transparent; font-size: 10px; opacity: 0; pointer-events: none; visibility: hidden; transition: var(--accent-transition); }
.template-value-field:hover .template-value-help, .template-value-field:focus-within .template-value-help, .template-value-field .template-value-help[aria-expanded="true"] { opacity: 1; pointer-events: auto; visibility: visible; }
.template-value-field .template-value-help:hover, .template-value-field .template-value-help:focus-visible, .template-value-field .template-value-help[aria-expanded="true"] { border-color: var(--accent-color); color: var(--accent-text-color); background: var(--accent-soft); }
.field-value-wrap { position: relative; min-width: 0; }
.field-value-wrap > .template-value-input { display: block; padding-right: 44px; }
.template-value-field .field-label { font-weight: 400; }
.field-reset { position: absolute; top: 3px; right: 1px; z-index: 1; display: grid; width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 0; place-items: center; border: 0; border-radius: 6px; color: var(--accent-text-color); background: transparent; font-size: var(--font-base); line-height: 1; }
.field-reset:hover, .field-reset:focus-visible { color: var(--accent-text-color); background: var(--accent-soft); outline: 0; }
.template-value-input { min-width: 2lh; min-height: calc(1lh + 26px); overflow-y: hidden; resize: vertical; }
.fields-message { grid-column: 1 / -1; margin: 0 0 1px; color: var(--muted); font-size: var(--font-supporting); }
.fields-warning-symbol { margin-right: 4px; color: var(--accent-text-color); font-weight: 700; }
.fields-reset-all { min-height: auto; padding: 0; font: inherit; vertical-align: baseline; }
.snapshot-template-note { margin-top: 12px; }
.notice { padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--accent-color) 45%, var(--border)); border-radius: 11px; color: var(--muted); background: var(--accent-soft); font-size: var(--font-supporting); }

.template-reference-editor-field { padding-top: 4px; }
.template-reference-dropzone { cursor: default; }
.template-reference-dropzone .reference-dropzone-trigger { cursor: pointer; }
.template-reference-url-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; flex: 1 1 100%; width: 100%; margin-top: 12px; }
.template-reference-url-form input { min-width: 0; }
.template-reference-item { display: grid; place-items: center; color: var(--muted); }
.template-reference-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.template-reference-item .template-reference-preview-fallback { padding: 8px; color: var(--muted); font-size: var(--font-supporting); text-align: center; }
.template-reference-empty { grid-column: 1 / -1; padding: 4px 0; color: var(--muted); font-size: var(--font-supporting); }
.template-reference-help { justify-content: flex-start; margin-top: -2px; }

.reference-dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; min-height: 76px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: 14px; color: var(--text); background: var(--panel-subtle); cursor: pointer; }
.reference-dropzone:hover,
.reference-dropzone:focus,
.reference-dropzone:focus-visible,
.reference-dropzone:focus-within,
.reference-dropzone.is-dragover { border-color: var(--accent-color); background: var(--accent-soft); box-shadow: none; outline: 0; }
.reference-dropzone-trigger { display: flex; flex: 1 1 100%; align-items: center; gap: 13px; min-width: 0; cursor: pointer; }
.reference-dropzone strong, .reference-dropzone small { display: block; }
.reference-dropzone strong { font-weight: 500; }
.reference-dropzone small { margin-top: 3px; color: var(--muted); font-size: var(--font-supporting); }
.reference-dropzone-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; color: var(--accent-text-color); background: var(--control-bg); font-size: var(--icon-size-prominent); }
.reference-dropzone > input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.reference-list { display: grid; flex: 1 1 100%; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 9px; width: 100%; margin-top: 12px; }
.reference-list:empty { display: none; }
.reference-item { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-subtle); }
.reference-item, .reference-item img { cursor: default; }
.reference-item img { width: 100%; height: 100%; object-fit: cover; }
.reference-item button { position: absolute; top: 4px; right: 4px; display: grid; width: 25px; height: 25px; padding: 0; place-items: center; border: 0; border-radius: 50%; color: #fff; background: transparent; cursor: pointer; font-size: var(--icon-size-action); line-height: 1; text-shadow: 0 1px 5px rgba(0,0,0,0.95); }
.reference-item button:hover { border: 0; color: var(--accent-text-color); background: transparent; }

.preview-stage { position: relative; }
.image-preview { display: grid; min-height: 0; aspect-ratio: 1 / 1; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--page-bg) 88%, var(--text)) 0 25%, var(--page-bg) 0 50%) 50% / 24px 24px; }
.image-preview img { display: block; width: 100%; max-height: 610px; object-fit: contain; }
.preview-empty { display: grid; gap: 12px; place-items: center; width: min(100%, 360px); max-width: 100%; padding: 30px; color: var(--muted); text-align: center; cursor: default; }
.preview-empty p { max-width: 100%; margin: 0; overflow-wrap: anywhere; font-size: var(--font-base); text-shadow: 0 0 4px var(--page-bg), 0 0 9px var(--page-bg); cursor: default; }
.preview-mark { display: grid; width: 54px; height: 54px; place-items: center; border: 0; border-radius: 17px; color: var(--accent-text-color); font-size: var(--icon-size-prominent); }
.image-preview:has(img) { position: relative; }
.result-badge, .count-badge { color: var(--muted); font-size: var(--font-supporting); font-weight: 400; cursor: default; }
.result-badge { padding: 5px 8px; border-radius: 999px; background: var(--panel-subtle); }
.result-actions { position: absolute; right: 2px; bottom: 12px; left: 22px; z-index: 2; display: flex; flex-wrap: nowrap; gap: 1px; margin-top: 0; opacity: 0; pointer-events: none; text-shadow: 0 2px 7px rgba(0,0,0,0.96); filter: drop-shadow(0 2px 5px rgba(0,0,0,0.82)); transition: opacity 150ms ease; }
.preview-stage:hover .result-actions, .preview-stage:focus-within .result-actions { opacity: 1; pointer-events: auto; }
.result-actions > button { min-width: 29.33px; width: 29.33px; flex: 0 0 29.33px; padding: 0; border-color: transparent; color: var(--text); background: transparent; font-size: var(--icon-size-action); line-height: 1; white-space: nowrap; }
.result-actions > button:hover:not(:disabled) { border-color: transparent; color: var(--accent-text-color); background: transparent; }
.result-actions > .favorite-button { min-width: 44px; width: 44px; flex-basis: 44px; margin-left: auto; }
.favorite-button { min-width: 44px; color: var(--accent-text-color); font-size: var(--icon-size-action); }
.favorite-button.is-favorite { border-color: var(--accent-color); color: var(--accent-text-color); background: var(--accent-soft); }

.history-heading-actions { display: flex; align-items: center; gap: 12px; }
.preview-panel .panel-heading, .history-panel .panel-heading { align-items: flex-end; }
.history-panel h2 { display: flex; align-items: center; gap: 8px; }
.count-badge { display: inline-grid; min-width: 24px; height: 24px; padding: 0 6px; place-items: center; border-radius: 999px; color: var(--accent-text-color); background: var(--accent-soft); }
.history-list { display: grid; gap: 11px; }
#history-show-all { display: none; margin: 4px auto 0; }
.history-empty { padding: 18px 8px 0; color: var(--muted); font-size: var(--font-supporting); text-align: center; }
.history-item { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 13px; align-items: stretch; padding: 9px; border: 1px solid var(--border); border-radius: 13px; background: var(--panel-bg); }
.history-item.is-current { border-color: var(--accent-color); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 16%, transparent); }
.history-thumb-wrap { position: relative; align-self: stretch; min-height: 82px; overflow: hidden; border-radius: 8px; background: var(--panel-subtle); }
.history-thumb-wrap img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; cursor: pointer; }
.history-thumb-wrap img:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }
.history-thumb-empty { position: absolute; inset: 0; display: grid; min-height: 0; place-items: center; color: var(--muted); }
.history-text { min-width: 0; }
.history-prompt { display: -webkit-box; width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 0; color: var(--text); background: transparent; font-size: var(--font-base); text-align: left; transition: var(--accent-transition); cursor: default; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.history-prompt.is-openable { cursor: pointer; }
.history-prompt.is-openable:hover, .history-prompt.is-openable:focus-visible { color: var(--accent-text-color); }
.history-meta { display: block; min-width: 0; max-width: 100%; margin-top: 6px; overflow: hidden; color: var(--muted); font-size: var(--font-micro); text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.history-actions { position: relative; left: -6px; display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.history-actions button { display: inline-grid; width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 5px; place-items: center; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: var(--icon-size-action); line-height: 1; }
.history-actions button .ui-icon { width: 18px; height: 18px; color: inherit; }
.history-actions button:hover, .history-actions button:focus-visible { border-color: transparent; color: var(--accent-text-color); background: transparent; }
.history-actions button.is-favorite { color: var(--accent-text-color); }
.history-actions button.delete-action.is-confirming { color: var(--accent-text-color); }
.history-actions button.delete-action:hover, .history-actions button.delete-action:focus-visible { border-color: transparent; color: var(--accent-text-color); background: transparent; }

.status { --status-accent: var(--accent-color); position: fixed; left: max(16px, calc(16px + var(--host-safe-area-left))); bottom: max(16px, calc(16px + var(--host-safe-area-bottom))); z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; width: fit-content; min-width: 150px; max-width: min(50vw, calc(100vw - 32px)); min-height: 58px; padding: 12px 4px 12px 16px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--status-accent) 72%, var(--border)); border-radius: 10px; color: var(--text); background: color-mix(in srgb, var(--panel-bg) 86%, var(--status-accent)); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18); font-size: var(--font-supporting); pointer-events: auto; transition: var(--accent-transition), opacity 160ms ease, transform 300ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 160ms ease; }
.status::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--status-accent); content: ""; transition: var(--accent-transition); }
.status[data-level="info"] { --status-accent: var(--accent-color); }
.status[data-level="success"] { --status-accent: #2f855a; }
.status[data-level="warning"] { --status-accent: var(--warning-color); border-color: color-mix(in srgb, var(--status-accent) 86%, var(--border)); background: color-mix(in srgb, var(--panel-bg) 74%, var(--status-accent)); }
.status[data-level="error"] { --status-accent: var(--warning-error); border-color: color-mix(in srgb, var(--status-accent) 86%, var(--border)); background: color-mix(in srgb, var(--panel-bg) 74%, var(--status-accent)); }
.status:hover, .status:focus-within { box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24); }
.status[data-state="open"] { animation: status-slide-fade-in 220ms cubic-bezier(0.22, 1, 0.36, 1); }
.status[data-state="closed"] { animation: status-fade-out 160ms ease-in forwards; }
.status-copy { min-width: 0; max-width: 100%; }
.status-title, .status-message { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-title { margin-bottom: 2px; font-size: var(--font-supporting); font-weight: 750; }
.status-message { font-size: var(--font-supporting); line-height: 1.35; }
.status-action { min-height: 30px; padding: 4px 9px; border: 1px solid color-mix(in srgb, var(--status-accent) 72%, var(--border)); border-radius: 7px; color: var(--text); background: transparent; font: inherit; font-weight: 700; }
.status-action:hover, .status-action:focus-visible { border-color: var(--status-accent); background: color-mix(in srgb, var(--status-accent) 12%, transparent); }
.status-close { justify-self: end; width: 26px; height: 26px; padding: 0; margin: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: var(--icon-size-action); line-height: 1; }
.status-close:hover, .status-close:focus-visible { color: var(--text); background: color-mix(in srgb, var(--text) 10%, transparent); }
@keyframes status-slide-fade-in { from { opacity: 0; transform: translate3d(-24px, 0, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
@keyframes status-fade-out { from { opacity: 1; } to { opacity: 0; } }

#app-direct-footer { display: flex; flex-wrap: nowrap; justify-content: flex-start; gap: 0; padding: 12px clamp(18px, 4vw, 52px); border-top: 1px solid var(--border); color: var(--muted); background: var(--panel-bg); font-size: var(--font-supporting); white-space: nowrap; }
.footer-links { display: inline; }

.preferences-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(10, 18, 20, 0.36); }
.preferences-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(470px, 100vw); border-left: 1px solid var(--border); color: var(--text); background: var(--panel-bg); box-shadow: -18px 0 60px rgba(0,0,0,0.14); }
.preferences-header { display: flex; justify-content: space-between; gap: 15px; padding: 25px 25px 20px; border-bottom: 1px solid var(--border); }
.preferences-header h2 { margin: 4px 0 0; font-size: var(--font-section); }
.preferences-content { overflow: auto; padding: 22px 25px 45px; }
.preferences-section { display: grid; gap: 13px; padding: 0 0 25px; margin-bottom: 25px; border-bottom: 1px solid var(--border); }
.preferences-section:last-child { border-bottom: 0; }
.preferences-section-heading h3 { font-size: var(--font-section); }
.preferences-section .section-help { margin: -5px 0 1px; }
.fields-preferences-section[hidden] { display: none !important; }
.preferences-section-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; list-style: none; cursor: pointer; }
.preferences-section-summary::-webkit-details-marker { display: none; }
.preferences-section-chevron { width: 9px; height: 9px; margin: 7px 4px 0 0; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(45deg); transition: transform 150ms ease; }
.fields-preferences-section[open] .preferences-section-chevron { transform: rotate(225deg); }
.preferences-fields { display: grid; gap: 13px; }
.preferences-output-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.template-editor-grid { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: start; }
.template-editor-grid .field-wide { grid-column: 1 / -1; }
.template-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.preferences-links { display: block; }
.preferences-links h3 { margin: 4px 0 5px; }

.lightbox { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 30px; background: rgba(0,0,0,0.82); }
.lightbox figure { display: grid; max-width: min(1100px, 100%); max-height: 100%; gap: 10px; margin: 0; }
.lightbox img { display: block; max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; }
.lightbox figcaption { overflow: auto; max-height: 70px; color: #fff; font-size: var(--font-supporting); }
.lightbox-close { position: absolute; top: 17px; right: 20px; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(255,255,255,0.55); border-radius: 50%; color: #fff; background: rgba(0,0,0,0.3); font-size: var(--icon-size-prominent); }

/* Template Manager controls are intentionally quiet: meaning comes from text, symbols, and color. */
.template-manager button,
.template-manager .template-badge,
.template-manager .count-badge,
.template-manager .pill {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.template-manager .prompt-field-picker-trigger {
  border: 0 !important;
  color: var(--accent-text-color) !important;
  background: transparent !important;
  box-shadow: none !important;
}
.template-manager .prompt-field-picker-trigger:hover,
.template-manager .prompt-field-picker-trigger:focus-visible {
  border-color: transparent !important;
  color: var(--accent-text-color) !important;
  background: transparent !important;
}
.template-manager .prompt-field-option {
  border: 0 !important;
  color: var(--text) !important;
  background: transparent !important;
  text-align: left;
}
.template-manager .prompt-field-option:hover {
  color: var(--accent-text-color) !important;
  background: transparent !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.template-manager .prompt-field-option:focus-visible {
  color: var(--accent-text-color) !important;
  background: var(--accent-soft) !important;
}
.template-manager .primary-button { color: var(--accent-text-color); }
.template-manager .mode-button.is-active { color: var(--accent-text-color); }
.template-manager .template-actions > button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--border) !important;
  border-radius: 11px;
  color: var(--text);
  background: var(--control-bg) !important;
  box-shadow: none !important;
  font-size: var(--font-base);
  font-weight: 500;
  text-decoration: none;
}
.template-manager .template-actions > button:hover:not(:disabled) {
  border-color: var(--accent-color) !important;
  color: var(--accent-text-color);
  background: var(--accent-soft) !important;
}
.template-manager #new-template.template-import-export-link {
  min-height: auto;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  color: var(--accent-text-color);
  background: transparent !important;
  font-size: inherit;
  font-weight: 400;
  text-decoration: none;
  vertical-align: baseline;
}
.template-manager #new-template.template-import-export-link:hover:not(:disabled),
.template-manager #new-template.template-import-export-link:focus-visible {
  border-color: transparent !important;
  color: var(--accent-text-color);
  background: transparent !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.template-manager .template-actions > .primary-button {
  border-color: var(--accent-color) !important;
  color: var(--on-accent-color) !important;
  background: var(--accent-color) !important;
  font-weight: 400;
}
.template-manager .template-actions > .primary-button:hover:not(:disabled) {
  border-color: var(--accent-color) !important;
  color: var(--on-accent-color) !important;
  background: var(--accent-color) !important;
  filter: brightness(0.94);
}
.template-manager .template-action-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
}
.template-manager .template-action-links > button {
  min-width: 0;
  min-height: auto;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  color: var(--accent-text-color);
  background: transparent !important;
  font-size: var(--font-base);
  font-weight: 400;
  text-decoration: none;
  vertical-align: baseline;
}
.template-manager .template-action-links > button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 1;
}
.template-manager .template-action-links > button:not([hidden]) ~ button:not([hidden])::before {
  content: ", ";
  color: var(--muted);
  text-decoration: none;
  white-space: pre;
}
.template-manager .template-action-links > button:hover:not(:disabled),
.template-manager .template-action-links > button:focus-visible {
  border-color: transparent !important;
  color: var(--accent-text-color);
  background: transparent !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.template-manager .template-catalog-delete {
  display: none;
  visibility: hidden;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent !important;
  border-radius: 8px;
  color: var(--muted);
  background: transparent !important;
  box-shadow: none !important;
  font-size: var(--icon-size-standard);
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: var(--accent-transition), opacity 150ms ease;
}
.template-manager .template-catalog-item:hover .template-catalog-delete,
.template-manager .template-catalog-item:focus-within .template-catalog-delete,
.template-manager .template-catalog-delete.is-confirming,
.template-manager .template-catalog-delete:focus-visible {
  display: grid;
  visibility: visible;
  opacity: 0.66;
  pointer-events: auto;
}
.template-manager .template-catalog-item .template-catalog-edit:hover,
.template-manager .template-catalog-item .template-catalog-edit:focus-visible,
.template-manager .template-catalog-item .template-catalog-copy:hover,
.template-manager .template-catalog-item .template-catalog-copy:focus-visible,
.template-manager .template-catalog-item .template-catalog-delete:hover,
.template-manager .template-catalog-item .template-catalog-delete:focus-visible,
.template-manager .template-catalog-delete.is-confirming {
  opacity: 1;
}
.template-manager .template-catalog-delete:hover:not(:disabled),
.template-manager .template-catalog-delete:focus-visible,
.template-manager .template-catalog-delete.is-confirming {
  border: 0 !important;
  color: var(--danger);
  background: transparent !important;
}
.template-manager .template-catalog-delete:disabled { cursor: not-allowed; }
.template-manager .template-catalog-item .template-catalog-edit,
.template-manager .template-catalog-item .template-catalog-copy,
.template-manager .template-catalog-item .template-catalog-delete,
.template-manager .template-catalog-item .template-catalog-edit:hover,
.template-manager .template-catalog-item .template-catalog-edit:focus-visible,
.template-manager .template-catalog-item .template-catalog-copy:hover,
.template-manager .template-catalog-item .template-catalog-copy:focus-visible,
.template-manager .template-catalog-item .template-catalog-delete:hover,
.template-manager .template-catalog-item .template-catalog-delete:focus-visible {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.template-manager .template-catalog-item .template-catalog-edit:hover,
.template-manager .template-catalog-item .template-catalog-edit:focus-visible,
.template-manager .template-catalog-item .template-catalog-copy:hover,
.template-manager .template-catalog-item .template-catalog-copy:focus-visible {
  color: var(--accent-text-color);
}

.template-catalog-list.is-hover-suppressed .template-catalog-item .template-catalog-edit,
.template-catalog-list.is-hover-suppressed .template-catalog-item .template-catalog-copy,
.template-catalog-list.is-hover-suppressed .template-catalog-item .template-catalog-delete:not(.is-confirming) {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.template-manager .template-picker-shell { position: relative; margin-top: 20px; }
.template-manager .template-picker-shell.is-expanded { margin-top: 20px; }
.template-manager .template-picker-trigger {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 12px 24px;
  grid-template-rows: minmax(42px, auto);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 11px 14px;
  margin-top: 0;
  border: 1px solid var(--border) !important;
  border-radius: 14px;
  color: var(--text);
  background: var(--control-bg) !important;
  text-align: left;
  transition: var(--accent-transition);
}
.template-manager .template-picker-trigger:hover,
.template-manager .template-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent-color) !important;
  color: var(--text);
  background: var(--accent-soft) !important;
}
.template-manager .template-picker-trigger[aria-expanded="true"] { border-bottom-right-radius: 0; border-bottom-left-radius: 0; }
.template-manager .template-picker-trigger:focus-visible {
  border-color: var(--accent-color) !important;
  outline: 3px solid color-mix(in srgb, var(--accent-color) 24%, transparent);
  outline-offset: 2px;
}
.template-manager .template-picker-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-text-color);
  background: var(--panel-subtle);
  font-size: var(--icon-size-prominent);
  line-height: 1;
  transition: var(--accent-transition);
}
.template-manager .template-picker-copy { display: grid; min-width: 0; gap: 3px; }
.template-manager .template-picker-title { overflow: hidden; font-size: var(--font-base); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.template-manager .template-picker-description { overflow: hidden; color: var(--muted); font-size: var(--font-supporting); text-overflow: ellipsis; white-space: nowrap; transition: var(--accent-transition); }
.template-manager .template-picker-trigger:hover .template-picker-description,
.template-manager .template-picker-trigger[aria-expanded="true"] .template-picker-description { color: var(--text); }
.template-manager .template-picker-source {
  grid-column: 4;
  justify-self: end;
  color: var(--muted);
  transition: var(--accent-transition);
}
.template-manager .template-picker-trigger:hover .template-picker-source,
.template-manager .template-picker-trigger[aria-expanded="true"] .template-picker-source { color: var(--accent-text-color); }
.template-manager .template-picker-chevron {
  grid-column: 3;
  grid-row: 1;
  width: 10px;
  height: 10px;
  justify-self: end;
  margin-top: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: var(--muted);
  transform: rotate(45deg);
  transition: var(--accent-transition), transform 150ms ease;
}
.template-manager .template-picker-trigger:hover .template-picker-chevron,
.template-manager .template-picker-trigger[aria-expanded="true"] .template-picker-chevron { color: var(--accent-text-color); }
.template-manager .template-picker-trigger[aria-expanded="true"] .template-picker-chevron { margin-top: 0; transform: rotate(225deg); }
.template-manager .template-picker-list {
  position: relative;
  display: grid;
  gap: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0 solid transparent !important;
  border-radius: 0 0 14px 14px;
  background: var(--panel-bg);
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: height 200ms ease, margin-top 200ms ease, opacity 200ms ease, var(--accent-transition), box-shadow 200ms ease, visibility 0s linear 200ms;
}
.template-manager .template-picker-list.is-open {
  margin-top: -1px;
  border-width: 1px !important;
  border-color: var(--accent-color) !important;
  box-shadow: var(--shadow);
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: height 200ms ease, margin-top 200ms ease, opacity 200ms ease, var(--accent-transition), box-shadow 200ms ease, visibility 0s linear 0s;
}
.template-manager .template-picker-list[hidden] { display: none; }
.template-manager .template-picker-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  border: 0 !important;
  border-radius: 0;
  color: var(--text);
  background: transparent !important;
  text-align: left;
  cursor: pointer;
  transition: var(--accent-transition);
}
.template-manager .template-catalog-item.template-picker-option {
  grid-template-columns: minmax(0, 1fr) auto 24px;
  grid-template-rows: minmax(44px, auto);
}
.template-manager .template-catalog-item .template-catalog-source {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  color: var(--accent-text-color);
}
.template-manager .template-catalog-item .template-catalog-actions {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: end;
}
.template-manager .template-picker-option:hover,
.template-manager .template-picker-option:focus-visible,
.template-manager .template-picker-option.is-selected { background: var(--accent-soft) !important; outline: 0; }
.template-manager .template-picker-option:last-child { border-bottom-right-radius: 13px; border-bottom-left-radius: 13px; }
.template-manager .template-picker-option:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-color) 24%, transparent); outline-offset: 1px; }
.template-manager .template-picker-option-main {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0 !important;
  color: inherit;
  background: transparent !important;
  font: inherit;
  text-align: left;
}
.template-manager .template-picker-option-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-text-color);
  background: var(--panel-subtle);
  font-size: var(--icon-size-prominent);
  line-height: 1;
  transition: var(--accent-transition);
}
.template-manager .template-picker-option-copy { display: grid; min-width: 0; gap: 3px; }
.template-manager .template-picker-option-title { overflow: hidden; font-size: var(--font-base); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.template-manager .template-picker-option-description { overflow: hidden; color: var(--muted); font-size: var(--font-supporting); text-overflow: ellipsis; white-space: nowrap; transition: var(--accent-transition); }
.template-manager .template-picker-option:hover .template-picker-option-description,
.template-manager .template-picker-option:focus-visible .template-picker-option-description,
.template-manager .template-picker-option.is-selected .template-picker-option-description { color: var(--text); }
.template-manager .template-catalog-footer-actions > .count-badge,
.template-manager .template-manager-note > .count-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 3px;
  border: 1px solid var(--accent-color) !important;
  border-radius: 999px;
  color: var(--muted) !important;
  background: var(--accent-soft) !important;
}
.template-manager .template-editor-mode {
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border) !important;
  border-radius: 12px;
  background: var(--panel-subtle) !important;
}
.template-manager .template-editor-mode .mode-button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0 !important;
  border-radius: 8px;
  color: var(--muted);
  background: transparent !important;
  box-shadow: none !important;
}
.template-manager .template-editor-mode .mode-button:hover,
.template-manager .template-editor-mode .mode-button.is-active {
  color: var(--accent-text-color);
  background: var(--panel-bg) !important;
  box-shadow: var(--small-shadow) !important;
}

html[data-embed] {
  --embed-content-top: 0px;
  --page-bg: var(--color-back, var(--fallback-page-bg));
  --panel-bg: var(--color-panel, var(--fallback-panel-bg));
  --panel-subtle: var(--color-surface, var(--fallback-panel-subtle));
  --control-bg: var(--color-surface, var(--panel-bg));
  --text: var(--color-main, var(--fallback-text));
  --muted: color-mix(in srgb, var(--color-muted, var(--fallback-muted)) 68%, var(--page-bg));
  --border: var(--color-border, var(--fallback-border));
  --border-strong: var(--color-border-strong, var(--fallback-border-strong));
  --accent-soft: color-mix(in srgb, var(--accent-color) 10%, var(--color-code-content-back, var(--page-bg)));
  --accent-shade-color: var(--chrome-accent-shade-color, var(--color-main, #111));
  --accent-text-color: var(--accent-color-text, var(--accent-color));
  --accent-icon-shadow: none;
  --chrome-accent-visible-shade-strength: max(30%, var(--chrome-accent-shade-strength, 0%));
  --shadow: none;
  --small-shadow: none;
  background: transparent;
}

html[data-embed][data-brightness="light"] {
  --accent-icon-shadow:
    drop-shadow(1px 1px 2px color-mix(in srgb, var(--accent-shade-color) calc(var(--chrome-accent-visible-shade-strength) * 0.88), transparent))
    drop-shadow(2px 2px 5px color-mix(in srgb, var(--accent-shade-color) calc(var(--chrome-accent-visible-shade-strength) * 0.62), transparent))
    drop-shadow(4px 4px 14px color-mix(in srgb, var(--accent-shade-color) calc(var(--chrome-accent-visible-shade-strength) * 0.34), transparent));
}

html[data-embed] body { min-height: 100%; height: auto; overflow: visible; background: transparent; }
html[data-embed] #app { min-height: 100%; }
html[data-embed] #app-direct-header, html[data-embed] #app-direct-footer { display: none !important; }
html[data-embed] .direct-intro { display: block; width: 100%; max-width: 780px; margin-bottom: 32px; }
html[data-embed] .app-shell { width: 100%; max-width: none; margin: 0; padding: 0; }
html[data-embed] .panel { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
html[data-embed] .builder-panel, html[data-embed] .preview-panel, html[data-embed] .history-panel { padding: 0; }
html[data-embed] .workspace-grid { gap: clamp(40px, 6vw, 88px); }
html[data-embed] .result-column { gap: clamp(40px, 6vw, 72px); }
html[data-embed] .panel-heading { margin-bottom: 32px; }
html[data-embed] .builder-panel > .panel-heading { margin-top: 10px; margin-bottom: 18px; }
html[data-embed] .section-heading { margin-top: 37px; margin-bottom: 18px; }
html[data-embed] .preview-panel > .panel-heading { margin-top: 0; }
html[data-embed] .history-panel > .panel-heading { margin-top: 5px; }
html[data-embed] .eyebrow { color: var(--accent-text-color); font-size: var(--font-micro); font-weight: 700; }
html[data-embed] textarea, html[data-embed] input, html[data-embed] select { background-color: var(--control-bg) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-embed] textarea, html[data-embed] input { -webkit-appearance: none; appearance: none; }
html[data-embed] #prompt-input:hover,
html[data-embed] #prompt-input:focus,
html[data-embed] #prompt-input:focus-visible { border-color: var(--accent-color) !important; background: var(--accent-soft) !important; box-shadow: none !important; outline: 0 !important; }
html[data-embed] #prompt-input:focus:not(:hover):placeholder-shown {
  border-color: var(--border) !important;
  background: var(--control-bg) !important;
}
html[data-embed] .template-fields { padding: 0; border: 0; border-radius: 0; background: transparent; }
html[data-embed] .preferences-fields { gap: 16px; }
html[data-embed] .notice { padding: 8px 0 8px 14px; border: 0; border-left: 2px solid var(--accent-color); border-radius: 0; background: transparent; }
html[data-embed] .reference-dropzone { padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--control-bg); }
html[data-embed] .reference-dropzone:hover,
html[data-embed] .reference-dropzone:focus,
html[data-embed] .reference-dropzone:focus-visible,
html[data-embed] .reference-dropzone:focus-within,
html[data-embed] .reference-dropzone.is-dragover { border-color: var(--accent-color) !important; background: var(--accent-soft) !important; box-shadow: none; outline: 0; }
html[data-embed] .reference-dropzone-icon { background: transparent; }
html[data-embed] .reference-dropzone-trigger { background: transparent; }
html[data-embed] .image-preview { border: 0; border-radius: 0; }
html[data-embed] .result-badge { padding: 0; background: transparent; }
html[data-embed] .count-badge { min-width: 0; height: auto; padding: 0; background: transparent; }
html[data-embed] .history-list { gap: 7px; }
html[data-embed] .history-item { padding: 10px 0 5px; border: 0; border-radius: 0; background: transparent; }
html[data-embed] .history-actions button, html[data-embed] .icon-button { border-color: transparent; background: transparent; }
html[data-embed] .secondary-button, html[data-embed] textarea, html[data-embed] input, html[data-embed] select { border-radius: 8px; }
html[data-embed] .secondary-button { background: transparent; }
html[data-embed="full"] { --embed-content-top: calc(18px + var(--host-safe-area-top)); }
html[data-embed="full"] .app-shell { padding: var(--embed-content-top) clamp(28px, 5vw, 72px) calc(24px + var(--host-safe-area-bottom)); }
html[data-embed="full"] .app-shell { padding-bottom: 24px; }
html[data-embed="full"] .app-shell,
html[data-embed="full"] .template-manager { transform: translateY(-45px); }
html[data-embed="full"] .workspace-grid { grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr); }
html[data-embed="inline"] .workspace-grid { grid-template-columns: minmax(0, 1fr); }
html[data-embed="inline"] .app-shell { padding: 0; }
html[data-embed] #standalone-api-section { display: none; }
html[data-embed] #standalone-fields-section { display: none; }
html[data-embed] #standalone-generation-section { display: none; }
html[data-embed][data-local-preferences-open] #standalone-fields-section { display: grid; }
html[data-embed][data-local-preferences-open] #standalone-generation-section { display: grid; }
html[data-embed] #output-options { display: none; }
html[data-embed] .hosted-only-note { display: block; }
html[data-embed] .preferences-panel { top: var(--host-safe-area-top); bottom: var(--host-safe-area-bottom); }
html[data-embed] .template-manager { width: 100%; max-width: none; margin: 0; padding: 0; }
html[data-embed="full"] .template-manager { padding: var(--embed-content-top) clamp(28px, 5vw, 72px) calc(24px + var(--host-safe-area-bottom)); }
html[data-embed="full"] .template-manager { padding-bottom: 24px; }
html[data-embed] .template-manager-catalog, html[data-embed] .template-manager-editor, html[data-embed] .template-manager-preview { padding: 0; }
html[data-embed] .eyebrow,
html[data-embed] .text-button,
html[data-embed] .prompt-field-picker-trigger,
html[data-embed] .prompt-field-option:hover,
html[data-embed] .prompt-field-option:focus-visible,
html[data-embed] .template-manager .mode-button:hover,
html[data-embed] .template-manager .mode-button.is-active {
  color: var(--accent-text-color) !important;
}
html[data-embed] .template-field-remove:hover,
html[data-embed] .template-field-remove:focus-visible {
  color: var(--accent-text-color) !important;
}
html[data-embed][data-brightness="light"] #template-catalog-list .ui-icon {
  filter: var(--accent-icon-shadow);
}
html[data-embed] .prompt-field-picker-trigger .ui-icon,
html[data-embed] .template-manager-close .ui-icon {
  filter: var(--accent-icon-shadow);
}
html[data-embed] .template-field-remove:hover .ui-icon,
html[data-embed] .template-field-remove:focus-visible .ui-icon {
  filter: var(--accent-icon-shadow);
}
html[data-embed] .template-manager .template-editor-mode .mode-button.is-active { color: var(--text) !important; }

@media (max-width: 920px) {
  .workspace-grid { grid-template-columns: 1fr; }
  html[data-embed="full"] .workspace-grid { grid-template-columns: 1fr; }
  .result-column { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .template-manager-grid { grid-template-areas: "catalog" "editor" "preview"; grid-template-columns: 1fr; grid-template-rows: auto; }
}

@media (max-width: 640px) {
  .app-shell { padding-top: 30px; }
  .result-column { grid-template-columns: 1fr; }
  .option-grid, .template-fields, .preferences-output-grid { grid-template-columns: 1fr; }
  .template-output-grid { grid-template-columns: 1fr 1fr; }
  .template-output-grid .field-wide { grid-column: 1 / -1; }
  .history-item { grid-template-columns: 70px minmax(0, 1fr); }
  .history-thumb-wrap, .history-thumb-wrap img, .history-thumb-empty { min-height: 70px; }
  .history-list:not(.is-expanded) > .history-item:nth-child(n + 4) { display: none; }
  #history-show-all:not([hidden]) { display: block; width: fit-content; }
  #app-direct-footer { display: block; }
  .template-manager { padding-top: 30px; }
  html[data-embed="full"] .app-shell { padding-inline: 20px; }
  html[data-embed="full"] .template-manager { padding-inline: 20px; }
}

@media (max-width: 420px) {
  .result-actions { gap: 1px; }
  .result-actions > button { min-width: 26.67px; width: 26.67px; flex-basis: 26.67px; font-size: var(--icon-size-action); }
  .result-actions > .favorite-button { min-width: 40px; width: 40px; flex-basis: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .status, .status[data-state="open"], .status[data-state="closed"] { animation: none; transition: opacity 0ms; }
}
