:root {
  color-scheme: light;
  --blue: #0796cf;
  --blue-dark: #0676a3;
  --blue-soft: #e5f4fa;
  --canvas: #e8ebe9;
  --background: #f7f5f0;
  --surface: #fdfcf9;
  --text: #242729;
  --muted: #72787a;
  --line: #dedfdb;
  --shadow: 0 24px 70px rgb(35 48 51 / 12%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Avenir Next", Avenir, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--canvas);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--background);
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(68px + var(--safe-top));
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--blue) 18%, var(--line));
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgb(25 81 101 / 7%);
}

.brand-mark img {
  width: 27px;
  height: 27px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgb(25 81 101 / 6%);
  cursor: pointer;
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  padding: 26px 20px calc(110px + var(--safe-bottom));
}

body.has-miniplayer main {
  padding-bottom: calc(178px + var(--safe-bottom));
}

.view h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 38px);
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.section-label {
  margin: 30px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty-note {
  margin: 34px 4px;
  color: var(--muted);
  font-size: 15px;
}

.view-note {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.group-note {
  margin: 2px 2px 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Words ---------- */

.picker-search {
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  appearance: none;
  -webkit-appearance: none;
}

.picker-search::placeholder {
  color: var(--muted);
}

.picker-family-name {
  margin: 20px 2px 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.chip-grid {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  min-height: 36px;
  padding: 7px 14px;
  gap: 6px;
  align-items: center;
  font-size: 14.5px;
  font-weight: 540;
  letter-spacing: -0.005em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

/* ---------- Toolkit ---------- */

.situation-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr 1fr;
}

.situation-card {
  display: flex;
  padding: 15px 15px 14px;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
}

.situation-card:active {
  transform: scale(0.985);
}

.situation-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  place-items: center;
  color: var(--blue-dark);
  border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--line));
  border-radius: 13px;
  background: var(--blue-soft);
}

.situation-name {
  font-size: 15.5px;
  font-weight: 640;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.situation-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tool-list {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 20px;
  background: var(--surface);
}

.tool + .tool {
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.tool-head {
  display: flex;
  width: 100%;
  min-height: 56px;
  padding: 13px 16px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tool-head svg {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 160ms ease;
}

.tool.is-open .tool-head svg {
  transform: rotate(180deg);
}

.tool-head-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.tool-name {
  font-size: 15.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.tool-line {
  color: var(--muted);
  font-size: 13px;
}

.tool-detail {
  padding: 0 16px 15px;
}

.practice-steps {
  margin: 2px 0 0;
  padding-left: 19px;
  color: color-mix(in srgb, var(--text) 84%, var(--muted));
  font-size: 14.5px;
  line-height: 1.55;
}

.practice-steps li {
  margin-bottom: 6px;
}

.practice-steps li::marker {
  color: color-mix(in srgb, var(--blue) 65%, var(--muted));
}

.tool-link {
  display: inline-flex;
  margin-top: 8px;
  padding: 8px 0;
  gap: 4px;
  align-items: center;
  color: var(--blue-dark);
  font-size: 14.5px;
  font-weight: 640;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tool-audio {
  margin-top: 10px;
}

.tool-audio .track {
  padding: 9px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tool-audio .track + .track {
  border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

.daily-quote {
  margin: 34px 24px 0;
  color: var(--muted);
  font-size: 15.5px;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

.support-note {
  margin: 22px 4px 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
}

.support-note a {
  color: var(--blue-dark);
  font-weight: 600;
  text-decoration: none;
}

.back-link {
  display: inline-flex;
  margin: 0 0 14px -6px;
  padding: 8px 12px 8px 6px;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  font-size: 15px;
  font-weight: 620;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.situation-intro {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.situation-listen .track,
.audio-group .track {
  margin-bottom: 8px;
}

.situation-tool {
  padding: 15px 16px;
  margin-bottom: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 18px;
  background: var(--surface);
}

.situation-tool-name {
  margin: 0 0 5px;
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.situation-tool-how {
  margin: 0;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  font-size: 14.5px;
  line-height: 1.5;
}

/* ---------- Audio ---------- */

.audio-group {
  margin-bottom: 6px;
}

.track {
  position: relative;
  display: flex;
  overflow: hidden;
  width: 100%;
  padding: 12px 14px;
  gap: 13px;
  align-items: center;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 18px;
  background: var(--surface);
  cursor: pointer;
}

.track:active {
  transform: scale(0.99);
}

.track.is-playing {
  border-color: color-mix(in srgb, var(--blue) 30%, var(--line));
  box-shadow: 0 8px 22px rgb(25 81 101 / 8%);
}

.track-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  place-items: center;
  color: var(--blue-dark);
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: 999px;
  background: var(--blue-soft);
}

.track.is-playing .track-toggle {
  color: white;
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.track-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.track-title {
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-sub {
  color: var(--muted);
  font-size: 13px;
}

.track-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
  opacity: 0;
  transition: opacity 200ms ease;
}

.track-progress-fill {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 400ms linear;
}

.closure-toggle {
  display: inline-flex;
  margin: 2px 0 8px;
  padding: 10px 4px;
  gap: 6px;
  align-items: center;
  color: var(--blue-dark);
  font-size: 14.5px;
  font-weight: 640;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.closure-toggle svg {
  transition: transform 160ms ease;
}

.closure-toggle.is-open svg {
  transform: rotate(180deg);
}

/* ---------- Mini player ---------- */

.miniplayer {
  position: fixed;
  z-index: 25;
  bottom: calc(78px + var(--safe-bottom));
  left: 50%;
  display: flex;
  overflow: hidden;
  width: min(100% - 24px, 456px);
  padding: 10px 14px 12px;
  gap: 12px;
  align-items: center;
  text-align: left;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--line));
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 14px 40px rgb(22 31 35 / 16%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
}

.miniplayer-toggle {
  display: grid;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  place-items: center;
  color: white;
  border-radius: 999px;
  background: var(--blue-dark);
}

.miniplayer-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 0;
}

.miniplayer-title {
  overflow: hidden;
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miniplayer-time {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.miniplayer-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: color-mix(in srgb, var(--line) 55%, transparent);
}

.miniplayer-progress-fill {
  display: block;
  height: 100%;
  background: var(--blue);
  transition: width 400ms linear;
}

/* ---------- Player sheet ---------- */

.player-sheet-title {
  margin: 6px 0 0;
  font-size: 21px;
  font-weight: 640;
  letter-spacing: -0.025em;
}

.player-sheet-voice {
  margin: 2px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.player-scrub {
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.player-scrub::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 90%, transparent);
}

.player-scrub::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border: 0;
  border-radius: 999px;
  background: var(--blue-dark);
  box-shadow: 0 2px 8px rgb(6 118 163 / 35%);
  appearance: none;
  -webkit-appearance: none;
}

.player-scrub::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 90%, transparent);
}

.player-scrub::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--blue-dark);
}

.player-times {
  display: flex;
  margin-top: 2px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.player-controls {
  display: flex;
  margin: 18px 0 6px;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.player-main-toggle {
  display: grid;
  width: 68px;
  height: 68px;
  padding: 0;
  place-items: center;
  color: white;
  border: 0;
  border-radius: 999px;
  background: var(--blue-dark);
  box-shadow: 0 10px 26px rgb(6 118 163 / 30%);
  cursor: pointer;
}

.player-main-toggle:active {
  transform: scale(0.96);
}

.player-skip {
  display: grid;
  width: 52px;
  height: 52px;
  padding: 0;
  place-items: center;
  color: var(--text);
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.player-side-btn {
  display: grid;
  width: 46px;
  height: 40px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  border: 0;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
}

button.player-side-btn:active {
  background: var(--blue-soft);
}

/* ---------- Shared chrome ---------- */

.tabbar {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 50%;
  display: grid;
  width: min(100%, 480px);
  min-height: calc(72px + var(--safe-bottom));
  padding: 8px 12px calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.tab {
  display: flex;
  min-width: 0;
  min-height: 54px;
  padding: 6px 8px;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: 17px;
  background: transparent;
  cursor: pointer;
}

.tab svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.is-active {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.connection-status {
  position: fixed;
  z-index: 30;
  top: calc(12px + var(--safe-top));
  left: 50%;
  padding: 7px 12px;
  transform: translateX(-50%);
  color: white;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 8px 22px rgb(0 0 0 / 18%);
}

.toast {
  position: fixed;
  z-index: 60;
  bottom: calc(150px + var(--safe-bottom));
  left: 50%;
  max-width: min(100% - 40px, 420px);
  padding: 11px 18px;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  font-weight: 580;
  text-align: center;
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 22%);
}

.spinner {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentcolor 30%, transparent);
  border-top-color: currentcolor;
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Sheets ---------- */

.sheet {
  width: min(100%, 480px);
  max-width: none;
  margin: auto auto 0;
  padding: 10px 24px calc(22px + var(--safe-bottom));
  color: var(--text);
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 60px rgb(22 31 35 / 18%);
}

.sheet::backdrop {
  background: rgb(21 31 35 / 42%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet-handle {
  width: 38px;
  height: 5px;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: var(--line);
}

.install-sheet h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -0.035em;
}

.install-sheet p {
  margin: 12px 0 22px;
  color: #555c5e;
  font-size: 16px;
  line-height: 1.5;
}

.primary-button,
.text-button {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  cursor: pointer;
}

.primary-button {
  color: white;
  font-weight: 680;
  border: 0;
  background: var(--blue-dark);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: default;
}

.text-button {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 620;
  border: 0;
  background: transparent;
}

[hidden] {
  display: none !important;
}

@media (min-width: 520px) {
  .app-shell {
    box-shadow: var(--shadow);
  }

  .topbar,
  .tabbar {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .view.is-active {
    animation: view-in 180ms ease-out;
  }

  .sheet {
    animation: sheet-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .miniplayer {
    animation: rise-in 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .toast {
    animation: rise-in 200ms ease-out;
  }
}

@keyframes view-in {
  from {
    transform: translateY(4px);
    opacity: 0;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

@keyframes rise-in {
  from {
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
