/* QuietRoom — mid-century paper: cream field, navy ink, blue/orange accents. */

:root {
  --paper: #f2e6c8;
  --card: #f7eed6;
  --ink: #2e3d59;
  --ink-soft: #5d6b85;
  --line: #2e3d59;
  --blue: #5d93a8;
  --blue-soft: #9dbfcb;
  --orange: #d96b43;
  --orange-deep: #c14f2e;
  --gold: #c9a24a;
  --shadow: rgba(46, 61, 89, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background: var(--paper) url('bg.svg') center / cover fixed no-repeat;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100vh;
  /* Soft paper veil: keeps the blobs and starbursts at the edges, and the
     type always on readable cream. The blurred shadow feathers the seam. */
  background: rgba(242, 230, 200, 0.78);
  box-shadow: 0 0 36px 24px rgba(242, 230, 200, 0.78);
}

/* --------------------------------------------------------------- header -- */

.head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }

.mark {
  width: 52px; height: 52px; flex: none;
  border-radius: 15px;
  background: var(--card) url('icon.svg') center / cover;
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--shadow);
}

h1 {
  font-size: 26px; margin: 0;
  font-weight: 800; letter-spacing: -0.02em;
}

.tag {
  margin: 3px 0 0;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--blue);
}
.tag em { font-style: normal; color: var(--orange-deep); }

/* --------------------------------------------------------------- status -- */

.status { min-height: 20px; margin: 0 0 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.status.ok { color: var(--blue); }
.status.warn { color: var(--gold); }
.status.bad { color: var(--orange-deep); }

/* -------------------------------------------------------------- screens -- */

.screen { display: none; }
.screen.active { display: block; }

button {
  font: inherit;
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, color .15s ease, box-shadow .08s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 0 var(--shadow);
}
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }

.primary {
  width: 100%; padding: 16px;
  background: var(--orange); color: #fff7e6;
  font-weight: 750; font-size: 17px;
}

.secondary {
  padding: 14px 20px;
  background: var(--card); color: var(--ink);
  font-weight: 650;
}

.danger {
  padding: 14px;
  background: transparent; color: var(--orange-deep);
  border-color: var(--orange-deep);
  font-weight: 650;
  box-shadow: 0 3px 0 rgba(193, 79, 46, 0.18);
}

.wide { width: 100%; }

.lede { margin: 0 0 20px; font-size: 15px; line-height: 1.65; color: var(--ink); }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0; color: var(--ink-soft);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 2px; background: var(--ink); opacity: .25; border-radius: 2px;
}

.join { display: flex; gap: 10px; }

#join-code {
  flex: 1; min-width: 0;
  padding: 14px 18px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 16px;
  font: 700 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .18em; text-align: center;
  box-shadow: inset 0 2px 0 var(--shadow);
}
#join-code::placeholder { color: #b3a37c; letter-spacing: .18em; }
#join-code:focus { outline: 3px solid var(--blue-soft); outline-offset: 2px; }

.fine { margin: 18px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-soft); }
.fine-link { color: var(--blue); font-weight: 650; text-decoration: none; white-space: nowrap; }
.fine-link:active { color: var(--orange-deep); }
.label {
  margin: 22px 0 8px; font-size: 11px; font-weight: 750;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft);
}

.code {
  margin: 0 0 18px;
  font: 800 44px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em; color: var(--ink); text-align: center;
  padding: 24px 22px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 20px;
  box-shadow: 0 4px 0 var(--shadow);
}

/* --------------------------------------------------------------- meters -- */

.meters {
  background: var(--card); border: 2px solid var(--ink);
  border-radius: 18px; padding: 14px; margin-bottom: 12px;
  box-shadow: 0 3px 0 var(--shadow);
}
.meter-row { display: flex; align-items: center; gap: 12px; }
.meter-row + .meter-row { margin-top: 10px; }

.meter-label {
  width: 62px; flex: none; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #cbbd97; transition: background .06s, box-shadow .06s;
}
.dot.on { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

.meter {
  position: relative; flex: 1; height: 10px;
  background: #e2d3ab; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(46, 61, 89, 0.25);
}
.fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--blue-soft), var(--blue));
  border-radius: 6px;
}
.fill.them { background: linear-gradient(90deg, #e8a37f, var(--orange)); }

/* Tick showing where the gate thinks the room's noise floor sits. */
.floor {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--ink); opacity: .55;
}

/* ---------------------------------------------------------------- stats -- */

.stats { display: flex; gap: 8px; margin-bottom: 6px; }
.stat {
  flex: 1; padding: 10px 12px; text-align: center;
  background: var(--card); border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: 0 3px 0 var(--shadow);
}
.stat-label {
  display: block; font-size: 10px; font-weight: 750;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
}
.stat-value {
  display: block; margin-top: 3px; font-size: 16px; font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.stat-value.good { color: var(--blue); }
.stat-value.ok { color: var(--gold); }
.stat-value.poor { color: var(--orange-deep); }

/* ---------------------------------------------------------------- modes -- */

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.mode {
  padding: 13px 6px;
  background: var(--card); color: var(--ink-soft);
  border-radius: 14px;
  font-size: 12.5px; font-weight: 700;
}
.mode.on {
  background: var(--ink); color: var(--paper);
}

.blurb { margin: 10px 2px 0; font-size: 12.5px; color: var(--ink-soft); min-height: 34px; }

/* ------------------------------------------------------------- controls -- */

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }

.toggle {
  flex: 1; min-width: 118px; padding: 12px 10px;
  background: var(--card); color: var(--ink-soft);
  font-size: 12.5px; font-weight: 700;
  border-radius: 999px;
}
.toggle.on { background: var(--blue); color: #fff7e6; }

#btn-record.on {
  background: var(--orange-deep); color: #fff7e6;
  border-color: var(--orange-deep);
  animation: rec-pulse 1.6s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 3px 0 var(--shadow), 0 0 0 0 rgba(193, 79, 46, 0.45); }
  50% { box-shadow: 0 3px 0 var(--shadow), 0 0 0 7px rgba(193, 79, 46, 0); }
}

.row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.row label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); flex: none; }

select {
  flex: 1; min-width: 0; padding: 11px 12px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 12px;
  font: inherit; font-size: 13px; font-weight: 600;
}

.fatal { padding: 40px 24px; text-align: center; color: var(--orange-deep); font-weight: 650; }

#remote-audio { display: none; }
