/*
MIT License

Copyright (c) 2026 mr-highball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/


#tools-toggle {
  position: absolute;
  top: 78px;
  right: 12px;
  z-index: 8;
  min-width: 90px;
  min-height: 44px;
  background: #163236f2;
  touch-action: manipulation;
}
#fly-controls {
  position: absolute;
  right: 12px;
  bottom: 96px;
  z-index: 6;
  display: grid;
  gap: 8px;
}
#fly-controls button {
  min-height: 48px;
  min-width: 88px;
  padding: 8px;
  background: #163236ed;
  touch-action: none;
}
#fly-controls[hidden], #tools-toggle[hidden] { display: none; }
body.tools-collapsed aside#tools-panel { display: none; }
body:not(.tools-collapsed) aside#tools-panel { display: block; }
.zoom-controls[hidden] { display: none; }
.render-options { margin-top: 18px; }
.render-options label { display: block; margin-bottom: 8px; }
.render-options select { width: 100%; min-height: 44px; font: inherit; }
.render-options p { color: var(--muted); font-size: 12px; line-height: 1.5; }
#selection-settings, #catalog-browser { grid-column: 1 / -1; }
#selection-settings label { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
#selection-settings select { min-height: 44px; min-width: 0; flex: 1; font: inherit; }
#selection-settings select, .render-options select { color: #f2f0d9; border: 1px solid #668a82; background: #163638; border-radius: 10px; padding: 8px; }
#selection-settings [hidden] { display: none; }
#selection-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
#selection-stroke { fill: #d7eb9722; stroke: #e9f6b1; stroke-width: 2; vector-effect: non-scaling-stroke; }
#authoring-tools { position: absolute; left: 50%; transform: translateX(-50%); bottom: 8px; z-index: 7; display: flex; gap: 4px; padding: 5px; border: 1px solid #7faaa377; border-radius: 14px; background: #123035ee; max-width: calc(100% - 16px); }
#authoring-tools[hidden] { display: none; }
#authoring-tools button { min-height: 44px; min-width: 46px; padding: 4px 8px; font-size: 11px; border-radius: 9px; touch-action: manipulation; }
#authoring-tools button::before { width: 20px; height: 20px; }
#authoring-tools button[aria-pressed='true'] { background: #466459; border-color: #e6efb0; box-shadow: inset 3px 0 #e6efb0; }
#selection-count { align-self: center; font-size: 11px; white-space: nowrap; padding: 0 6px; }
body:not(.exploring) .viewport-bottom { bottom: 76px; }
body:not(.exploring) #walk-controls { bottom: 78px; }
body.catalog-open [data-catalog-root] { display: none; }
#catalog-browser[hidden] { display: none; }
#catalog-browser label { display: block; font-size: 12px; margin: 10px 0 6px; }
#catalog-search { width: 100%; min-height: 44px; box-sizing: border-box; font: inherit; }
#catalog-results { display: grid; gap: 8px; margin: 12px 0; }
#catalog-results button { min-height: 52px; text-align: left; font: inherit; padding: 10px; }
#catalog-results button[aria-pressed='true'] { border-color: #e6efb0; background: #466459; }
#catalog-results small { display: block; font-size: 11px; opacity: .8; margin-top: 4px; }
#catalog-path { font-size: 11px; color: var(--muted); margin-top: 14px; }
#catalog-choice { font-size: 12px; line-height: 1.5; }
#catalog-confirm { position: sticky; bottom: -1px; z-index: 2; padding: 6px 0 10px; background: #163236; box-shadow: 0 -10px 14px #163236bb; }
#catalog-confirm[hidden] { display: none; }
body.catalog-open #tools-panel { scroll-padding-bottom: 120px; }
#catalog-results button { scroll-margin-block: 8px 110px; }
#catalog-browser h2 { margin: 6px 0; font-size: 18px; }
body[data-camera='fly'] #interaction-hint, body[data-camera='walk'] #interaction-hint { display: none; }
@media (max-width: 700px) {
  aside#tools-panel { height: min(312px, 42dvh); }
  body:not(.tools-collapsed):not([data-interior='true']):not([data-groundworks='true']):not([data-modular='true']):not([data-landforms='true']) aside#tools-panel { display: grid; }
  body[data-interior='true']:not(.tools-collapsed) aside#tools-panel,
  body[data-groundworks='true']:not(.tools-collapsed) aside#tools-panel,
  body[data-modular='true']:not(.tools-collapsed) aside#tools-panel,
  body[data-landforms='true']:not(.tools-collapsed) aside#tools-panel { display: block; }
  .render-options { grid-column: 1 / 3; }
  #selection-count { display: none; }
  #viewport-shell { min-height: 180px; }
  #walk-controls { left: 8px; bottom: 48px; }
  #walk-controls button { width: 44px; height: 44px; margin: 2px; }
  #fly-controls { bottom: 100px; right: 8px; gap: 5px; }
  #fly-controls button { min-width: 78px; min-height: 44px; font-size: 12px; }
  #interaction-hint { max-width: calc(100% - 110px); font-size: 10px; }
  .selection-panel strong, .selection-panel p { display: block; }
  .selection-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 8px; }
  .selection-panel > .section-title, .selection-panel > strong, .selection-panel > p,
  .selection-panel > .minor-actions, .selection-panel > .primary { grid-column: 1 / -1; }
  .selection-panel .wide { width: 100%; min-width: 0; }
  .selection-panel .minor-actions { display: flex; }
  .selection-panel strong { font-size: 12px; }
  .selection-panel p { font-size: 11px; margin: 5px 0; }
}
@media (max-height: 500px) and (orientation: landscape) {
  main { flex-direction: row; }
  aside#tools-panel { width: min(260px, 40vw); height: auto; max-height: none; }
  body:not(.tools-collapsed):not([data-interior='true']):not([data-groundworks='true']) aside#tools-panel { display: block; }
  aside#tools-panel section { margin-bottom: 14px; }
  .selection-panel { grid-template-columns: minmax(0, 1fr); }
  #tools-toggle { top: 72px; min-width: 76px; min-height: 44px; font-size: 11px; padding: 4px; }
  #viewport-shell { min-height: 120px; }
  #walk-controls { bottom: 8px; }
  body:not(.exploring) #walk-controls { bottom: 68px; }
  #fly-controls { bottom: 8px; }
  body:not(.exploring) #fly-controls { bottom: 68px; }
  #fly-controls button { min-width: 66px; }
  #authoring-tools button { min-width: 42px; padding: 4px; }
  #selection-count { display: none; }
  #interaction-hint { display: none; }
}
body[data-modular='true']:not([data-interior='true']):not([data-groundworks='true']) #tools-panel > :not(#module-tools):not(#selection-settings):not(#mobile-save-world) {
  display: none;
}
body[data-landforms='true'] #tools-panel > :not(#landform-tools):not(#selection-settings):not(#mobile-save-world) {
  display: none;
}
body[data-landforms='true']:not(.tools-collapsed) aside#tools-panel {
  display: flex;
  flex-direction: column;
}
body[data-landforms='true'] #tools-panel > * { flex-shrink: 0; }
body[data-landforms='true'] #landform-tools { order: -2; }
body[data-landforms='true'] #selection-settings { order: -1; }
body[data-landforms='true'] #selection-settings label:has(#selection-layer) {
  display: none;
}
#landform-tools h2 { margin: 18px 0 8px; font-size: 1.4rem; }
#landform-tools p { line-height: 1.5; font-size: 0.8rem; }
#landform-tools select {
  width: 100%; margin: 8px 0; min-height: 48px; padding: 10px;
  color: #f3ebd2; background: #163133; border: 1px solid #758c87;
  border-radius: 12px; font: inherit;
}
@media (max-width: 700px) {
  #landform-tools h2 { margin: 10px 0; font-size: 1.1rem; }
  #landform-tools > p:first-of-type, #landform-tools > [data-landform='draw'] {
    display: none;
  }
}
#module-tools h2 {
  margin: 18px 0 8px;
  font-size: 1.4rem;
}
#module-tools p {
  line-height: 1.5;
  font-size: 0.8rem;
}
#module-tools select {
  width: 100%;
  margin: 6px 0 10px;
  min-height: 44px;
  border: 1px solid #758c87;
  border-radius: 12px;
  padding: 10px;
  color: #f3ebd2;
  background: #163133;
  font: inherit;
}
#module-tools label {
  font-size: 0.85rem;
}
#module-content-count {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  margin: 6px 0;
  color: #f3ebd2;
  background: #163133;
  border: 1px solid #758c87;
  border-radius: 12px;
  box-sizing: border-box;
}
.module-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
#module-population {
  min-width: 0;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #758c87;
  border-radius: 12px;
}
#module-population legend {
  padding: 0 6px;
  font-weight: bold;
}
.module-actions button {
  min-width: 0;
  min-height: 48px;
  padding: 9px;
}
.module-actions button[aria-pressed='true'] {
  border-color: #e4d5a8;
  box-shadow: inset 0 0 0 2px #e4d5a8;
}
.module-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 12px 0;
}
#module-nearby {
  position: absolute;
  left: 50%;
  bottom: 210px;
  transform: translateX(-50%);
  z-index: 12;
  min-height: 52px;
  max-width: calc(100% - 32px);
  background: #203e3c;
  border-color: #e4d5a8;
}
