/* One workspace beside the world; touch browsing becomes a focused sheet. */
.atmosphere-library, .atmosphere-library * { box-sizing: border-box; }
.atmosphere-library[hidden], .atmosphere-library [hidden] { display: none !important; }
.atmosphere-library {
  display: flex; flex-direction: column; flex: 0 0 304px; width: 304px;
  height: 100dvh; min-height: 0; overflow: hidden; border-right: 2px solid var(--mx-line);
  background: var(--mx-panel, #151119); color: var(--mx-paper, #f5f2ea);
  font: 400 8px/1.8 var(--mx-ui);
}

.atmosphere-library button, .atmosphere-library input, .atmosphere-library select { font: inherit; color: inherit; }
.atmosphere-library button {
  min-height: 44px; padding: 8px; border: 1px solid var(--mx-line);
  border-radius: 0; background: #211828; cursor: pointer;
}
.atmosphere-library button:hover { border-color: var(--mx-cyan); }
.atmosphere-library button:disabled { opacity: .45; cursor: default; }
.atmosphere-library :is(button, input):focus-visible { outline: 0; box-shadow: inset 0 -2px var(--mx-cyan); }
.atmosphere-heading { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; flex-shrink: 0; }
.atmosphere-heading h2 { font: inherit; font-size: 11px; text-transform: uppercase; }
.atmosphere-heading button { width: 44px; border: 0; background: transparent; font-size: 22px; }
.atmosphere-views { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 0 10px 8px; flex-shrink: 0; }
.atmosphere-views [aria-pressed="true"] { color: var(--mx-cyan); background: #112128; border-color: var(--mx-cyan); }
.atmosphere-active { flex-shrink: 0; padding: 0 10px 8px; border-bottom: 1px solid var(--mx-line); }
#atmosphere-count { color: var(--mx-muted); display: block; font-size: 7px; }
#atmosphere-layers { display: flex; gap: 5px; overflow-x: auto; overscroll-behavior: contain; }
#atmosphere-layers:not(:empty) { padding-top: 5px; }
#atmosphere-layers button { flex: 1 0 auto; padding: 6px; font-size: 7px; }
#atmosphere-layers [aria-pressed="true"] { border-color: var(--mx-cyan); color: var(--mx-cyan); background: #112128; }
.atmosphere-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; overscroll-behavior: contain; scrollbar-gutter: stable; }
.atmosphere-intro { color: var(--mx-muted); margin: 0 0 12px; font-size: 7px; line-height: 2; }
.atmosphere-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.atmosphere-cards .atmosphere-card { min-height: 56px; padding: 10px; text-align: left; background: #1a1420; display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: 0; -webkit-tap-highlight-color: transparent; }
.atmosphere-card strong { display: block; font: inherit; font-size: 8px; line-height: 1.6; }
.atmosphere-card small { display: block; font-size: 6px; line-height: 1.6; color: var(--mx-muted); }
@media (hover: hover) { .atmosphere-card:hover { background: #241c2c; } }
@media (hover: none) { .atmosphere-card[data-added="false"]:hover { border-color: var(--mx-line); } }
.atmosphere-card:active { box-shadow: inset 0 -2px var(--mx-cyan); }
.atmosphere-card[data-added="true"] { border-color: var(--mx-cyan); background: #112128; }
.atmosphere-card[data-added="true"] strong { color: var(--mx-cyan); }
.atmosphere-card[data-added="true"] small { color: #aac7cc; }
.atmosphere-effect-heading { margin-bottom: 12px; }
.atmosphere-effect-heading h3 { font: inherit; font-size: 11px; color: var(--mx-cyan); margin: 0 0 6px; }
.atmosphere-effect-heading p, .atmosphere-note { color: var(--mx-muted); font-size: 7px; line-height: 1.9; }
.atmosphere-fields { display: grid; gap: 12px; }
.atmosphere-field { min-width: 0; }
.atmosphere-field label { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.atmosphere-field output { color: var(--mx-cyan); font-size: 7px; white-space: nowrap; }
.atmosphere-field input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; accent-color: var(--mx-cyan); cursor: pointer; touch-action: pan-y; }
.atmosphere-field input[type="range"]::-webkit-slider-runnable-track { height: 4px; border: 0; border-radius: 0; background: #54475d; }
.atmosphere-field input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 14px; height: 18px; margin-top: -7px; border: 2px solid #112128; border-radius: 0; background: var(--mx-cyan); }
.atmosphere-field input[type="range"]::-moz-range-track { height: 4px; border: 0; border-radius: 0; background: #54475d; }
.atmosphere-field input[type="range"]::-moz-range-thumb { width: 10px; height: 14px; border: 2px solid #112128; border-radius: 0; background: var(--mx-cyan); }
.atmosphere-field .mx-select { width: 100%; margin-top: 6px; }
.atmosphere-field .mx-select-trigger { width: 100%; min-height: 44px; text-align: left; }
.atmosphere-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; }
#atmosphere-clear { width: 100%; margin: 6px 0 10px; background: transparent; color: var(--mx-muted); }
.atmosphere-footer { flex-shrink: 0; padding: 8px 10px; border-top: 1px solid var(--mx-line); background: #100d14; }
#atmosphere-status { font-size: 7px; line-height: 1.8; margin-bottom: 7px; }
#atmosphere-preview-pause { width: 100%; color: var(--mx-cyan); }
#atmosphere-motion-note { color: var(--mx-muted); font-size: 6px; line-height: 1.9; padding-top: 6px; }
#atmosphere-sidebar-btn.active { color: var(--mx-cyan); background: #112128; border-color: var(--mx-cyan); }
#atmosphere-sidebar-btn[data-has-effects="true"]:not(.active) { color: var(--mx-cyan); }
/* An extra tool must never squeeze the bottom rail action off a short screen. */
.sidebar-tools { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.sidebar-tools .sidebar-icon, .sidebar-logo { flex-shrink: 0; }
@media (max-width: 1100px) { .atmosphere-library { width: 286px; flex-basis: 286px; } }
@media (max-width: 600px), (max-width: 900px) and (min-height: 600px) {
  .atmosphere-library { position: fixed; z-index: 85; inset: auto 0 0; width: 100%; height: min(80dvh, 760px); border: 2px solid var(--mx-line); }
  .atmosphere-library[data-view="edit"] { height: 42dvh; }
  .app.atmosphere-library-open .main { padding-bottom: var(--atmosphere-sheet-height, 0px); }
  /* Keep a real preview above the sheet, including on a 320×568 screen.
     The terrain palette and screen navigation remain within reach. */
  .app.atmosphere-library-open :is(#selection-action-bar, .palette-quick, .palette-mode) { display: none !important; }
  .app.atmosphere-library-open .palette-shell { display: flex; min-height: 58px; }
  .atmosphere-library[data-view="edit"] .atmosphere-heading { position: absolute; right: 2px; top: 2px; padding: 0; }
  .atmosphere-library[data-view="edit"] .atmosphere-heading h2 { display: none; }
  .atmosphere-library[data-view="edit"] .atmosphere-views { padding: 4px 52px 4px 8px; }
  .atmosphere-library[data-view="edit"] .atmosphere-active { display: none; }
  .atmosphere-library[data-view="edit"] .atmosphere-effect-heading { display: none; }
  .atmosphere-library[data-view="edit"] .atmosphere-fields { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .atmosphere-library[data-view="edit"] .atmosphere-field:first-child { grid-column: 1 / -1; }
  .atmosphere-library[data-view="edit"] .atmosphere-footer { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 4px 8px; align-items: center; }
  .atmosphere-library[data-view="edit"] #atmosphere-status { margin: 0; font-size: 6px; }
  .atmosphere-library[data-view="edit"] #atmosphere-preview-pause { width: auto; font-size: 7px; }
  .atmosphere-library[data-view="edit"] #atmosphere-motion-note { grid-column: 1 / -1; padding: 0; font-size: 5px; }
}

/* Phone landscape: browse a full sheet, then adjust beside the exposed world. */
@media (pointer: coarse) and (orientation: landscape) and (max-width: 1100px) and (max-height: 560px) {
  .app .atmosphere-library {
    position: fixed; z-index: 85;
    inset: var(--mx-safe-top) var(--mx-safe-right) var(--mx-safe-bottom) var(--mx-safe-left);
    width: auto; height: auto; border: 2px solid var(--mx-line);
  }
  .app .atmosphere-library[data-view="library"] { display: grid; grid-template-columns: minmax(180px, 27%) minmax(0, 1fr); grid-template-rows: 52px minmax(0, 1fr) auto; }
  .app .atmosphere-library[data-view="library"] .atmosphere-heading { grid-column: 1 / -1; grid-row: 1; }
  .app .atmosphere-library[data-view="library"] .atmosphere-views { position: absolute; top: 4px; right: 56px; width: 44%; padding: 0; font-size: 7px; }
  .app .atmosphere-library[data-view="library"] .atmosphere-active { grid-column: 1; grid-row: 2; padding-top: 10px; overflow-y: auto; }
  .app .atmosphere-library[data-view="library"] #atmosphere-layers { flex-direction: column; }
  .app .atmosphere-library[data-view="library"] .atmosphere-scroll { grid-column: 2; grid-row: 2; }
  .app .atmosphere-library[data-view="library"] .atmosphere-footer { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: 1fr 160px; align-items: center; gap: 4px 12px; padding: 4px 10px; }
  .app .atmosphere-library[data-view="library"] #atmosphere-status { margin: 0; }
  .app .atmosphere-library[data-view="library"] #atmosphere-motion-note { grid-column: 1 / -1; padding: 0; }
  .app .atmosphere-library[data-view="edit"] {
    inset: calc(var(--mx-safe-top) + 122px) var(--mx-safe-right) var(--mx-safe-bottom) auto;
    width: min(360px, 44vw); min-width: 240px;
  }
  .app .atmosphere-library[data-view="edit"] .atmosphere-heading { position: absolute; right: 2px; top: 2px; padding: 0; }
  .app .atmosphere-library[data-view="edit"] .atmosphere-heading h2 { display: none; }
  .app .atmosphere-library[data-view="edit"] .atmosphere-views { padding: 4px 52px 4px 8px; font-size: 7px; }
  .app .atmosphere-library[data-view="edit"] .atmosphere-active,
  .app .atmosphere-library[data-view="edit"] .atmosphere-effect-heading { display: none; }
  .app .atmosphere-library[data-view="edit"] .atmosphere-footer { padding: 4px 8px; }
  .app.atmosphere-library-open .main { padding-bottom: 0; }
  .app.atmosphere-library-open .palette-shell { min-height: 0; }
  .app.atmosphere-library-open .palette-quick,
  .app.atmosphere-library-open .palette-mode { display: flex !important; }
  .app.atmosphere-library-open .selection-action-bar { display: none !important; }
}
