/* === Global App Styles (no modal or keyboard selectors here) === */
/* Keep comments in English as requested. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--neutral-900);
  color: var(--mist-200);
  font: 16px/1.5 system-ui, Segoe UI, Roboto, Helvetica, Arial;
}

h1,
h2,
h3 {
  margin: .2rem 0;
  color: whitesmoke;
}

/* Navbar */
.navbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1rem;
  background: var(--neutral-900);
  border-bottom: 1px solid var(--neutral-700);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 36px;
  height: 36px;
}

.brand span {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: .2px;
}

#burger {
  font-size: 1.2rem;
  cursor: pointer;
}

.app-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
}

#mute-btn {
  cursor: pointer;
}

.mixers {
  display: flex;
  gap: 1rem;
}

.mixers label {
  font-size: .85rem;
  color: var(--mist-400);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.mixers label input {
  width: 8em;
  cursor: pointer;
}

#tile-playback {
  position: relative;
}

.tile-controls {
  position: absolute;
  top: 12px;
  right: 16px;

}

/* host row inside each NPC tile */
.npc-emojis {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

/* circular emoji with subtle colored backdrop */
.npc-emo {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  font-size: 1.05rem;
  line-height: 1;
  background: hsl(var(--h) 90% 96%);
  box-shadow: inset 0 0 0 2px hsl(var(--h) 65% 70% / .55);
}


/* Side menu */
.side-menu {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(320px, 85vw);
  background: var(--neutral-900);
  padding: 1rem;
  transform: translateX(-100%);
  transition: .2s transform;
  z-index: 20;
  overflow: auto;
  border-right: 1px solid var(--neutral-700);
}

.side-menu.hidden {
  transform: translateX(-100%);
}

.side-menu:not(.hidden) {
  transform: translateX(0);
}

#chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#chapter-list li {
  padding: .3rem 0;
  border-bottom: 1px dashed var(--neutral-700);
  cursor: pointer;
}

#chapter-list li:hover {
  color: var(--blue-300);
}

/* Layout & tiles */
.layout {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
  display: grid;
  gap: 1rem;
}

.row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.tile {
  max-height: 180px;
  overflow: auto;
  color: whitesmoke;
  background: var(--neutral-200);
  border: 1px solid var(--neutral-700);
  border-radius: 16px;
  padding: 1.2rem;
  padding-top: 0.4rem;
  min-height: 110px;
}

.tile h3 {
  font-size: 1rem;
  margin-bottom: .4rem;
  margin-left: 0.2rem;
}

/* Map/Back buttons (generic) */
#keyboard-btn,
#note-btn,
#random-btn a,
#random-btn {
  min-height: 28px;
  background-color: rgb(170, 67, 79);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  color: var(--mist-200);
}

#back-btn {
  background-color: #000;
  border-radius: 8px;
  min-height: 28px;
}

#back-btn a {
  text-decoration: none;
  color: var(--mist-200);
}

/* Generic buttons */
.btn-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.btn-list.scroll {
  max-height: 140px;
  overflow: auto;
  /* padding-right: 0.55rem; */
}

.btn-list.scroll .btn {
  padding: 0.5em;
  margin: auto;
}

#playback-stop {
  position: relative;
  top: -6px;
  background-color: var(--red-300);
}

.btn {
  color: whitesmoke;
  background: var(--neutral-500);
  border: 1px solid var(--neutral-700);
  padding: .2rem .7rem;
  border-radius: 12px;
  cursor: pointer;
}

.btn-list .btn .npc-emo {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: hsl(var(--h) 90% 96%);
  box-shadow: inset 0 0 0 2px hsl(var(--h) 65% 70% / .55);
  font-size: 1.05rem;
  line-height: 1;
}

.btn.active {
  background: var(--neutral-300);
  border-color: var(--blue-300);
}

.btn.danger {
  border-color: var(--red-200);
}

.placeholder {
  opacity: .6;
}

/* Story content */
.story {
  background: var(--neutral-900);
  border: 1px solid var(--neutral-700);
  border-radius: 18px;
  padding: 1rem;
}

.story-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
}

#chapter-content {
  white-space: pre-wrap;
}

#chapter-content li {
  margin: 8px 0;
}

#chapter-content a {
  text-decoration: none;
  color: #2d3654;
  background-color: #fff;
  border-radius: 8px;
  padding: 4px;
  margin: 4px;
}

/* Chapter links */
.chapter-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}

.link-btn {
  background: var(--mist-200);
  border: 1px solid var(--neutral-700);
  padding: .5rem .7rem;
  border-radius: 12px;
  color: var(--neutral-900);
  cursor: pointer;
}

.link-btn:hover {
  border-color: var(--teal-600);
}

/* Inline sound triggers (non-modal) */
.inline-sound {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1rem .4rem;
  margin: 0 .1rem;
  border-radius: 10px;
  border: 1px dashed var(--neutral-700);
  cursor: pointer;
}

.inline-sound:hover {
  border-color: var(--blue-300);
}

/* Simple overlay card (if used outside modal system) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: grid;
  place-items: center;
  z-index: 30;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: var(--neutral-900);
  border: 1px solid var(--neutral-700);
  padding: 1.2rem;
  border-radius: 16px;
  min-width: min(90vw);
  text-align: center;
}

#note-text {
  width: 95% !important;
  height: 70vh;
}

/* Metronome controls */
.metronome-ui {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}

.metronome-ui label {
  display: inline-flex;
  gap: .4rem;
  align-items: center;
}

.metronome-ui input{
  width: fit-content;
}

#metro-toggle {
  color: whitesmoke;
  background: var(--teal-600);
  border: 1px solid var(--neutral-500);
  padding: .2rem .7rem;
  border-radius: 12px;
  cursor: pointer;
}

/* Responsive */
@media (max-width:900px) {
  .row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Chapters Editor (light DOM, non-modal) */
#chapters-editor {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, .6);
  display: none;
}

#chapters-editor .wrap {
  font-family: system-ui, sans-serif;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  padding: 12px;
  height: 100vh;
  box-sizing: border-box;
}

#chapters-editor .card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
  padding: 12px;
  display: flex;
  flex-direction: column;
}

#chapters-editor .toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#chapters-editor .toolbar input[type="search"] {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

#chapters-editor .list {
  height: 76vh;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  box-sizing: border-box;
}

#chapters-editor .row {
  color: gray;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #f2f2f2;
  cursor: pointer;
}

#chapters-editor .row:hover {
  background: #f9f9ff;
}

#chapters-editor .row.active {
  background: #eef3ff;
  font-weight: 600;
}

#chapters-editor .btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
}

#chapters-editor .btn.primary {
  background: #1a73e8;
  border-color: #1a73e8;
  color: #fff;
}

#chapters-editor .btn.danger {
  background: #e53935;
  border-color: #e53935;
  color: #fff;
}

#chapters-editor .btn.ghost {
  background: transparent;
}

#chapters-editor .split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#chapters-editor .field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

#chapters-editor .field label {
  font-size: 12px;
  color: #666;
}

#chapters-editor .field input,
#chapters-editor .field textarea,
#chapters-editor .field select {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

#chapters-editor .links {
  display: grid;
  gap: 6px;
}

#chapters-editor .link-row {
  display: grid;
  grid-template-columns: 1fr 120px 36px;
  gap: 6px;
  align-items: center;
}

#chapters-editor .tags {
  font-size: 12px;
  color: #888;
}

#chapters-editor .footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

#chapters-editor .errors {
  color: #b00020;
  font-size: 12px;
  white-space: pre-wrap;
}

#chapters-editor .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#chapters-editor .dim {
  color: #777;
  font-size: 12px;
}