:root {
  color-scheme: light;
  --gray-0: 0, 0, 0;
  --gray-16: 16, 16, 16;
  --gray-34: 34, 34, 34;
  --gray-56: 56, 56, 56;
  --gray-80: 80, 80, 80;
  --gray-110: 110, 110, 110;
  --gray-136: 136, 136, 136;
  --gray-168: 168, 168, 168;
  --gray-200: 200, 200, 200;
  --gray-222: 222, 222, 222;
  --gray-236: 236, 236, 236;
  --gray-245: 245, 245, 245;
  --gray-250: 250, 250, 250;
  --gray-255: 255, 255, 255;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --gray-0: 255, 255, 255;
  --gray-16: 245, 245, 245;
  --gray-34: 230, 230, 230;
  --gray-56: 212, 212, 212;
  --gray-80: 190, 190, 190;
  --gray-110: 164, 164, 164;
  --gray-136: 128, 128, 128;
  --gray-168: 96, 96, 96;
  --gray-200: 65, 65, 65;
  --gray-222: 42, 42, 42;
  --gray-236: 28, 28, 28;
  --gray-245: 19, 19, 19;
  --gray-250: 13, 13, 13;
  --gray-255: 0, 0, 0;
}

.tavern-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tavern-tool-note { margin: 0 0 12px; color: var(--fg-2); overflow-wrap: anywhere; }
.tavern-action[aria-pressed='true'] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tavern-message-controls { display: flex; align-items: center; gap: 2px; align-self: flex-end; margin-bottom: 2px; }
.tavern-message-controls small { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.tavern-message-controls .tavern-action { min-width: 32px; min-height: 32px; padding: 0 5px; }
.tavern-message-controls .tavern-action:disabled { opacity: .4; }
.tavern-advanced { margin: 10px 0 16px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.tavern-advanced summary { cursor: pointer; font-weight: 650; }
.tavern-advanced[open] summary { margin-bottom: 10px; }
.tavern-advanced .field:last-child { margin-bottom: 0; }
.tavern-rule-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tavern-rule-fields input { width: 100%; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); color: var(--fg); }
.h5-square-searchbar { display: flex; align-items: flex-start; gap: 6px; }
.h5-square-searchbar .h5-search { flex: 1; min-width: 0; }
.h5-square-genres { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }

@media (max-width: 780px) {
  .h5-active, .h5-active .app, .h5-active .messages,
  .h5-active .h5-nav, .h5-active .h5-drawer, .h5-active .composer-wrap,
  .h5-active .sheet, .h5-active[data-h5-page='post'] #postSheet { background: var(--bg); }
  .h5-active .h5-nav { box-shadow: none; }
  .h5-active .h5-section-head h2::before { background: var(--fg); }
  .h5-active .h5-create-grid .h5-tile,
  .h5-active :is(.h5-sticker, .h5-hero, .h5-avatar, .h5-profile-avatar) { background: var(--bg-soft); border-color: var(--line); }
  .h5-active :is(.h5-sticker, .h5-hero-art, .h5-nav-item .h5-icon) { box-shadow: none; filter: none; color: currentColor; }
  .h5-active :is(.h5-primary, .h5-chip.selected, .h5-post-action),
  .h5-active #sendBtn:not(:disabled), .h5-active .sheet .save-btn { background: var(--fg); color: var(--bg); border-color: var(--fg); }
  .h5-active .h5-post-card { color: #fff; background: #252525; }
  .h5-active .h5-post-cover::after { background: linear-gradient(transparent 32%, #0005 58%, #000e 100%); }
  .h5-active .h5-post-body .h5-tags > span { background: #000b; color: #fff; }
  .h5-active .h5-post-action { background: #fff; color: #000; }
  .h5-active .h5-chat-hero.tavern { background: var(--bg-soft); border-color: var(--line); }
  .h5-active .h5-chat-hero.tavern :is(.h5-text strong, .h5-text small, .h5-scenario) { color: var(--fg); }
  .h5-active .messages .row:has(.tavern-message-controls) { flex-wrap: wrap; }
  .h5-active .messages .tavern-message-controls { flex-basis: 100%; margin-inline: 33px 0; }
  .h5-active .messages .row.me .tavern-message-controls { justify-content: flex-end; margin-inline: 0; }
  .h5-active .tavern-message-controls .tavern-action { min-width: 38px; min-height: 34px; }
  .h5-active #tavernToolsSheet .tavern-action { min-height: 44px; }
}
