/* WorldTree V2.1: a shared navigation and compact tool system. */
.desktop-nav,
html.metamorph-open .desktop-nav {
  color: #d8d5c7;
  border-color: rgba(193, 168, 117, .32);
  background: linear-gradient(180deg, rgba(11, 24, 26, .98), rgba(7, 18, 22, .98));
}
.desktop-nav nav a,
.desktop-nav .nav-feature,
html.metamorph-open .desktop-nav nav a,
html.metamorph-open .desktop-nav .nav-feature { color: #bfc7be; }
.desktop-nav nav a span,
.desktop-nav .nav-feature span,
.mobile-tabbar .tb-ico { color: #c9b477; font-weight: 400; }
.desktop-nav nav a.active,
.desktop-nav .nav-feature.active,
html.metamorph-open .desktop-nav nav a.active,
html.metamorph-open .desktop-nav .nav-feature.active {
  color: #f5e5ba;
  border-color: rgba(212, 186, 124, .52);
  background: rgba(196, 169, 99, .12);
}
#quickTools { gap: 8px; }
#quickTools > [data-quick-label],
#quickTools #metamorphEntry {
  width: 70px; height: 70px; margin: 0; padding: 7px 3px 5px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  border: 1px solid rgba(209, 181, 128, .38); border-radius: 13px;
  background: rgba(10, 27, 24, .9); color: #e4d4ac;
  box-shadow: 0 5px 16px rgba(0,0,0,.22), inset 0 1px rgba(255,255,255,.045);
  backdrop-filter: blur(14px); transition: transform .18s, border-color .18s, background .18s;
}
#quickTools > [data-quick-label]:hover,
#quickTools > [data-quick-label]:focus-visible {
  transform: translateY(-2px); border-color: rgba(238, 211, 160, .7);
  background: rgba(22, 42, 35, .95); box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
#quickTools > [data-quick-label].is-current { border-color: rgba(241, 213, 151, .7); background: rgba(47, 53, 36, .95); }
#quickTools .quick-svg,
#quickToolsToggle svg { display: block; width: 24px; height: 24px; fill: none; stroke: #e1c98e; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#quickTools .quick-label { display: block !important; margin: 6px 0 0 !important; color: #dfd2b4; font: 11px/1.15 system-ui, sans-serif !important; letter-spacing: 0 !important; text-indent: 0 !important; white-space: nowrap; }
#quickTools > [data-quick-label]::after { display: none; }
#quickToolsToggle { align-items: center; justify-content: center; }
/* The real stage images are untouched. The cropped green margins are reduced. */
.mt-stage-track { --mt-art-size: 90px; width: min(960px, 100%); margin-bottom: 10px; }
.mt-stage-track::before { top: calc(var(--mt-art-size) + 15px); background: linear-gradient(90deg, rgba(116, 187, 109, .78) 0 calc(var(--mt-progress) * 12.5%), rgba(125, 143, 145, .45) calc(var(--mt-progress) * 12.5%) 100%); }
.mt-stage-number { display: none !important; }
.mt-stage-art { border: 0; outline: 1px solid rgba(198, 186, 154, .35); outline-offset: -2px; box-shadow: 0 0 12px rgba(3, 9, 13, .45); }
.mt-stage-art img { transform: scale(1.37); }
.mt-stage.is-active .mt-stage-art { outline-color: rgba(217, 199, 138, .66); box-shadow: 0 0 15px rgba(171, 214, 112, .28); }
.mt-stage.is-current .mt-stage-art,
.mt-stage.is-selected .mt-stage-art { box-shadow: 0 0 20px rgba(214, 222, 126, .45); }
.mt-stage-dot { width: 10px; height: 10px; margin-top: 10px; border-color: rgba(158, 175, 166, .63); background: #11201f; }
.mt-stage.is-active .mt-stage-dot { border-color: #c9e09d; background: #9eca85; box-shadow: 0 0 8px rgba(119, 211, 106, .5); }
.mt-stage.is-current .mt-stage-dot,
.mt-stage.is-selected .mt-stage-dot { box-shadow: 0 0 0 2px rgba(117, 190, 100, .25), 0 0 12px rgba(145, 232, 122, .75); }
.mt-stage-status { width: 100%; margin: 0 auto 22px; color: #d1d5c5; font: .86rem/1.55 system-ui, sans-serif; text-align: center; }
.mt-stage-unknown .mt-stage-art { outline: 1px solid rgba(176, 192, 123, .5); background: radial-gradient(circle at center, #193f2a 0, #0b201f 46%, #08151d 78%); }
.mt-continuum { display: block; width: 100%; height: 100%; overflow: visible; }
.mt-continuum-ring, .mt-continuum-trail { fill: none; stroke: #c6b976; stroke-width: 3.2; stroke-linecap: round; filter: drop-shadow(0 0 3px #95b862); }
.mt-continuum-trail { stroke: #76ad75; stroke-width: 2; }
.mt-continuum-core { fill: #a7ca80; filter: drop-shadow(0 0 9px #a4d078); }
.mt-continuum-spark { fill: #f5df9e; }
.mt-stage-unknown:not(.is-active) .mt-stage-art { filter: grayscale(.4) brightness(.54); }
.mt-stage-unknown.is-active .mt-continuum-ring { stroke: #ead28a; filter: drop-shadow(0 0 5px #d7c470); }
.mt-stage-unknown.is-active .mt-continuum-core { fill: #d0ef9f; }
.mt-loading-panel { width: min(470px, 100%); padding: 27px 32px; }
.mt-loading-copy h2 { white-space: nowrap; font-size: clamp(1.85rem, 2.7vw, 2.5rem); }
.mt-loading-copy p { margin-top: 14px; }
.mt-ai-disclosure { display: inline-block; margin: 0 0 12px; padding: 5px 10px; border: 1px solid rgba(219, 186, 121, .43); border-radius: 7px; background: rgba(9, 21, 27, .84); color: #dfc892; font: .78rem/1.5 system-ui, sans-serif; }
.mt-ai-explainer { margin: 12px 0 0; color: #c5c5c1; font: .83rem/1.6 system-ui, sans-serif; }
.mt-collection-item { grid-template-columns: 33px 68px minmax(0,1fr); align-items: start; }
.mt-story-picker { display: grid; justify-items: center; gap: 4px; color: #d1c7a6; font-size: .68rem; cursor: pointer; }
.mt-story-picker input { width: 21px; height: 21px; accent-color: #a6ba78; cursor: pointer; }
.mt-selected-stories { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 12px; align-items: center; }
.mt-selected-stories strong { flex-basis: 100%; font-weight: 500; }
.mt-selected-stories button { padding: 5px 8px; border: 1px solid rgba(204, 183, 135, .45); border-radius: 8px; background: rgba(21, 38, 33, .85); color: #ead8b7; cursor: pointer; }
.mt-novel-item { grid-template-columns: 1fr; }
.mt-novel-error { color: #f1a9a0; min-height: 1.5em; }
@media (max-width: 900px) {
  .mt-shell, .mt-result-shell { width: min(680px, calc(100% - 24px)); margin-inline: auto; }
  .mt-stage-track { --mt-art-size: min(72px, calc((100vw - 60px)/4)); width: min(360px,100%); grid-template-columns: repeat(4,minmax(0,1fr)); column-gap: 7px; row-gap: 18px; margin: 24px auto 13px; }
  .mt-stage-track::before { display: none; }
  .mt-stage-art { width: var(--mt-art-size); height: var(--mt-art-size); }
  .mt-stage-dot { width: 9px; height: 9px; margin-top: 8px; }
  .mt-stage-status { max-width: min(370px,100%); margin-bottom: 18px; }
  html.metamorph-open .mt-record-card,
  html.metamorph-open .mt-recent,
  html.metamorph-open .mt-day-card,
  html.metamorph-open .mt-ai-section { width: min(560px,100%); margin-left: auto; margin-right: auto; }
  .mt-recent { margin-top: 35px; }
  .mt-loading-copy { padding: 18px; }
  .mt-loading-panel { width: min(460px,100%); padding: 23px 20px; }
  .mt-loading-copy h2 { font-size: clamp(1.55rem, 6vw, 2.15rem); }
  #quickTools { right: 8px; bottom: calc(78px + env(safe-area-inset-bottom)); flex-direction: row; gap: 5px; }
  #quickTools > [data-quick-label], #quickTools #metamorphEntry { width: 48px; height: 48px; padding: 4px; border-radius: 11px; }
  #quickTools .quick-svg { width: 25px; height: 25px; }
  #quickTools .quick-label { display: none !important; }
  #quickToolsToggle { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 11px; }
  #quickTools .is-open::before { background: #0b1b19; }
  .mt-collection-item { grid-template-columns: 30px 58px minmax(0,1fr); gap: 9px; }
  .mt-collection-thumb { width: 58px; height: 58px; }
}
@media (max-width: 380px) {
  .mt-stage-track { --mt-art-size: min(66px, calc((100vw - 58px)/4)); }
  .mt-loading-copy h2 { font-size: 1.55rem; }
}
.wt-ai-disclosure { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin: 12px auto; padding: 4px 0; border: 0; border-radius: 0; box-shadow: none; color: #d6c9a7; background: transparent; font-size: max(.82rem,var(--wt-control-size,.82rem)); text-align: center; } .wt-ai-disclosure small { color: #bfc5bd; font-size: inherit; }
@media (max-width: 900px) {
  html.metamorph-open #metamorphApp,
  html.quick-open.metamorph-open #metamorphApp { bottom: calc(68px + env(safe-area-inset-bottom)); }
  #quickTools.is-open::before {
    content: ''; position: fixed; left: 0; right: 0;
    bottom: calc(68px + env(safe-area-inset-bottom)); height: 68px;
    border-top: 1px solid rgba(202,179,119,.27);
    background: #0b1c19; pointer-events: none; z-index: -1;
  }
  html.metamorph-open #quickTools.is-open::before { background: #07101e; }
}
.mt-revision{margin-top:22px;padding:18px;border:1px solid rgba(226,188,132,.32);border-radius:14px;background:rgba(5,15,27,.65)}
.mt-revision h4{margin:0 0 8px;color:#f0d4a5;font:400 1.2rem "STKaiti","KaiTi",serif}
.mt-revision p{margin:0 0 12px;color:#c5c7d0;line-height:1.6}
.mt-revision textarea{box-sizing:border-box;width:100%;min-height:100px;padding:14px;border:1px solid rgba(226,188,132,.4);border-radius:10px;background:rgba(4,12,23,.72);color:#f5ead5;resize:vertical;font:inherit;line-height:1.6}
.mt-revision-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.mt-revision select{max-width:100%;padding:8px 12px;border:1px solid rgba(226,188,132,.4);border-radius:9px;background:#0b1725;color:#f0d4a5}
.mt-revision #mtRevisionStatus{margin:10px 0 0;min-height:1.5em}

/* Nine issue follow-up: relevant actions, precise overlay boundary and consistent controls. */
.mt-loading-copy { justify-content: center; }
html.metamorph-open #quickTools { display: none !important; }
html.branch-open #branchEntry { display: none !important; }
.mt-heading-actions { display: flex; justify-content: center; gap: 10px; margin: 13px auto 0; }
.mt-heading-actions button { min-height: 38px; padding: 6px 15px; border: 1px solid rgba(222,194,143,.52); border-radius: 999px; background: rgba(8,20,36,.72); color: #ecd7ad; font: 14px/1.3 system-ui,sans-serif; cursor: pointer; }
.mt-heading-actions button:hover,.mt-heading-actions button:focus-visible { border-color: #f3d9a9; background: rgba(29,39,52,.88); }
.mt-story-toggle { display: block; width: fit-content; min-height: 39px; margin: 11px 0 0; }
.mt-voice-label { position: relative; min-width: 0; }
#mtVoicePicker { display: none; }
#mtVoicePicker[hidden], #mtVoiceOptions[hidden] { display: none !important; }
#mtVoiceOptions { position: absolute; top: 100%; left: 0; z-index: 10; width: min(340px,calc(100vw - 55px)); max-height: 220px; overflow-y: auto; padding: 5px; border: 1px solid rgba(224,190,131,.6); border-radius: 9px; background: #10202d; box-shadow: 0 15px 35px #0009; }
#mtVoiceOptions button { display: block; width: 100%; padding: 10px; border: 0; border-radius: 6px; background: transparent; color: #eee0c9; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
#mtVoiceOptions button:hover,#mtVoiceOptions button[aria-selected=true] { background: #273743; }
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 23px; height: 23px; flex: none; margin: 0; border: 1.5px solid #c9ad72; border-radius: 50%; background: #101c23; cursor: pointer; vertical-align: middle; }
input[type=checkbox]:checked { border-color: #f0d89e; background: linear-gradient(135deg,#f7e4b6,#c9a86e); box-shadow: 0 0 8px #c6a25d4d; }
input[type=checkbox]:checked::after { content: '✓'; display: grid; place-items: center; width: 100%; height: 100%; color: #18231e; font: 700 16px/1 system-ui,sans-serif; }
input[type=checkbox]:focus-visible { outline: 2px solid #ffe2a3; outline-offset: 3px; }
.mt-story-picker { display: flex; align-items: center; justify-content: center; min-height: 44px; }
.mt-story-picker input { width: 23px; height: 23px; }
@media (max-width:900px) {
  html.metamorph-open .mobile-tabbar { display: grid !important; }
  html.metamorph-open #metamorphApp { bottom: calc(68px + env(safe-area-inset-bottom)); }
  html.metamorph-open .mt-shell { padding-bottom: 85px; }
  .mt-speech-options { display: grid; grid-template-columns: minmax(0,1fr) minmax(105px,.5fr); }
  .mt-speech-options label { min-width: 0; }
  .mt-speech-options .mt-voice-label:has(#mtVoicePicker:not([hidden])) select { display: none; }
  #mtVoicePicker:not([hidden]) { display: block; width: 100%; min-width: 0; min-height: 39px; padding: 6px 25px 6px 9px; border: 1px solid rgba(227,191,132,.48); border-radius: 8px; background: #13232c; color: #f5e9d6; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; cursor: pointer; }
}

#quickTools .quick-svg { width: 30px; height: 30px; }
@media (max-width:900px) { #quickTools .quick-svg { width: 28px; height: 28px; } }

#mtHistoryClose { min-height: 38px; padding: 6px 9px; border: 1px solid rgba(222,194,143,.45); border-radius: 8px; font: 13px/1.2 system-ui,sans-serif; }

#quickTools #branchEntry .quick-svg, #quickTools #metamorphEntry .quick-svg { width: 34px; height: 34px; stroke-width: 1.9; }
#quickTools #metamorphEntry .quick-svg { stroke: #e4d19c; filter: drop-shadow(0 0 3px rgba(150,196,111,.36)); }
#quickTools #metamorphEntry .quick-svg circle { fill: #a6d087; stroke: none; }
#quickTools #metamorphEntry.gated-locked,
#quickTools #metamorphEntry.gated-locked:hover,
#quickTools #metamorphEntry.gated-locked:focus-visible {
  opacity: .45; filter: grayscale(.85); cursor: not-allowed;
  transform: none; border-color: rgba(166, 169, 161, .4);
  background: rgba(25, 31, 29, .9); color: #aaaead;
  box-shadow: 0 5px 16px rgba(0,0,0,.2);
}
#quickTools #metamorphEntry.gated-locked .quick-svg { stroke: #aaaead; filter: none; }
#quickTools #metamorphEntry.gated-locked .quick-svg circle { fill: #aaaead; }

.mt-heading-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.mt-heading-actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mt-heading-actions { position: absolute; right: 0; top: 12px; margin: 0; }
.mt-heading-actions button { min-height: 34px; border-color: rgba(222,194,143,.25); background: rgba(8,20,36,.35); font-size: 12px; }
.mt-heading-actions { position: static; justify-content: center; margin: 13px auto 0; }
.mt-heading-actions button { min-height: 38px; padding: 6px 15px; border-color: rgba(222,194,143,.52); background: rgba(8,20,36,.72); font-size: 14px; }
.mt-recent-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 15px 0 0; }
.mt-recent-links button { min-height: 38px; padding: 7px 15px; border: 1px solid rgba(222,194,143,.42); border-radius: 999px; background: rgba(8,20,36,.65); color: #ecd7ad; cursor: pointer; }
.mt-recent-links button:disabled { opacity: .45; cursor: not-allowed; }
.mt-novel-menu { position: fixed; inset: 0; z-index: 100015; display: grid; place-items: center; padding: 20px; background: rgba(3,9,21,.74); }
.mt-novel-menu[hidden] { display: none !important; }
.mt-novel-menu-card { display: grid; gap: 10px; width: min(360px,100%); padding: 23px; border: 1px solid rgba(224,191,137,.55); border-radius: 16px; background: #101c2b; box-shadow: 0 22px 65px #0008; color: #f3e5c8; }
.mt-novel-menu-card h2 { margin: 0 0 7px; text-align: center; font: 1.5rem/1.4 "STKaiti","KaiTi",serif; }
.mt-novel-menu-card button { min-height: 43px; border: 1px solid rgba(224,191,137,.5); border-radius: 10px; background: rgba(26,34,52,.75); color: #f3e5c8; cursor: pointer; }
.mt-novel-menu-card button:last-child { border-color: transparent; background: transparent; }
.wt-generation-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
#wtGenerationView { min-width: 112px; margin-top: 15px; padding: 9px 18px; border: 1px solid rgba(237,207,150,.8); border-radius: 999px; background: #344b3f; color: #fff2cf; cursor: pointer; }
#quickTools > #metamorphNovelQuick { display: none; }
@media (max-width: 900px) {
  html.metamorph-open .mt-heading-actions { display: none; }
  html.metamorph-open #quickTools > #shareEntry { display: none !important; }
  html.metamorph-open #quickTools > #pixelTree { visibility: visible; pointer-events: auto; }
}
.wt-generation-status { position: fixed; inset: 0; z-index: 100020; display: grid; place-items: center; padding: 20px; background: rgba(3, 9, 21, .76); }
.wt-generation-status[hidden] { display: none !important; }
.wt-generation-card { width: min(410px, 100%); padding: 28px 25px; border: 1px solid rgba(224, 191, 137, .55); border-radius: 16px; background: linear-gradient(150deg, #101c2b, #07141c); box-shadow: 0 22px 65px rgba(0,0,0,.5); color: #e9e1d5; text-align: center; }
.wt-generation-orbit { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 8px; border: 1px solid rgba(231, 195, 136, .52); border-radius: 50%; color: #efdbad; font-size: 29px; animation: wt-generation-glow 2.5s ease-in-out infinite; }
.wt-generation-card h2 { margin: 0 0 10px; color: #f3e5c8; font: 1.5rem/1.35 "STKaiti", "KaiTi", serif; }
.wt-generation-card p { margin: 7px 0; line-height: 1.6; }
#wtGenerationPhase { color: #eed4a0; }
#wtGenerationHelp { color: #c5c4c0; font-size: .9rem; }
#wtGenerationClose { min-width: 100px; margin-top: 15px; padding: 9px 18px; border: 1px solid rgba(224,191,137,.6); border-radius: 999px; background: rgba(35,45,45,.8); color: #f2e2bd; }
.wt-generation-status[data-phase="failed"] .wt-generation-orbit,
.wt-generation-status[data-phase="success"] .wt-generation-orbit { animation: none; }
@keyframes wt-generation-glow { 50% { box-shadow: 0 0 20px rgba(226,189,126,.26); } }
@media (prefers-reduced-motion: reduce) { .wt-generation-orbit { animation: none; } }

.mt-history-back-label { display: none; }
html.metamorph-open .mt-history-back-label { display: inline; }
html.metamorph-open .mt-history-close-glyph { display: none; }
html.metamorph-open #historyClose { width: auto; min-width: 92px; padding: 6px 9px; border-radius: 8px; font: 13px/1.2 system-ui,sans-serif; white-space: nowrap; }

.mt-collection-item.is-selected { border-color: rgba(225,190,127,.72); box-shadow: inset 0 0 0 1px rgba(225,190,127,.16); }

@media (max-width:900px) { #quickTools #branchEntry, #quickTools #metamorphEntry { display: none !important; } }

/* Eleven-item local fixes: compact quick tools and readable mobile controls. */
@media (max-width: 900px) {
  #quickTools.is-open::before, .floating-corner.is-open::before { content: none !important; display: none !important; }
  #quickTools { width: max-content; max-width: calc(100vw - 16px); }
  #quickTools.is-open { position: fixed; padding: 5px; }
  .mobile-brandbar { position: relative; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); min-height: 62px; gap: 6px; padding: 8px 4px 10px; border-bottom: 1px solid rgba(204,190,151,.14); background: rgba(6,22,19,.72); backdrop-filter: blur(10px); box-shadow: none; }
  .mobile-brandbar img { grid-column: 2; grid-row: 1; width: 86px; height: 34px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .mobile-brandbar .mobile-text-size { position: relative; grid-column: 3; grid-row: 1; margin: 0; justify-self: end; gap: 6px; border: 0; border-radius: 0; padding: 0; background: transparent; box-shadow: none; color: #cfbf99; font-size: 13px; }
  .mobile-brandbar .mobile-text-size select { box-sizing: border-box; width: 92px; min-width: 92px; height: 40px; min-height: 40px; padding: 5px 23px 5px 9px; border: 1px solid rgba(194,177,139,.55); border-radius: 9px; background: rgba(9,27,23,.54); box-shadow: none; color: #efe5cd; font-size: 13px; appearance: none; }
  .mobile-brandbar .mobile-text-size::after { content: "⌄"; position: absolute; right: 11px; top: 6px; color: #d8c8a5; font: 20px/1 system-ui,sans-serif; pointer-events: none; }
  .mobile-brandbar .mbb-menu { grid-column: 1; grid-row: 1; justify-self: start; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: #e7cb89; font-size: 23px; }
  .mt-collection-item.mt-novel-item { display: block; grid-template-columns: none; min-width: 0; }
  .mt-novel-item .mt-collection-main { width: 100%; min-width: 0; }
  .mt-novel-item .mt-collection-title { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
  .mt-novel-item .mt-collection-meta { white-space: normal; overflow-wrap: anywhere; }
  .mt-novel-item .mt-collection-actions { display: flex; flex-wrap: wrap; }
  .mt-novel-item .mt-collection-actions button { white-space: nowrap; }
  .bf-header { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px 10px; align-items: center; }
  .bf-header .fx-head-main { display: contents; }
  .bf-header h3 { grid-column: 1; grid-row: 1; min-width: 0; font-size: clamp(1rem,4.5vw,1.2rem); white-space: nowrap; }
  .bf-header .history-close { grid-column: 2; grid-row: 1; justify-self: end; }
  .bf-header .fx-head-sub { grid-column: 1/-1; grid-row: 2; white-space: normal; }
  .bf-header .bf-round { grid-column: 1; grid-row: 3; justify-self: start; }
  .bf-header .bf-export-text { grid-column: 2; grid-row: 3; min-width: 96px; min-height: 38px; padding: 6px 12px; white-space: nowrap; text-align: center; font-size: 13px; }
}
@media (max-width: 380px) {
  .mobile-brandbar { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); }
  .mobile-brandbar img { width: 82px; }
}

/* Four isolated history categories and compact batch controls. */
.history-tabs { grid-template-columns: repeat(4,minmax(0,1fr)); }
.history-tabs button { min-width: 0; padding: 5px 3px; white-space: nowrap; font-size: clamp(11px,2.8vw,13px); }
.history-bulk-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 9px; border: 1px solid rgba(213,180,111,.3); border-radius: 10px; color: #e2d5b6; font-size: 12px; }
.history-bulk-toolbar button { min-height: 35px; padding: 5px 9px; border: 1px solid rgba(213,180,111,.42); border-radius: 8px; background: rgba(14,34,28,.88); color: #eeddbb; cursor: pointer; white-space: nowrap; }
.history-bulk-toolbar button:hover { border-color: #e7c883; }
.history-bulk-toolbar span { white-space: nowrap; }
.history-bulk-check, .wt-bulk-picker { display: inline-flex; align-items: center; margin: 0 8px 8px 0; }
.history-bulk-check, .wt-bulk-picker input { width: 21px; height: 21px; accent-color: #d4af60; cursor: pointer; }
.mt-collection-item.mt-novel-item { min-width: 0; }
.wt-branch-item .mt-collection-title { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .bf-header { grid-template-columns: minmax(0,1fr) auto; }
  .bf-header .history-close { grid-column: 2; }
  .bf-header .bf-round { grid-column: 1; }
  .bf-header .bf-header-actions { grid-column: 2; grid-row: 3; justify-self: end; }
  .bf-header .bf-export-text { min-width: 75px; padding-inline: 8px; }
  .history-tabs { gap: 3px; padding-inline: 8px; }
}

#mapContainer.history-static .stage-card,
#mapContainer.history-static .summary-box,
#mapContainer.history-static .today-box { animation: none !important; opacity: 1 !important; transform: none !important; }

.fx-legacy-result { padding: 18px; color: #e1d8c2; }
.fx-legacy-result pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.6 ui-monospace, Consolas, monospace; }

.history-item.is-bulk-selected, .mt-collection-item.is-bulk-selected { border-color: rgba(226,190,113,.72); box-shadow: inset 0 0 0 1px rgba(226,190,113,.16); }

@media (max-width: 900px) {
  .mobile-brandbar .mbb-menu { border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: #e7cb89; font-size: 23px; }
  .mobile-brandbar .mbb-menu:focus-visible { outline: 2px solid #e7cb89; outline-offset: 2px; }
  .mobile-brandbar .mobile-text-size select:focus-visible { outline: 2px solid #dec796; outline-offset: 2px; }
}

/* Four-item repair: grouped branch actions and a history drawer above the branch scene. */
html.branch-open #historyBackdrop { z-index: 100000; }
html.branch-open #historyPanel { z-index: 100001; }
.bf-header { justify-content: initial; }
.bf-header .fx-head-main { margin-right: auto; }
.bf-header-actions { display: inline-flex; align-items: center; gap: 9px; flex: none; }
.bf-header-actions .bf-export-text { min-width: 92px; margin: 0; }
@media (max-width: 900px) {
  .bf-header-actions { gap: 7px; }
  .bf-header-actions .bf-export-text { min-width: 76px; }
  .mobile-brandbar img { grid-row: 1; }
}
@media (max-width: 380px) {
  .mobile-brandbar { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); }
  .bf-header-actions .bf-export-text { min-width: 70px; padding-inline: 6px; }
}

/* Mobile header keeps the original centered Mille image and light controls. */
@media (max-width: 900px) {
  .mobile-brandbar { position: relative; display: flex; justify-content: space-between; width: 100%; min-height: 62px; padding: 8px 4px 10px; }
  .mobile-brandbar > img { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 86px; height: 34px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; pointer-events: none; }
  .mobile-brandbar .mbb-menu { position: relative; z-index: 2; flex: 0 0 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .mobile-brandbar .mobile-text-size { position: relative; z-index: 3; display: block; flex: 0 0 44px; justify-self: auto; margin-left: auto; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .mobile-brandbar .mobile-text-size::after { content: none; }
  #mobileTextSizeToggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: #e7d6ad; cursor: pointer; }
  .mobile-text-size-icon { display: inline-flex; align-items: center; font: 500 16px/1.2 system-ui,sans-serif; white-space: nowrap; }
  .mobile-text-size-icon small { font-size: 13px; }
  #mobileTextSizeToggle:hover, #mobileTextSizeToggle[aria-expanded="true"] { background: rgba(221,197,143,.08); }
  #mobileTextSizeToggle:focus-visible { outline: 2px solid #dec796; outline-offset: 1px; }
  .mobile-text-size-menu[hidden] { display: none !important; }
  .mobile-text-size-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10000; width: 138px; padding: 5px; border: 1px solid rgba(207,185,141,.48); border-radius: 11px; background: #10211f; box-shadow: 0 12px 32px rgba(0,0,0,.52); }
  .mobile-text-size-menu button { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 40px; padding: 7px 11px; border: 0; border-radius: 7px; background: transparent; color: #e9e1ce; text-align: left; font-size: 14px; cursor: pointer; }
  .mobile-text-size-menu button span { visibility: hidden; color: #dfc689; }
  .mobile-text-size-menu button[aria-checked="true"] { background: rgba(203,178,121,.13); color: #f4e5bd; }
  .mobile-text-size-menu button[aria-checked="true"] span { visibility: visible; }
  .mobile-text-size-menu button:hover, .mobile-text-size-menu button:focus-visible { background: rgba(203,178,121,.18); outline: none; }

  /* Compact quick menu: only the two actions that are absent from the five bottom tabs. */
  #quickTools, html.metamorph-open #quickTools { display: flex !important; position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(78px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 24px); flex-direction: column; align-items: flex-end; gap: 6px; padding: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
  html.nav-open #quickTools, html.quick-input-active #quickTools { display: none !important; }
  #quickTools::before, #quickTools.is-open::before, .floating-corner.is-open::before { content: none !important; display: none !important; pointer-events: none !important; }
  #quickTools.is-open { padding: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
  #quickTools > #shareEntry, #quickTools > #pixelTree, #quickTools > #metamorphNovelQuick { order: 1; display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 9px; width: 142px; height: 44px; min-height: 44px; margin: 0; padding: 8px 12px; border: 1px solid rgba(196,178,143,.38); border-radius: 11px; background: rgba(9,27,24,.93); box-shadow: 0 4px 12px rgba(0,0,0,.2); backdrop-filter: blur(9px); color: #e7d8b7; text-align: left; }
  #quickTools > #shareEntry { order: 1; }
  #quickTools > #pixelTree { order: 1; }
  #quickTools > #metamorphNovelQuick { order: 2; display: none; }
  html.metamorph-open #quickTools > #metamorphNovelQuick { display: flex; }
  html.metamorph-open #quickTools > #shareEntry { display: none !important; }
  #quickTools:not(.is-open) > [data-quick-label] { display: none !important; }
  #quickTools > #branchEntry, #quickTools > #metamorphEntry { display: none !important; }
  #quickTools .quick-svg { display: block; flex: 0 0 21px; width: 21px; height: 21px; }
  #quickTools .quick-label { display: block !important; margin: 0 !important; color: #e7d8b7; font: 13px/1.2 system-ui,sans-serif !important; white-space: nowrap; }
  #quickTools > [data-quick-label]:hover, #quickTools > [data-quick-label]:focus-visible { transform: none; border-color: rgba(225,203,158,.65); background: rgba(21,43,36,.96); box-shadow: 0 4px 12px rgba(0,0,0,.25); }
  #quickToolsToggle { order: 3; display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 5px; flex: 0 0 44px; width: 48px; height: 44px; min-height: 44px; margin: 0; padding: 0; border: 1px solid rgba(199,184,150,.5); border-radius: 999px; background: rgba(9,28,24,.86); box-shadow: 0 4px 12px rgba(0,0,0,.22); backdrop-filter: blur(10px); color: #e4d5b5; font: 12px/1 system-ui,sans-serif; cursor: pointer; touch-action: manipulation; }
  #quickToolsToggle svg { width: 22px; height: 22px; stroke: none; fill: none; }
  #quickToolsToggle svg circle { fill: #e0cda2; stroke: none; }
  #quickToolsToggle:hover, #quickToolsToggle[aria-expanded="true"] { border-color: rgba(222,199,153,.73); background: rgba(20,42,34,.93); }
  #quickToolsToggle:focus-visible, #quickTools > [data-quick-label]:focus-visible { outline: 2px solid #e0c890; outline-offset: 2px; }
}
