*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --bg-card: #020617;
  --bg-elevated: #020617;
  --border-subtle: rgba(148, 163, 184, 0.4);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.18);
  --accent-strong: #0ea5e9;
  --text-main: #e5e7eb;
  --text-soft: #9ca3af;
  --danger: #fb7185;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.9);
  --shadow-strong: 0 28px 80px rgba(15, 23, 42, 1);
  --transition-fast: 150ms ease-out;
  --max-width: 480px;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, #1e293b 0, #020617 60%),
    #020617;
  color: var(--text-main);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app-shell {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 14px 72px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.2), transparent 55%),
    radial-gradient(circle at 90% 0%, rgba(129, 140, 248, 0.18), transparent 60%);
  opacity: 0.75;
  z-index: -1;
}

.top-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.top-bar-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-name {
  font-size: 1.1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-name::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 0%, #38bdf8, transparent 60%),
    radial-gradient(circle at 70% 100%, #6366f1, transparent 60%);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.app-tagline {
  font-size: 0.82rem;
  color: var(--text-soft);
  max-width: 340px;
}

.safety-pill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(248, 250, 252, 0.15);
  padding: 5px 8px;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-soft);
}

.safety-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.3);
}

.screen-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card {
  background: radial-gradient(circle at top, #020617, #020617 60%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 12px 12px 10px;
  backdrop-filter: blur(16px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.card-title {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.control-block {
  margin-top: 8px;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.control-label-main {
  font-size: 0.84rem;
}

.control-label-sub {
  font-size: 0.74rem;
  color: var(--text-soft);
}

.control-value-tag {
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  font-size: 0.74rem;
  color: var(--accent);
  background: rgba(15, 23, 42, 0.9);
}

.control-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.number-input {
  width: 80px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
}

.number-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent-strong);
}

.beat-band-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  font-size: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.95);
}

.chip-soft {
  border-color: rgba(56, 189, 248, 0.6);
  color: var(--accent);
  background: rgba(15, 23, 42, 0.95);
}

.chip-outline {
  border-style: dashed;
}

.ear-readouts {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.ear-card {
  flex: 1;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 8px 8px 6px;
  background: rgba(15, 23, 42, 0.9);
}

.ear-label {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.ear-value-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}

.ear-value {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.ear-unit {
  font-size: 0.72rem;
  color: var(--text-soft);
}

.ear-note {
  font-size: 0.72rem;
  color: var(--text-soft);
  text-align: right;
}

.volume-row {
  padding-inline: 2px;
}

.volume-icon {
  font-size: 1rem;
  opacity: 0.85;
}

.select-input {
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
}

.select-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.divider {
  margin: 12px 0 4px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.6);
}

.field-label {
  font-size: 0.74rem;
  color: var(--text-soft);
  margin-bottom: 3px;
}

.sleep-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.sleep-inputs {
  flex: 1;
}

.sleep-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-secondary,
.btn-ghost {
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  font-size: 0.78rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary {
  border-color: rgba(56, 189, 248, 0.7);
  color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(15, 23, 42, 1);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
}

.btn-ghost {
  border-style: dashed;
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: rgba(15, 23, 42, 1);
}

.timer-countdown {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-soft);
}

.drift-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.drift-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.drift-band-hint {
  font-size: 0.7rem;
  color: var(--text-soft);
}

.drift-buttons {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.preset-description {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.info-button {
  margin-top: 10px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(56, 189, 248, 0.6);
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.95);
  color: var(--accent);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.info-button:hover {
  background: rgba(15, 23, 42, 1);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.25);
}

.info-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
}

.play-button {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: calc(var(--max-width) - 32px);
  border-radius: 999px;
  border: none;
  padding: 10px 14px;
  background: radial-gradient(circle at 0 0, #22c55e, #0f766e);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-strong);
  cursor: pointer;
  z-index: 10;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), opacity var(--transition-fast);
}

.play-button.paused {
  background: radial-gradient(circle at 0 0, var(--accent-strong), #0f172a);
}

.play-button:active {
  transform: translateX(-50%) translateY(1px) scale(0.99);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.9);
}

.play-icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 1);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.4);
  position: relative;
}

.play-button:not(.paused) .play-icon::before {
  content: "";
  position: absolute;
  inset: 3px 5px 3px 7px;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent rgba(15, 23, 42, 1);
}

.play-button.paused .play-icon::before,
.play-button.paused .play-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: rgba(15, 23, 42, 1);
  border-radius: 4px;
}

.play-button.paused .play-icon::before {
  left: 5px;
}

.play-button.paused .play-icon::after {
  right: 5px;
}

.footer {
  margin-top: 14px;
  font-size: 0.72rem;
  color: var(--text-soft);
  max-width: 360px;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 20;
}

.modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  background: radial-gradient(circle at top, #020617, #020617 60%);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  box-shadow: var(--shadow-strong);
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.modal-title {
  margin: 0;
  font-size: 0.95rem;
}

.modal-tagline {
  margin: 3px 0 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.modal-close {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-soft);
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(15, 23, 42, 1);
}

.modal-body {
  margin-top: 4px;
  padding-right: 2px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.modal-body h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-main);
  margin: 8px 0 4px;
}

.modal-body ul {
  padding-left: 18px;
  margin: 4px 0 6px;
}

.modal-body li {
  margin-bottom: 3px;
}

.modal-note {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--text-soft);
}

/* Responsive tweaks */

@media (min-width: 520px) {
  .app-shell {
    padding-inline: 20px;
  }

  .play-button {
    bottom: 20px;
    width: calc(100% - 40px);
    max-width: calc(var(--max-width) - 40px);
  }
}
