:root {
  color-scheme: light;
  --bg: #eef2ff;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #f1f5f9;
  --track: #f1f5f9;
  --indigo: #6366f1;
  --indigo-soft: #eef2ff;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --red: #f43f5e;
  --red-soft: #fff1f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  min-height: -webkit-fill-available;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  margin: 0;
  overflow-x: hidden;
  background: rgba(238, 242, 255, 0.5);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.monitor {
  width: min(100%, 448px);
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 40px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 6vw, 40px);
}

.app-header {
  text-align: center;
  padding-top: 8px;
}

.mark {
  width: 64px;
  height: 64px;
  display: inline-grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 24px;
  font-size: 64px;
  line-height: 1;
}

.mark svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 9vw, 2.5rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: 0;
}

p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.55;
  font-weight: 600;
}

.volume-number {
  line-height: 0.86;
  font-weight: 800;
  font-size: clamp(4rem, 22vw, 6.5rem);
  letter-spacing: 0;
  display: none;
}

.unit {
  font-size: 0.34em;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.idle {
  color: var(--muted);
  background: #f1f5f9;
}

.status-pill.listening {
  color: #059669;
  background: var(--green-soft);
}

.status-pill.loud {
  color: var(--red);
  background: var(--red-soft);
}

.status-pill.error {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.status-pill.listening .status-dot,
.status-pill.loud .status-dot {
  animation: pulse 1.15s infinite;
}

.threshold-slider-wrap {
  margin-top: 24px;
  padding: 16px;
  border-radius: 20px;
  background: #f8fafc;
  position: relative;
}

.waveform-chart {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  width: 100%;
  height: 80px;
  transform: translateY(-50%);
  z-index: 0;
  opacity: 0.3;
  pointer-events: none;
}

.slider-track-container {
  position: relative;
  height: 48px;
  display: flex;
  align-items: center;
}

.slider-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 12px;
  background: var(--track);
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.04);
  z-index: 1;
}

.slider-track-fill {
  position: absolute;
  left: 0;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--green), var(--amber), var(--red));
  z-index: 2;
  pointer-events: none;
  transition: width 0.1s ease, background 0.2s ease;
}

.threshold-label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  text-align: center;
  position: relative;
  z-index: 2;
}

#thresholdValue {
  color: var(--indigo);
  font-weight: 800;
}

.threshold-slider {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 48px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  z-index: 3;
}

.threshold-slider:focus {
  outline: none;
}

/* Webkit slider track - make transparent */
.threshold-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 12px;
  background: transparent;
  border-radius: 999px;
}

/* Webkit slider thumb */
.threshold-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(99, 102, 241, 0.25);
  cursor: grab;
  margin-top: -9px;
  transition: transform 100ms ease, box-shadow 100ms ease;
  position: relative;
  z-index: 2;
}

.threshold-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.08);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(99, 102, 241, 0.35);
}

/* Firefox slider track - make transparent */
.threshold-slider::-moz-range-track {
  width: 100%;
  height: 12px;
  background: transparent;
  border-radius: 999px;
}

/* Firefox slider thumb */
.threshold-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(99, 102, 241, 0.25);
  cursor: grab;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.threshold-slider::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.08);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(99, 102, 241, 0.35);
}

.meter-labels {
  display: none;
}

.settings-inline {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.settings-inline h2 {
  margin: 0 0 16px;
  font-size: 1.125rem;
  color: var(--ink);
  font-weight: 700;
}

.settings {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 10px;
  color: #334155;
  font-size: 0.94rem;
  font-weight: 700;
}

.field strong {
  color: var(--indigo);
}

.message-input-wrap {
  margin-top: 16px;
  padding: 16px;
  border-radius: 20px;
  background: #f8fafc;
}

.message-label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  text-align: center;
}

.alert-message-input {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: white;
  color: #1e293b;
  padding: 14px 20px;
  font-size: 1.125rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
  -webkit-user-select: text;
  user-select: text;
  text-align: center;
  font-weight: 600;
}

.alert-message-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.alert-message-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

.slider {
  width: 100%;
  accent-color: var(--indigo);
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.switch {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
  font-weight: 750;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  width: 42px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 160ms ease;
}

.switch-ui::after {
  content: "";
  width: 19px;
  height: 19px;
  position: absolute;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 160ms ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
}

.switch input:checked + .switch-ui {
  background: var(--green);
}

.switch input:checked + .switch-ui::after {
  transform: translateX(17px);
}

.permission-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 32px;
  padding-bottom: 8px;
}

.primary-button,
.secondary-button {
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--green);
  color: white;
  padding: 0 22px;
  font-size: 1.12rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 8px 22px rgba(16, 185, 129, 0.18);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button.stop {
  background: var(--red);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1), 0 8px 22px rgba(244, 63, 94, 0.18);
}

.secondary-button {
  background: #f1f5f9;
  color: var(--ink);
  padding: 0 18px;
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.98);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (max-width: 390px) {
  .monitor {
    border-radius: 32px;
  }

  .readout {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .toggle-row {
    grid-template-columns: 1fr;
  }

  .secondary-button {
    width: 100%;
  }
}

/* Remove modal and hidden button styles */
.hidden-test-button,
.settings-modal,
.settings-modal-content,
.modal-header,
.close-btn,
.modal-settings-form {
  display: none !important;
}
