:root {
  --bg-start: #ffef9a;
  --bg-end: #9ae6ff;
  --card: #ffffff;
  --accent: #ff6b6b;
  --accent-dark: #ff3d3d;
  --play: #28a745;
  --stop: #ff9f1a;
  --text: #1a1a1a;
  --shadow: rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", "Bradley Hand", cursive;
  color: var(--text);
  display: grid;
  place-items: center;
  background: transparent;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, var(--bg-start), var(--bg-end));
  transition: background 0.6s ease;
  z-index: 0;
}

body.recording .bg-layer,
html.recording body .bg-layer {
  background: radial-gradient(circle at top, #ffd6d6, #ffb3b3);
}

.app {
  position: relative;
  z-index: 1;
}

.app {
  width: min(900px, 92vw);
  padding: 24px;
  display: grid;
  gap: 20px;
}

.hero {
  text-align: center;
  background: var(--card);
  padding: 20px 18px;
  border-radius: 24px;
  box-shadow: 0 12px 24px var(--shadow);
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  margin: 0 0 8px;
  letter-spacing: 1px;
}

.hero p {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.4rem);
}

.panel {
  background: var(--card);
  padding: 18px;
  border-radius: 20px;
  box-shadow: 0 10px 20px var(--shadow);
  display: grid;
  gap: 12px;
}

.status {
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  text-align: center;
}

.meter {
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffe066, #ff9f1a, #ff6b6b);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.15s ease;
}

.controls {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.controls-record {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.icon-stack {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 18px 22px;
  font-size: clamp(1.1rem, 2.6vw, 1.6rem);
  cursor: pointer;
  box-shadow: 0 10px 18px var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease;
}

.btn:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 6px 12px var(--shadow);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-btn {
  width: min(180px, 45vw);
  height: min(180px, 45vw);
  max-width: 200px;
  max-height: 200px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  place-items: center;
}

.icon {
  display: inline-block;
}

.icon-label {
  font-size: 1.1rem;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.icon-record {
  width: min(110px, 60%);
  height: min(110px, 60%);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.6);
}

.icon-stop {
  width: min(90px, 50%);
  height: min(90px, 50%);
  border-radius: 12px;
  background: #fff;
}

.btn-record {
  background: var(--accent);
  color: #fff;
}

.btn-stop {
  background: var(--stop);
  color: #1f1f1f;
}

.btn-play {
  background: var(--play);
  color: #fff;
}

.tips {
  text-align: center;
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
}

.tip {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.history {
  background: var(--card);
  padding: 18px;
  border-radius: 20px;
  box-shadow: 0 10px 20px var(--shadow);
}

.history h2 {
  margin: 0 0 12px;
  font-size: clamp(1.2rem, 2.8vw, 1.6rem);
  text-align: center;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.history-item {
  display: grid;
  gap: 12px;
  align-items: center;
  grid-template-columns: 1fr auto;
  background: rgba(255, 255, 255, 0.7);
  padding: 12px;
  border-radius: 16px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.history-item:nth-child(even) {
  background: rgba(255, 255, 255, 0.92);
}

.history-item.is-playing {
  outline: 3px solid rgba(43, 107, 255, 0.35);
}

.history-info {
  display: grid;
  gap: 6px;
}

.history-title {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-title-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.2;
}

.history-playing {
  display: none;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(43, 107, 255, 0.15);
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.history-item.is-playing .history-playing {
  display: inline-flex;
}

.history-meta {
  display: flex;
  gap: 12px;
  font-size: 0.9rem;
  opacity: 0.85;
}

.history-time {
  font-size: 0.9rem;
}

.history-duration {
  font-size: 0.9rem;
}

.history-controls {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
}

.history-waveform-wrap {
  position: relative;
  width: 100%;
  height: 70px;
  border-radius: 12px;
  background: #f2f2f2;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}

.history-waveform {
  width: 100%;
  height: 100%;
  display: block;
}

.history-playhead {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 4px;
  left: 0%;
  transform: translateX(-50%);
  background: #1a1a1a;
  border-radius: 999px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.history-btn {
  font-size: 1rem;
  padding: 18px 22px;
  display: grid;
  place-items: center;
  min-width: 108px;
  min-height: 68px;
}

.history-btn .icon {
  display: block;
}

.history-btn-forward {
  background: #2fb85a;
}

.history-btn-back {
  background: #ff8c2a;
}

.history-btn-stop {
  background: #e53935;
}

.icon-play {
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid #fff;
}

.icon-reverse {
  position: relative;
  width: 36px;
  height: 24px;
}

.icon-reverse::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 16px solid #fff;
}

.icon-reverse::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 0;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 16px solid #fff;
}

.history-btn-stop .icon-stop {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.history-empty {
  text-align: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
}

@media (max-width: 600px) {
  .app {
    padding: 16px;
  }

  .btn {
    padding: 16px 18px;
  }

  .icon-btn {
    width: min(150px, 60vw);
    height: min(150px, 60vw);
  }
}
