/* Shared reading-size and narrow-screen adjustments. Brand artwork and navigation remain unchanged. */
:root {
  --wt-control-size: .82rem;
  --wt-caption-size: .74rem;
  --wt-touch-size: max(44px, 2.35rem);
  --wt-panel-gap: clamp(8px, .6rem, 15px);
}
.wt-home-state { margin: .35rem 0 .7rem; color: #c8d4c3; font-size: .76rem; line-height: 1.5; overflow-wrap: anywhere; }
#mtRevisionInput[hidden], #mtRevisionGenerate[hidden] { display: none !important; }

button, input, textarea, select { max-width: 100%; }
button { touch-action: manipulation; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
:is(button, a, input, textarea, select, [role="button"]):focus-visible {
  outline: 2px solid #e9d099;
  outline-offset: 2px;
}

/* Important labels and user content must grow instead of being clipped. */
.history-tabs { gap: var(--wt-panel-gap); }
.history-tabs button {
  min-height: var(--wt-touch-size);
  padding: .4rem .35rem;
  font-size: var(--wt-control-size);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}
.history-bulk-toolbar { gap: var(--wt-panel-gap); padding: .55rem; font-size: var(--wt-control-size); }
.history-bulk-toolbar button, .history-btn {
  min-height: var(--wt-touch-size);
  padding: .45rem .65rem;
  font-size: var(--wt-control-size);
  line-height: 1.35;
  white-space: normal;
}
.history-bulk-toolbar span, .history-toolbar-note { white-space: normal; overflow-wrap: anywhere; }
.history-close, .mt-close { min-width: var(--wt-touch-size); min-height: var(--wt-touch-size); }
.history-item-title, .mt-collection-title, .mt-recent-text {
  white-space: normal;
  text-overflow: clip;
  overflow: visible;
  overflow-wrap: anywhere;
}
.history-item-meta, .mt-collection-meta { font-size: var(--wt-caption-size); line-height: 1.5; }
.mt-collection-actions button, .mt-history-actions button {
  min-height: var(--wt-touch-size);
  padding: .4rem .6rem;
  font-size: var(--wt-control-size);
  white-space: normal;
}
.mt-novel-item .mt-collection-actions button { white-space: normal; }
.mt-recent-item { height: auto; min-height: var(--wt-touch-size); }
.mt-recent-text { line-height: 1.55; }
.mt-story-body, .fx-legacy-result pre { overflow-wrap: anywhere; }
.fx-legacy-result pre { font-size: var(--wt-control-size); }

/* Controls scale with the text they contain. */
.mt-heading-actions, .mt-recent-links, .mt-result-actions, .bf-header-actions { flex-wrap: wrap; }
.mt-heading-actions button, .mt-recent-links button,
#mtHistoryClose, html.metamorph-open #historyClose,
.bf-header-actions .bf-export-text {
  min-width: 0;
  min-height: var(--wt-touch-size);
  padding: .4rem .75rem;
  font-size: var(--wt-control-size);
  line-height: 1.35;
  white-space: normal;
}
.bf-header h3 { white-space: normal; overflow-wrap: anywhere; }
.mt-loading-copy h2 { white-space: normal; }
.mt-revision textarea, #metamorphInput { font-size: max(16px, .9rem); }

/* Overlays can be read and dismissed even with large text or a short viewport. */
.share-panel-card, .wt-export-card, .wt-generation-card, .mt-novel-menu-card,
.mt-entry-review-card, .mt-history-card, #wtSiteDialog {
  box-sizing: border-box;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.share-panel-head h2 { font-size: 1.3rem; }
.share-panel-preview { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); }
.share-panel-preview img { width: 100%; height: auto; aspect-ratio: 1; }
.share-panel-preview h3 { font-size: .95rem; overflow-wrap: anywhere; }
.share-panel-preview p, .share-panel-link-label, .share-panel-status,
#sharePanelLink { font-size: var(--wt-control-size); }
.share-panel-preview small { font-size: var(--wt-caption-size); }
.share-panel-actions button { min-height: var(--wt-touch-size); font-size: var(--wt-control-size); }
#wtSiteDialog { font-size: .88rem; }
#wtSiteDialog h2 { font-size: 1.4rem; }
#wtSiteDialog button { min-height: var(--wt-touch-size); }
.wt-generation-card p, .wt-export-card p { overflow-wrap: anywhere; }
.wt-generation-card :is(button, a), .wt-export-actions button, .mt-novel-menu-card button {
  min-height: var(--wt-touch-size);
  font-size: var(--wt-control-size);
  white-space: normal;
}

@media (max-width: 900px) {
  .mobile-tabbar { min-height: calc(68px + env(safe-area-inset-bottom)); }
  .mobile-tabbar a {
    min-width: 0 !important;
    min-height: 52px;
    padding: .25rem .1rem;
    font-size: clamp(10px, .64rem, 15px);
    line-height: 1.2;
    overflow-wrap: anywhere;
    text-align: center;
  }
  .mobile-text-size-menu { width: max(138px, 8rem); max-width: calc(100vw - 24px); }
  .mobile-text-size-menu button { min-height: var(--wt-touch-size); font-size: var(--wt-control-size); }
  #quickTools > [data-quick-label] { width: max(142px, 8.5rem); min-height: var(--wt-touch-size); }
  #quickTools .quick-label { font-size: var(--wt-control-size) !important; white-space: normal; }
  .mt-shell, .mt-result-shell { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .bf-header { grid-template-columns: minmax(0, 1fr) auto; }
  .bf-header-actions { min-width: 0; justify-content: flex-end; }
  .bf-header .bf-round { min-width: 0; }
}

@media (max-width: 430px) {
  .supervise-box { grid-template-columns: minmax(0, 1fr); }
  .supervise-label, .supervise-box select, .supervise-hint { grid-column: 1; }
  .supervise-label { min-height: var(--wt-touch-size); white-space: normal; }
  .history-tabs { gap: 3px; padding-inline: 6px; }
  .history-tabs button { padding-inline: 2px; }
  .share-panel-preview { grid-template-columns: minmax(0, 4.5rem) minmax(0, 1fr); gap: .6rem; }
  .share-panel-actions button { flex: 1 1 auto; }
  .wt-export-actions { grid-template-columns: minmax(0, 1fr); }
  .wt-export-actions button[data-export="close"] { grid-column: 1; }
  .mt-heading-actions { max-width: 100%; }
}

@media (max-width: 380px) {
  .history-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .share-panel-preview { grid-template-columns: minmax(0, 1fr); }
  .share-panel-preview img { width: min(110px, 100%); }
}
@media (max-width: 430px) {
  html[data-text-size="xlarge"] .history-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-text-size="xlarge"] .share-panel-preview { grid-template-columns: minmax(0, 1fr); }
}

@media (max-height: 560px) {
  .share-panel-card, .wt-export-card, .wt-generation-card, .mt-novel-menu-card,
  .mt-entry-review-card, .mt-history-card, #wtSiteDialog { max-height: calc(100dvh - 12px); }
}

@media (prefers-reduced-motion: reduce) {
  .floating-corner.is-open > [data-quick-label], .mt-recent-item,
  .wt-generation-orbit { animation: none !important; transition-duration: .01ms !important; }
}
