:root {
  --bg: #faf9f5;
  --ink: #262624;
  --muted: #6f6a63;
  --faint: #857f76;
  --line: #e7e3da;
  --surface: #ffffff;
  --accent: #c96442;
  --accent-deep: #a94f31;
  --accent-soft: #f4e6df;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --radius: 20px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  display: flex;
  justify-content: center;
  padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  touch-action: manipulation;
}

.glow {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 62vh;
  pointer-events: none;
  background:
    radial-gradient(48% 52% at 50% 28%, rgba(201, 100, 66, 0.10), transparent 72%),
    radial-gradient(38% 44% at 78% 8%, rgba(201, 100, 66, 0.06), transparent 70%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: calc(18px + env(safe-area-inset-top));
}

/* ---------- bar ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
}

.brand-mark svg { width: 15px; height: 15px; }

.brand-word {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink);
}

.brand-word i {
  font-style: normal;
  color: var(--accent);
  margin: 0 2px;
}

.bar-actions { display: inline-flex; gap: 6px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .i-off { display: none; }
.icon-btn[aria-pressed="false"] { color: var(--faint); }
.icon-btn[aria-pressed="false"] .i-on { display: none; }
.icon-btn[aria-pressed="false"] .i-off { display: block; }
.icon-btn:active { background: var(--accent-soft); border-color: var(--accent-soft); }

/* ---------- hero ---------- */

.hero { padding: 6px 2px 2px; }

.kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 8.4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

.hero .sub {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 34ch;
}

/* ---------- pad ---------- */

.pad {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 52svh;
  border-radius: 26px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fdfcf8 100%);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.12s ease;
  box-shadow: 0 1px 0 rgba(38, 38, 36, 0.03), 0 18px 40px -32px rgba(38, 38, 36, 0.4);
  user-select: none;
  -webkit-user-select: none;
}

.pad.is-live {
  border-color: #ddc9bf;
  box-shadow: 0 1px 0 rgba(38, 38, 36, 0.04), 0 26px 54px -34px rgba(169, 79, 49, 0.55);
}

.pad.is-hold {
  border-color: var(--accent);
}

#trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.heart-wrap {
  position: relative;
  width: 66%;
  max-width: 232px;
  color: rgba(201, 100, 66, 0.45);
  display: grid;
  place-items: center;
  transition: color 0.3s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.heart-wrap.beat { color: var(--accent); }
.heart-wrap.beat-strong { transform: scale(1.06); }

.heart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.heart-path {
  stroke-dasharray: 340;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 0 rgba(201, 100, 66, 0));
  transition: filter 0.3s ease;
}

.pad.is-live .heart-path {
  filter: drop-shadow(0 6px 18px rgba(201, 100, 66, 0.22));
}

.heart-pulse {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 100, 66, 0.14), transparent 68%);
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.heart-pulse.on {
  animation: pulse-soft 700ms ease-out;
}

@keyframes pulse-soft {
  0% { opacity: 0.9; transform: scale(0.82); }
  100% { opacity: 0; transform: scale(1.28); }
}

.ring {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.ring.go { animation: ring-out 620ms cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes ring-out {
  0% { opacity: 0.55; transform: scale(0.28); }
  100% { opacity: 0; transform: scale(1.9); }
}

.pad-hint {
  position: absolute;
  bottom: 16px;
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #efe8df;
  border-radius: 999px;
  padding: 7px 15px;
  z-index: 4;
  transition: opacity 0.25s ease, transform 0.25s ease;
  animation: hint-breathe 2.8s ease-in-out infinite;
}

@keyframes hint-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.pad.is-live .pad-hint { opacity: 0; }

.pad-tag {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--accent-deep);
  font-weight: 500;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 4;
  padding: 0 16px;
}

.pad-tag.on { opacity: 1; transform: translateY(0); }

/* ---------- chips ---------- */

.chips-block { display: flex; flex-direction: column; gap: 10px; }

.chips-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

.chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  min-height: 52px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
}

.chip svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:active { transform: scale(0.985); background: #fbf7f3; }
.chip.playing { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- share ---------- */

.share-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid #ecd8ce;
}

.share-bar[hidden] { display: none; }

.share-text {
  font-size: 12.5px;
  color: var(--accent-deep);
  line-height: 1.35;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease;
}

.share-btn svg { width: 14px; height: 14px; }
.share-btn:active { background: var(--accent-deep); }

/* ---------- footer ---------- */

.foot { padding: 0 2px 4px; }

.foot p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--faint);
}

/* ---------- screen shake (iOS / vibration fallback) ---------- */

@keyframes shake-soft {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-1.5px, 1px, 0); }
  50% { transform: translate3d(1.5px, -1px, 0); }
  75% { transform: translate3d(-1px, -1.5px, 0); }
}

body.shake .app { animation: shake-soft 180ms ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .ring.go, .heart-pulse.on, body.shake .app { animation: none; }
  .heart-wrap { transition: none; }
}

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

@media (min-width: 700px) {
  body { padding-top: 22px; align-items: flex-start; }
  .app { max-width: 580px; gap: 20px; }
  .pad { max-height: 440px; }
  .hero h1 { font-size: 40px; }
  /* 8 rhythms fill two even rows of four — no orphan row */
  .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .chip { font-size: 12px; padding: 10px 11px; gap: 8px; min-height: 50px; }
  .chip svg { width: 15px; height: 15px; }
}
