html.wynntils-overlay-editor-standalone {
  min-width: 320px;
  scroll-behavior: smooth;
}

body.wynntils-overlay-editor-standalone {
  margin: 0;
  min-height: 100vh;
}

body.wynntils-overlay-editor-standalone > #wynntils-overlay-editor {
  min-height: 100vh;
}

#wynntils-overlay-editor {
  color-scheme: light dark;
  --woe-bg: #09111c;
  --woe-surface: #111d2b;
  --woe-surface-raised: #172638;
  --woe-border: #2a3d54;
  --woe-border-soft: #1d2d40;
  --woe-text: #edf5ff;
  --woe-muted: #9aabc0;
  --woe-accent: #65e1d5;
  --woe-accent-strong: #1eaaa1;
  --woe-warning: #f4c76c;
  --woe-danger: #ff7886;
  --woe-radius: 10px;
  --woe-page-gradient: linear-gradient(180deg, #0c1725 0, var(--woe-bg) 34rem);
  --woe-input: #0a1421;
  --woe-code: #0b1724;
  --woe-code-text: #d7e2ef;
  --woe-placeholder: #687b91;
  --woe-border-hover: #42617a;
  --woe-subtle: rgba(255, 255, 255, 0.04);
  --woe-subtle-hover: rgba(255, 255, 255, 0.08);
  --woe-result: #0c1724;
  --woe-result-hover: #102432;
  --woe-toggle: #334558;
  --woe-toggle-thumb: #c4d0dd;
  --woe-on-accent: #06211f;
  --woe-warning-surface: rgba(244, 199, 108, 0.08);
  --woe-danger-surface: var(--woe-danger-surface-strong);
  --woe-dialog: #0b1623;
  --woe-dialog-section: #0e1b2a;
  --woe-message-area: #09131f;
  --woe-message: #111f2e;
  --woe-message-user: #102b2c;
  --woe-toast: #102a2a;
  --woe-syntax-format: #ff8fad;
  --woe-syntax-variable: #8fb9ff;
  --woe-syntax-string: #d9c08c;
  --woe-syntax-number: #c49af8;
  --woe-syntax-escape: #7bd5b2;
  --woe-preview: linear-gradient(180deg, #17324b 0, #10253a 64%, #0b1725 64.5%);
  --woe-panel-overlay: rgba(17, 29, 43, 0.86);
  --woe-shadow: rgba(0, 0, 0, 0.3);
  --woe-selection: rgba(101, 225, 213, 0.28);
  --woe-accent-surface: rgba(30, 170, 161, 0.12);
  --woe-accent-surface-strong: rgba(30, 170, 161, 0.22);
  --woe-danger-border: rgba(255, 120, 134, 0.55);
  --woe-danger-surface-strong: rgba(102, 31, 43, 0.22);
  --woe-warning-border: rgba(244, 199, 108, 0.55);
  --woe-subtle-border: rgba(255, 255, 255, 0.12);
  --woe-glyph-surface: #0f2030;
  --woe-inline-code: rgba(4, 12, 22, 0.55);
  --woe-accent-border: rgba(101, 225, 213, 0.45);
  --woe-backdrop: rgba(2, 8, 14, 0.78);
  color: var(--woe-text);
  background: var(--woe-page-gradient);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: light) {
  #wynntils-overlay-editor {
    --woe-bg: #f4f7fa;
    --woe-surface: #ffffff;
    --woe-surface-raised: #eaf0f5;
    --woe-border: #c5d1dc;
    --woe-border-soft: #dce5ec;
    --woe-text: #172332;
    --woe-muted: #5f7182;
    --woe-accent: #087f78;
    --woe-accent-strong: #08645f;
    --woe-warning: #96600a;
    --woe-danger: #b52e42;
    --woe-page-gradient: linear-gradient(180deg, #ffffff 0, var(--woe-bg) 34rem);
    --woe-input: #ffffff;
    --woe-code: #f1f5f8;
    --woe-code-text: #203142;
    --woe-placeholder: #718394;
    --woe-border-hover: #8298aa;
    --woe-subtle: rgba(23, 35, 50, 0.05);
    --woe-subtle-hover: rgba(23, 35, 50, 0.1);
    --woe-result: #f7f9fb;
    --woe-result-hover: #e7f2f1;
    --woe-toggle: #9cadba;
    --woe-toggle-thumb: #ffffff;
    --woe-on-accent: #ffffff;
    --woe-warning-surface: rgba(150, 96, 10, 0.08);
    --woe-danger-surface: rgba(181, 46, 66, 0.08);
    --woe-dialog: #ffffff;
    --woe-dialog-section: #f3f6f8;
    --woe-message-area: #f7f9fb;
    --woe-message: #ffffff;
    --woe-message-user: #e6f4f2;
    --woe-toast: #e2f2ef;
    --woe-syntax-format: #b12858;
    --woe-syntax-variable: #255fab;
    --woe-syntax-string: #76581d;
    --woe-syntax-number: #7043a3;
    --woe-syntax-escape: #167154;
    --woe-preview: linear-gradient(180deg, #dcecf3 0, #c6dce5 64%, #b5cbd2 64.5%);
    --woe-panel-overlay: rgba(255, 255, 255, 0.92);
    --woe-shadow: rgba(23, 35, 50, 0.18);
    --woe-selection: rgba(8, 127, 120, 0.2);
    --woe-accent-surface: rgba(8, 127, 120, 0.1);
    --woe-accent-surface-strong: rgba(8, 127, 120, 0.16);
    --woe-danger-border: rgba(181, 46, 66, 0.45);
    --woe-danger-surface-strong: rgba(181, 46, 66, 0.1);
    --woe-warning-border: rgba(150, 96, 10, 0.42);
    --woe-subtle-border: rgba(23, 35, 50, 0.14);
    --woe-glyph-surface: #f4f7fa;
    --woe-inline-code: rgba(23, 35, 50, 0.08);
    --woe-accent-border: rgba(8, 127, 120, 0.35);
    --woe-backdrop: rgba(23, 35, 50, 0.28);
  }
}

#wynntils-overlay-editor * {
  box-sizing: border-box;
}
#wynntils-overlay-editor button,
#wynntils-overlay-editor input,
#wynntils-overlay-editor select,
#wynntils-overlay-editor textarea {
  font: inherit;
}
#wynntils-overlay-editor button {
  color: inherit;
}
#wynntils-overlay-editor button:focus-visible,
#wynntils-overlay-editor input:focus-visible,
#wynntils-overlay-editor select:focus-visible,
#wynntils-overlay-editor textarea:focus-visible,
#wynntils-overlay-editor .advanced-summary:focus-visible {
  outline: 2px solid var(--woe-accent);
  outline-offset: 2px;
}

#wynntils-overlay-editor {
  .page-tools {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  .language-button {
    min-width: 40px;
    min-height: 36px;
    border: 1px solid var(--woe-border);
    border-radius: 8px;
    background: transparent;
    color: var(--woe-accent);
    cursor: pointer;
    font-weight: 800;
  }

  .workspace {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 14px 0 56px;
    container: workspace / inline-size;
  }
  h1,
  h2 {
    margin: 0;
    letter-spacing: 0;
  }
  .editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(380px, 0.8fr);
    grid-template-areas:
      'form preview'
      'form search';
    gap: 18px;
    align-items: start;
  }
  .panel {
    border: 1px solid var(--woe-border);
    border-radius: var(--woe-radius);
    background: var(--woe-surface);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.16);
  }
  .form-panel,
  .search-panel,
  .preview-panel {
    padding: 22px;
  }
  .form-panel {
    grid-area: form;
  }
  .search-panel {
    grid-area: search;
  }
  .preview-panel {
    position: sticky;
    z-index: 4;
    top: 14px;
    grid-area: preview;
  }
  .section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
  }
  .section-heading h1,
  .section-heading h2 {
    font-size: 21px;
  }
  .validation-dot {
    width: 11px;
    height: 11px;
    margin-top: 8px;
    border-radius: 50%;
    background: var(--woe-accent);
    box-shadow: 0 0 14px rgba(101, 225, 213, 0.6);
  }
  .validation-dot.invalid {
    background: var(--woe-danger);
    box-shadow: 0 0 14px rgba(255, 120, 134, 0.55);
  }
  .draft-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -4px 0 16px;
    padding: 10px 12px;
    border: 1px solid rgba(244, 199, 108, 0.55);
    border-radius: 8px;
    color: var(--woe-text);
    background: var(--woe-warning-surface);
    font-size: 12px;
  }
  .draft-notice[hidden] {
    display: none;
  }
  .draft-notice p {
    margin: 0;
  }
  .draft-notice-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
  }
  .field {
    display: grid;
    gap: 7px;
    margin-top: 17px;
    color: var(--woe-muted);
    font-size: 12px;
  }
  .field:first-child {
    margin-top: 0;
  }
  .field-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    color: var(--woe-text);
    font-size: 12px;
    font-weight: 700;
  }
  .field-label em {
    color: var(--woe-warning);
    font-size: 10px;
    font-style: normal;
    font-weight: 600;
  }
  .field-grid {
    display: grid;
    gap: 13px;
  }
  .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  input,
  select,
  textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    color: var(--woe-text);
    background: var(--woe-input);
    padding: 10px 11px;
  }
  input,
  select {
    min-height: 40px;
  }
  textarea {
    resize: vertical;
    line-height: 1.5;
  }
  textarea[name='content'] {
    font:
      12px/1.55 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
  }
  .content-editor {
    position: relative;
    min-width: 0;
  }
  .content-highlight,
  #contentInput {
    min-height: 420px;
    margin: 0;
    padding: 10px 11px;
    border: 1px solid transparent;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    scrollbar-gutter: stable;
    tab-size: 2;
    font-kerning: none;
    font-variant-ligatures: none;
    letter-spacing: 0;
    word-spacing: 0;
    font:
      12px/1.55 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
  }
  .content-highlight {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    border-radius: 7px;
    color: var(--woe-code-text);
    background: var(--woe-input);
    pointer-events: none;
    user-select: none;
  }
  #contentHighlight {
    font: inherit;
  }
  #contentInput {
    display: block;
    z-index: 1;
    position: relative;
    resize: vertical;
  }
  &.syntax-highlighting #contentInput {
    color: transparent;
    caret-color: var(--woe-text);
    background: transparent;
  }
  &.syntax-highlighting #contentInput::placeholder {
    color: var(--woe-placeholder);
    opacity: 1;
  }
  &.syntax-highlighting #contentInput::selection {
    color: transparent;
    background: var(--woe-selection);
  }
  .syntax-format {
    color: var(--woe-syntax-format);
  }
  .syntax-brace {
    color: var(--woe-warning);
  }
  .syntax-function {
    color: var(--woe-accent);
  }
  .syntax-variable {
    color: var(--woe-syntax-variable);
  }
  .syntax-string {
    color: var(--woe-syntax-string);
  }
  .syntax-number,
  .syntax-boolean {
    color: var(--woe-syntax-number);
  }
  .syntax-punctuation {
    color: var(--woe-muted);
  }
  .syntax-escape {
    color: var(--woe-syntax-escape);
  }
  .syntax-glyph {
    position: relative;
    display: inline;
    color: transparent;
    font-weight: 400;
    text-align: center;
  }
  .syntax-glyph::before {
    content: attr(data-glyph);
    position: absolute;
    inset: 0;
    color: var(--woe-warning);
    font-weight: 700;
  }
  .syntax-error {
    color: var(--woe-danger);
    text-decoration: underline wavy rgba(255, 120, 134, 0.8);
    text-underline-offset: 3px;
  }
  textarea[name='content'] {
    min-height: 420px;
  }
  input:hover,
  select:hover,
  textarea:hover {
    border-color: var(--woe-border-hover);
  }
  .help {
    color: var(--woe-muted);
    font-size: 11px;
    line-height: 1.5;
  }
  .error {
    min-height: 15px;
    color: var(--woe-danger);
    font-size: 11px;
    line-height: 1.35;
  }
  [aria-invalid='true'] {
    border-color: var(--woe-danger) !important;
    box-shadow: 0 0 0 2px rgba(255, 120, 134, 0.1);
  }
  .checkbox-field {
    align-content: start;
  }
  .toggle-row {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--woe-text);
  }
  .toggle-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
  }
  .toggle-row input:focus-visible + .toggle {
    outline: 2px solid var(--woe-accent);
    outline-offset: 2px;
  }
  .toggle {
    width: 42px;
    height: 24px;
    position: relative;
    border-radius: 999px;
    background: var(--woe-toggle);
    transition: 0.15s;
  }
  .toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--woe-toggle-thumb);
    transition: 0.15s;
  }
  .toggle-row input:checked + .toggle {
    background: var(--woe-accent-strong);
  }
  .toggle-row input:checked + .toggle::after {
    transform: translateX(18px);
    background: white;
  }
  .toggle-value {
    color: var(--woe-text);
    font-size: 12px;
  }
  .advanced-settings {
    margin-top: 17px;
    border: 1px solid var(--woe-border);
    border-radius: 8px;
    background: var(--woe-subtle);
  }
  .advanced-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 13px;
    color: var(--woe-accent);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }
  .advanced-summary::-webkit-details-marker {
    display: none;
  }
  .advanced-summary::after {
    content: '';
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    opacity: 0.7;
    transition: transform 0.15s ease;
  }
  .advanced-settings[open] .advanced-summary::after {
    transform: rotate(180deg);
  }
  .advanced-body {
    padding: 6px 13px 13px;
    border-top: 1px solid var(--woe-border-soft);
  }
  .advanced-body > .field-grid + .field-grid {
    margin-top: 16px;
  }
  .validation-message {
    min-height: 20px;
    margin-top: 18px;
    color: var(--woe-accent);
    font-size: 12px;
  }
  .validation-message ul {
    margin: 7px 0 0;
    padding-left: 18px;
  }
  .lint-issue-button {
    width: 100%;
    padding: 3px 5px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .lint-issue-button:hover {
    background: var(--woe-subtle-hover);
  }
  .lint-issue-button:focus-visible {
    border-color: currentColor;
    outline: 2px solid var(--woe-accent);
    outline-offset: 1px;
  }

  .function-count {
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--woe-accent-surface);
    color: var(--woe-accent);
    font:
      700 11px ui-monospace,
      monospace;
  }
  .function-results {
    max-height: 310px;
    margin-top: 15px;
    overflow: auto;
    display: grid;
    gap: 7px;
    padding-right: 3px;
  }
  .function-results[hidden] {
    display: none;
  }
  .function-result {
    width: 100%;
    display: grid;
    gap: 4px;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 7px;
    text-align: left;
    cursor: pointer;
    background: var(--woe-result);
  }
  .function-result:hover,
  .function-result:focus-visible {
    border-color: var(--woe-accent-strong);
    background: var(--woe-result-hover);
  }
  .function-result strong {
    color: var(--woe-accent);
    font:
      700 12px ui-monospace,
      monospace;
  }
  .function-result span {
    color: var(--woe-text);
    font-size: 12px;
    line-height: 1.35;
  }
  .function-result small {
    overflow: hidden;
    color: var(--woe-muted);
    font:
      10px/1.4 ui-monospace,
      monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .empty-results {
    margin: 15px 0 0;
    color: var(--woe-muted);
    font-size: 12px;
  }
  .preview-frame {
    position: relative;
    height: auto;
    min-height: 210px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    background: var(--woe-preview);
  }
  .preview-frame::before {
    content: 'WYNNCRAFT';
    position: absolute;
    top: 17px;
    color: var(--woe-subtle-border);
    font:
      800 15px Georgia,
      serif;
    letter-spacing: 0.2em;
  }
  .preview-frame::after {
    content: '';
    position: absolute;
    right: 14px;
    bottom: 13px;
    left: 14px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.23);
    background: repeating-linear-gradient(
      90deg,
      var(--woe-subtle-border) 0 25px,
      transparent 25px 27px
    );
  }
  .preview-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    opacity: 0.36;
  }
  .preview-crosshair::before,
  .preview-crosshair::after {
    content: '';
    position: absolute;
    background: white;
  }
  .preview-crosshair::before {
    top: 8px;
    width: 18px;
    height: 2px;
  }
  .preview-crosshair::after {
    left: 8px;
    width: 2px;
    height: 18px;
  }
  .overlay-preview {
    z-index: 1;
    display: block;
    width: 100%;
    height: 210px;
    image-rendering: pixelated;
  }
  .preview-frame.is-fit-scaled .overlay-preview {
    outline: 1px dashed rgba(255, 120, 134, 0.6);
    outline-offset: -4px;
  }
  .preview-frame.is-fit-scaled::after {
    border-color: var(--woe-danger-border);
  }
  .preview-frame.is-paused .overlay-preview {
    opacity: 0.48;
  }
  .preview-frame.is-error {
    border-color: var(--woe-danger-border);
  }
  .preview-body > .help {
    display: block;
    margin-top: 11px;
  }
  .preview-status {
    color: var(--woe-warning);
  }
  .preview-status.is-error {
    color: var(--woe-danger);
  }
  .preview-status.is-warning {
    color: var(--woe-warning);
  }
  .preview-status[hidden] {
    display: none;
  }
  .preview-collapse-button {
    width: 34px;
    height: 34px;
    display: none;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    color: var(--woe-accent);
    background: var(--woe-input);
    cursor: pointer;
  }
  .preview-collapse-button svg {
    transition: transform 0.15s ease;
  }
  .preview-panel.is-collapsed .preview-collapse-button svg {
    transform: rotate(180deg);
  }
  .preview-panel.is-collapsed .preview-body {
    display: none;
  }
  .preview-color-note[hidden] {
    display: none;
  }

  .button {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    color: var(--woe-text);
    background: var(--woe-surface-raised);
    cursor: pointer;
    font-weight: 700;
  }
  .button:hover {
    border-color: var(--woe-border-hover);
    background: var(--woe-surface-raised);
  }
  .button.primary {
    border-color: var(--woe-accent-strong);
    color: var(--woe-on-accent);
    background: var(--woe-accent);
  }
  .button.primary:hover {
    background: var(--woe-accent);
  }
  .notice {
    margin: 12px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--woe-warning);
    border-radius: 7px;
    color: var(--woe-warning);
    background: var(--woe-warning-surface);
    font-size: 11px;
    line-height: 1.5;
  }
  .toast {
    position: fixed;
    z-index: 20;
    right: 22px;
    bottom: 22px;
    max-width: min(360px, calc(100vw - 44px));
    padding: 11px 14px;
    border: 1px solid var(--woe-accent-strong);
    border-radius: 8px;
    color: var(--woe-accent);
    background: var(--woe-toast);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: 0.18s;
    font-size: 12px;
  }
  .toast.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .startup-error {
    max-width: 720px;
    margin: 72px auto 0;
    padding: 16px 20px;
    border: 1px solid var(--woe-danger);
    color: var(--woe-danger);
    background: var(--woe-danger-surface);
  }
  .ai-entry-button {
    border-color: var(--woe-accent-border);
    color: var(--woe-accent);
    background: var(--woe-accent-surface);
  }
  .ai-entry-button:hover {
    background: var(--woe-accent-surface-strong);
  }
  .ai-entry-spark {
    margin-right: 4px;
    color: var(--woe-warning);
  }
  .ai-dialog {
    width: min(940px, calc(100vw - 32px));
    max-width: none;
    height: min(760px, calc(100dvh - 40px));
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--woe-border);
    border-radius: 12px;
    color: var(--woe-text);
    background: var(--woe-dialog);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
  }
  .ai-dialog::backdrop {
    background: var(--woe-backdrop);
    backdrop-filter: blur(5px);
  }
  .ai-shell {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
  }
  .ai-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 22px 17px;
    border-bottom: 1px solid var(--woe-border);
    background: linear-gradient(120deg, var(--woe-accent-surface), transparent 48%);
  }
  .ai-header h2 {
    font-size: 20px;
  }
  .ai-header p {
    margin: 6px 0 0;
    color: var(--woe-muted);
    font-size: 12px;
    line-height: 1.5;
  }
  .ai-icon-button {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    color: var(--woe-muted);
    background: var(--woe-subtle);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
  }
  .ai-icon-button:hover {
    border-color: var(--woe-border-hover);
    color: var(--woe-text);
  }
  .ai-settings {
    border-bottom: 1px solid var(--woe-border);
    background: var(--woe-dialog-section);
  }
  .ai-settings > summary {
    padding: 11px 22px;
    color: var(--woe-accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
  }
  .ai-settings-body {
    padding: 4px 22px 15px;
  }
  .ai-settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .ai-setting {
    min-width: 0;
    display: grid;
    grid-template-columns: 148px minmax(0, 1fr);
    align-items: center;
    gap: 6px 14px;
    color: var(--woe-text);
    font-size: 11px;
    font-weight: 700;
  }
  .ai-setting-help {
    grid-column: 2;
    color: var(--woe-muted);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
  }
  .ai-setting input,
  .ai-setting select {
    min-height: 38px;
    font:
      12px/1.4 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
  }
  .ai-model-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .ai-model-row input {
    border-radius: 7px 0 0 7px;
  }
  .ai-model-fetch {
    width: 96px;
    min-width: 96px;
    padding: 0 11px;
    border: 1px solid var(--woe-border);
    border-left: 0;
    border-radius: 0 7px 7px 0;
    color: var(--woe-accent);
    background: var(--woe-surface-raised);
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
  }
  .ai-model-fetch:hover:not(:disabled),
  .ai-key-toggle:hover {
    color: var(--woe-text);
    background: var(--woe-surface-raised);
  }
  .ai-model-fetch:disabled {
    cursor: wait;
    opacity: 0.68;
  }
  .ai-model-setting select {
    grid-column: 2;
    width: 100%;
    color: var(--woe-text);
    background: var(--woe-surface-raised);
  }
  .ai-model-status {
    grid-column: 2;
    min-height: 14px;
    color: var(--woe-muted);
    font-size: 10px;
    font-weight: 500;
    line-height: 1.4;
  }
  .ai-key-setting {
    grid-column: auto;
  }
  .ai-key-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .ai-key-row input {
    border-radius: 7px 0 0 7px;
  }
  .ai-key-toggle {
    width: 96px;
    min-width: 96px;
    padding: 0 12px;
    border: 1px solid var(--woe-border);
    border-left: 0;
    border-radius: 0 7px 7px 0;
    color: var(--woe-accent);
    background: var(--woe-surface-raised);
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
  }
  .ai-security-note {
    margin: 10px 0 0;
    padding-left: 10px;
    border-left: 2px solid var(--woe-warning);
    color: var(--woe-muted);
    font-size: 10px;
    line-height: 1.55;
  }
  .ai-messages {
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 22px;
    background:
      linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px) 0 0 / 100% 28px,
      var(--woe-message-area);
  }
  .ai-message {
    width: fit-content;
    max-width: min(82%, 680px);
    padding: 11px 13px;
    border: 1px solid var(--woe-border-soft);
    border-radius: 9px;
    background: var(--woe-message);
  }
  .ai-message.user {
    margin-left: auto;
    border-color: var(--woe-accent-strong);
    background: var(--woe-message-user);
  }
  .ai-message.error {
    border-color: var(--woe-danger-border);
    background: var(--woe-danger-surface-strong);
  }
  .ai-message-label {
    display: block;
    margin-bottom: 5px;
    color: var(--woe-accent);
    font-size: 10px;
    font-weight: 800;
  }
  .ai-message.error .ai-message-label {
    color: var(--woe-danger);
  }
  .ai-message-body {
    margin: 0;
    color: var(--woe-text);
    overflow-wrap: anywhere;
    font:
      12px/1.6 Inter,
      ui-sans-serif,
      system-ui,
      sans-serif;
  }
  .ai-message.user .ai-message-body,
  .ai-message.error .ai-message-body,
  .ai-message-body p {
    white-space: pre-wrap;
  }
  .ai-message-body > :first-child {
    margin-top: 0;
  }
  .ai-message-body > :last-child {
    margin-bottom: 0;
  }
  .ai-message-body p,
  .ai-message-body ul,
  .ai-message-body .ai-markdown-code {
    margin: 0 0 9px;
  }
  .ai-message-body ul {
    padding-left: 20px;
  }
  .ai-message-body strong {
    color: var(--woe-text);
    font-weight: 800;
  }
  .ai-inline-code,
  .ai-markdown-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }
  .ai-inline-code {
    padding: 1px 4px;
    border: 1px solid rgba(93, 226, 215, 0.2);
    border-radius: 4px;
    color: var(--woe-accent);
    background: var(--woe-inline-code);
  }
  .ai-markdown-code {
    max-width: 100%;
    padding: 10px 12px;
    overflow: auto;
    border: 1px solid var(--woe-border);
    border-radius: 7px;
    color: var(--woe-text);
    background: var(--woe-code);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.55;
  }
  .ai-proposal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 22px;
    border-top: 1px solid var(--woe-accent-border);
    color: var(--woe-accent);
    background: var(--woe-accent-surface);
    font-size: 11px;
    font-weight: 700;
  }
  .ai-proposal[hidden] {
    display: none;
  }
  .ai-proposal .button {
    min-height: 34px;
  }
  .ai-composer {
    padding: 14px 22px 17px;
    border-top: 1px solid var(--woe-border);
    background: var(--woe-dialog-section);
  }
  .ai-composer textarea {
    min-height: 78px;
    max-height: 180px;
    resize: vertical;
    font-size: 12px;
  }
  .ai-composer-footer {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 9px;
  }
  .ai-status {
    color: var(--woe-muted);
    font-size: 10px;
    line-height: 1.4;
  }
  .ai-composer-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
  }
  .ai-composer-actions .button {
    min-height: 34px;
    font-size: 11px;
  }
  .ai-composer-actions [hidden] {
    display: none;
  }

  @container workspace (max-width: 880px) {
    .editor-grid {
      grid-template-columns: 1fr;
      grid-template-areas:
        'preview'
        'form'
        'search';
    }
    .preview-panel {
      position: relative;
      z-index: 4;
      top: auto;
    }
  }
  @media (max-width: 768px) {
    .page-tools,
    .workspace {
      width: min(100% - 24px, 680px);
    }
    .preview-panel {
      padding: 12px 14px;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
    }
    .preview-panel .section-heading {
      align-items: center;
      margin-bottom: 10px;
    }
    .preview-collapse-button {
      display: grid;
    }
    .preview-frame,
    .overlay-preview {
      height: 132px;
      min-height: 132px;
    }
    .ai-dialog {
      width: calc(100vw - 16px);
      height: calc(100dvh - 16px);
    }
    .ai-settings-grid {
      grid-template-columns: 1fr;
    }
    .ai-setting {
      grid-template-columns: minmax(0, 1fr);
      align-items: stretch;
      gap: 6px;
    }
    .ai-setting-help,
    .ai-model-setting select,
    .ai-model-status {
      grid-column: auto;
    }
  }
  @media (max-width: 720px) {
    .page-tools,
    .workspace {
      width: min(100% - 20px, 580px);
    }
    textarea[name='content'] {
      min-height: 340px;
    }
    .content-highlight,
    #contentInput {
      min-height: 340px;
    }
    .form-panel,
    .search-panel,
    .preview-panel {
      padding: 16px;
    }
    .field-grid.two {
      grid-template-columns: 1fr;
      gap: 0;
    }
    .ai-dialog {
      width: 100vw;
      height: 100dvh;
      border: 0;
      border-radius: 0;
    }
    .ai-header {
      padding: 15px 16px 13px;
    }
    .ai-settings > summary {
      padding: 10px 16px;
    }
    .ai-settings-body,
    .ai-messages,
    .ai-composer {
      padding-right: 16px;
      padding-left: 16px;
    }
    .ai-message {
      max-width: 92%;
    }
    .ai-proposal {
      align-items: stretch;
      flex-direction: column;
      padding: 10px 16px;
    }
    .ai-composer-footer {
      align-items: stretch;
      flex-direction: column;
    }
    .ai-composer-actions {
      justify-content: flex-end;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      scroll-behavior: auto !important;
      transition: none !important;
    }
  }

  /* function category browsing */
  .function-category {
    border: 1px solid var(--woe-border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
  }
  .function-category-summary {
    cursor: pointer;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--woe-accent);
    background: var(--woe-subtle);
    list-style: none;
  }
  .function-category-summary::-webkit-details-marker {
    display: none;
  }
  .function-category[open] .function-category-summary {
    border-bottom: 1px solid var(--woe-border);
  }
  .category-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
  }
  /* mini toolbar buttons */
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 8px 0 0;
  }
  .content-color-tool {
    min-height: 29px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding-left: 9px;
    border: 1px solid var(--woe-border);
    border-radius: 6px;
    color: var(--woe-muted);
    background: var(--woe-subtle);
    font-size: 11px;
    font-weight: 600;
  }
  .content-color-picker {
    width: 30px;
    min-width: 30px;
    min-height: 27px;
    padding: 3px;
    border-width: 0 0 0 1px;
    border-radius: 0;
    cursor: pointer;
  }
  .content-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
  }
  .content-color-picker::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 3px;
  }
  .content-color-picker::-moz-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 3px;
  }
  .content-color-tool .mini-button {
    align-self: stretch;
    margin: -1px -1px -1px 0;
    border-radius: 0 6px 6px 0;
  }
  .mini-button {
    font: 600 11px/1 inherit;
    padding: 6px 10px;
    border: 1px solid var(--woe-border);
    border-radius: 6px;
    background: var(--woe-subtle);
    color: var(--woe-accent);
    cursor: pointer;
  }
  .mini-button:hover {
    border-color: var(--woe-accent);
  }

  .glyph-entry-button {
    border-color: var(--woe-warning-border);
    color: var(--woe-warning);
  }
  .glyph-picker[hidden] {
    display: none;
  }
  .glyph-picker {
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--woe-border);
    border-radius: 8px;
    background:
      linear-gradient(135deg, rgba(101, 225, 213, 0.055), transparent 42%), var(--woe-code);
    box-shadow: inset 3px 0 0 rgba(244, 199, 108, 0.72);
  }
  .glyph-picker-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
  }
  .glyph-picker-heading h3,
  .glyph-group h4 {
    margin: 0;
  }
  .glyph-picker-heading h3 {
    color: var(--woe-text);
    font-size: 13px;
  }
  .glyph-picker-heading p {
    max-width: 720px;
    margin: 5px 0 0;
    color: var(--woe-muted);
    font-size: 10px;
    line-height: 1.55;
  }
  .glyph-picker-close {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--woe-border);
    border-radius: 6px;
    color: var(--woe-muted);
    background: var(--woe-subtle);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
  }
  .glyph-picker-close:hover,
  .glyph-button:hover,
  .glyph-control-button:hover {
    border-color: var(--woe-accent);
    color: var(--woe-text);
    background: var(--woe-accent-surface-strong);
  }
  .glyph-group {
    min-width: 0;
    margin-top: 13px;
  }
  .glyph-group h4 {
    margin-bottom: 6px;
    color: var(--woe-muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .glyph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 4px;
  }
  .glyph-button,
  .glyph-control-button {
    min-width: 0;
    min-height: 42px;
    padding: 5px 3px;
    border: 1px solid var(--woe-border);
    border-radius: 5px;
    color: var(--woe-text);
    background: var(--woe-glyph-surface);
    cursor: pointer;
  }
  .glyph-button {
    display: grid;
    place-content: center;
    gap: 2px;
  }
  .glyph-button strong {
    color: var(--woe-warning);
    font:
      800 14px/1 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
  }
  .glyph-button small,
  .glyph-control-button small {
    overflow: hidden;
    color: var(--woe-muted);
    font:
      7px/1 ui-monospace,
      SFMono-Regular,
      Menlo,
      monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .glyph-picker-lower {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(250px, 0.8fr);
    gap: 12px;
  }
  .glyph-control-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  .glyph-control-button {
    display: grid;
    align-content: center;
    gap: 4px;
    padding-inline: 8px;
    text-align: left;
  }
  .glyph-control-button strong {
    overflow: hidden;
    color: var(--woe-accent);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 720px) {
    .glyph-picker {
      padding: 12px;
    }
    .glyph-picker-lower {
      grid-template-columns: 1fr;
      gap: 0;
    }
    .glyph-grid {
      grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    }
  }
}
