@font-face {
  font-family: "Manjari";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Manjari-Regular.ttf") format("truetype");
  ascent-override: 105%;
  descent-override: 37%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Manjari";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Manjari-Bold.ttf") format("truetype");
  ascent-override: 114%;
  descent-override: 44%;
  line-gap-override: 0%;
}
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  color: #fff;
  font-family: "Manjari", sans-serif;
  touch-action: manipulation;
}

/* Full-viewport column: top bar, then the record stage fills the rest. */
#app {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #111;
}

.topbar {
  position: relative;
  z-index: 5;
  height: 3.4rem;
  padding: 0 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Keep clear of notches/status bars when installed. */
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}

.icon-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  /* Suppress the blue tap flash mobile browsers paint over tapped elements. */
  -webkit-tap-highlight-color: transparent;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.icon-btn:active {
  color: #fff;
}

.stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.6rem;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* The single large record/stop/playback button. */
.record {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  /* Suppress the blue tap flash mobile browsers paint over tapped elements. */
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: min(64vw, 62vh, 22rem);
  height: min(64vw, 62vh, 22rem);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The sweeping four-colour ring: a conic gradient masked down to an annulus
   and rotated so the colours appear to sweep continuously around the circle. */
.record-ring {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff6b8a, #65e39a, #ffd36b, #64b5ff, #ff6b8a);
  -webkit-mask: radial-gradient(circle farthest-side, rgba(0, 0, 0, 0) 51%, #000 52% 68%, rgba(0, 0, 0, 0) 69%);
  mask: radial-gradient(circle farthest-side, rgba(0, 0, 0, 0) 51%, #000 52% 68%, rgba(0, 0, 0, 0) 69%);
  animation: ring-sweep 8s linear infinite;
}

/* Inner face carries the state glyph (dot / square). Its radius matches the
   ring's inner edge so the full gradient band stays visible. */
.record-glyph {
  position: relative;
  width: 52%;
  height: 52%;
  border-radius: 999px;
  background: #0d0d0d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.record-glyph::before {
  content: "";
  display: block;
  transition: width 0.15s ease, height 0.15s ease, border-radius 0.15s ease, background 0.15s ease;
}

/* Idle: a filled record dot. */
.record[data-mode=idle] .record-glyph::before {
  width: 34%;
  height: 34%;
  border-radius: 999px;
  background: #ff6b8a;
}

/* Recording: a rounded stop square. */
.record[data-mode=recording] .record-glyph::before {
  width: 34%;
  height: 34%;
  border-radius: 0.4rem;
  background: #ff6b8a;
}

/* Playing: a stop square in the play accent while the recording plays back. */
.record[data-mode=playing] .record-glyph::before {
  width: 34%;
  height: 34%;
  border-radius: 0.4rem;
  background: #65e39a;
}

/* The ring sweeps faster while recording, faster still on playback. */
.record[data-mode=recording] .record-ring {
  animation-duration: 4s;
}

.record[data-mode=playing] .record-ring {
  animation-duration: 2.4s;
}

/* A soft glow pulses behind the button while recording. */
.record[data-mode=recording] {
  animation: record-glow 1.4s ease-in-out infinite;
}

@keyframes ring-sweep {
  to {
    transform: rotate(1turn);
  }
}
@keyframes record-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 138, 0);
  }
  50% {
    box-shadow: 0 0 1.6rem 0.1rem rgba(255, 107, 138, 0.4);
  }
}
/* Respect users who prefer no motion: hold the ring still. */
@media (prefers-reduced-motion: reduce) {
  .record-ring {
    animation: none;
  }
  .record[data-mode=recording] {
    animation: none;
  }
}
.status {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  min-height: 1.4em;
}

.status.error {
  color: #ff6b8a;
}

/* Shared modal shell for the recordings list and settings dialogs. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
}

.overlay[hidden] {
  display: none;
}

.panel {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  width: min(92vw, 30rem);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.9rem;
  background: rgba(22, 22, 22, 0.92);
  box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-title {
  font-family: "Manjari", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.panel-close {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  /* Suppress the blue tap flash mobile browsers paint over tapped elements. */
  -webkit-tap-highlight-color: transparent;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-close:active {
  color: #fff;
}

.panel-body {
  padding: 0.8rem 1rem 1rem;
  overflow-y: auto;
}

.recordings-empty {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  padding: 1.6rem 0.5rem;
  letter-spacing: 0.02em;
}

.recordings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recording {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
}

.recording.playing {
  background: rgba(100, 181, 255, 0.16);
  border-color: transparent;
}

/* Tapping the label plays / pauses the recording (listen back). */
.recording-play {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  /* Suppress the blue tap flash mobile browsers paint over tapped elements. */
  -webkit-tap-highlight-color: transparent;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  min-width: 0;
}

.recording-play svg {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  color: #65e39a;
}

.recording-meta {
  min-width: 0;
}

.recording-time {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-sub {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Per-row actions: save to a file, or delete. */
.recording-action {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  /* Suppress the blue tap flash mobile browsers paint over tapped elements. */
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}
.recording-action svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.recording-action:active {
  color: #fff;
}

.recording-action.delete:active {
  color: #ff6b8a;
}

.settings-form {
  display: grid;
  gap: 0.9rem;
}

.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.98rem;
  color: rgba(255, 255, 255, 0.88);
}

.settings-field-text {
  display: grid;
  gap: 0.15rem;
}

.settings-field-hint {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

/* iOS-style toggle switch. */
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 3rem;
  height: 1.7rem;
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch-track {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease;
}

.switch-thumb {
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background: #fff;
  transform: translateY(-50%);
  transition: transform 0.15s ease;
}

.switch input:checked ~ .switch-track {
  background: #65e39a;
}

.switch input:checked ~ .switch-thumb {
  transform: translate(1.3rem, -50%);
}

.settings-actions {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

.settings-btn {
  font-family: "Manjari", sans-serif;
  font-weight: 400;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0.62rem 0.75rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.settings-btn.danger {
  color: #ff6b8a;
  border-color: rgba(255, 107, 138, 0.4);
}

.settings-btn.update {
  background: #64b5ff;
  border-color: transparent;
  color: #151515;
}

.settings-install-hint {
  text-align: center;
  margin-top: 0.1rem;
}
