:root {
  color-scheme: dark;
  --app-bg: #111827;
  --panel: #1e293b;
  --panel-soft: rgba(30, 41, 59, 0.72);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --faint: #94a3b8;
  --accent: #eaac3a;
  --feed-inset: 0.5rem;
  --success: #86efac;
  --danger: #fca5a5;
  --line: rgba(148, 163, 184, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--app-bg);
}

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

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--app-bg);
  color: var(--text);
  overscroll-behavior: none;
}

button,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 460px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--app-bg);
  position: relative;
}

.app-header {
  min-height: calc(2.8rem + env(safe-area-inset-top));
  padding: calc(0.42rem + env(safe-area-inset-top)) 0.66rem 0.38rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  background: var(--app-bg);
  z-index: 8;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.38rem;
  white-space: nowrap;
}

.brand {
  color: #fff;
  font-size: 1.08rem;
  line-height: 1;
  font-weight: 860;
}

.tagline {
  color: var(--accent);
  font-size: 0.61rem;
  line-height: 1;
  font-weight: 720;
}

.offline-status {
  min-width: 0;
  max-width: 58%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 0.62rem;
  line-height: 1.15;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.offline-status.is-ready {
  color: var(--success);
}

.offline-status.is-error {
  color: var(--danger);
  white-space: normal;
}

.feed-shell {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--app-bg);
}

.feed-strip {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  touch-action: pan-y;
  background: var(--app-bg);
}

.feed-strip::-webkit-scrollbar {
  display: none;
}

.feed-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: block;
  align-content: start;
  overflow: hidden;
  background: var(--app-bg);
}

.sense-strip {
  width: 100%;
  height: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
}

.sense-strip::-webkit-scrollbar {
  display: none;
}

.sense-page {
  flex: 0 0 100%;
  min-width: 100%;
  height: 100%;
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, auto);
  align-content: start;
  scroll-snap-align: start;
}

.word-audio {
  position: absolute;
  right: 0.56rem;
  top: 3.78rem;
  transform: translateY(-0.12rem);
  z-index: 4;
}

.sense-dots {
  position: absolute;
  left: 50%;
  bottom: 0.12rem;
  z-index: 5;
  display: flex;
  gap: 0.34rem;
  transform: translateX(-50%);
}

.sense-dot {
  width: 0.42rem;
  height: 0.42rem;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #64748b;
}

.sense-dot.active {
  background: var(--accent);
}

.feed-answer {
  min-height: 3.28rem;
  padding: 3.78rem 0.56rem 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.42rem;
  background: var(--app-bg);
}

.word-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
}

.word-lockup strong {
  flex: 0 0 auto;
  color: #fff;
  font-size: 1.32rem;
  line-height: 1.12;
  font-weight: 850;
  white-space: nowrap;
}

.word-lockup span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.12;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.audio-card-button,
.icon-button {
  flex: 0 0 auto;
  width: 2.35rem;
  height: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
}

.audio-card-button svg,
.icon-button svg {
  width: 1.38rem;
  height: 1.38rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-card-button:active,
.icon-button:active,
.control-button:active {
  transform: translateY(1px);
  color: #fff;
}

.audio-card-button:disabled {
  color: #475569;
}

.art-wrap {
  position: relative;
  width: calc(100% - (var(--feed-inset) * 2));
  margin: 0 var(--feed-inset);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  display: block;
  background: var(--app-bg);
}

.feed-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--app-bg);
  border-radius: 8px;
  -webkit-user-drag: none;
  user-select: none;
}

.info-panel {
  min-height: 0;
  padding: 1.05rem var(--feed-inset) 0;
  background: var(--app-bg);
}

.hook-grid {
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  gap: 0.35rem;
}

.hook-grid > div {
  min-width: 0;
  padding: 0.28rem 0.38rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.62);
}

.hook-grid strong {
  display: block;
  color: var(--accent);
  font-size: 0.58rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hook-grid p {
  margin: 0.12rem 0 0;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.08;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.examples-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
}

.examples-content {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: center;
  justify-items: stretch;
  gap: 0.45rem;
  padding: 1rem;
  text-align: center;
}

.example-row {
  width: 100%;
  padding: 0.45rem 0;
  text-align: center;
}

.example-row p {
  margin: 0.2rem 0;
}

.example-row p + p {
  color: var(--muted);
}

mark {
  padding: 0 0.12rem;
  border-radius: 3px;
  background: var(--accent);
  color: var(--app-bg);
}

.sentence-audio-button {
  min-height: 2rem;
  padding: 0 0.72rem;
  border: 1px solid rgba(234, 172, 58, 0.45);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent);
}

.feed-controls {
  min-height: calc(2.72rem + env(safe-area-inset-bottom));
  padding: 0.18rem 0.46rem calc(0.22rem + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--app-bg);
  border: 0;
  z-index: 7;
}

.status-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.48rem;
}

.counter-pill,
.control-button {
  min-height: 2rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 780;
}

.counter-pill {
  padding: 0.34rem 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.lesson-name {
  max-width: 8rem;
  color: var(--accent);
  font-size: 0.55rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-group {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.control-button {
  padding: 0 0.7rem;
}

.feed-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  z-index: 18;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
}

.settings-panel {
  position: absolute;
  z-index: 19;
  left: 0.55rem;
  right: 0.55rem;
  bottom: calc(0.65rem + env(safe-area-inset-bottom));
  padding: 0.85rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.97);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.42);
}

.settings-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-heading strong {
  font-size: 0.95rem;
}

.settings-close {
  min-height: 2.25rem;
  padding: 0 0.82rem;
  border: 1px solid rgba(234, 172, 58, 0.45);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(30, 41, 59, 0.9);
  font-size: 0.76rem;
  font-weight: 750;
}

.settings-panel label {
  min-width: 0;
  display: grid;
  gap: 0.28rem;
  color: var(--accent);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 760;
}

.settings-panel select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0 0.62rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.83rem;
  text-transform: none;
  letter-spacing: normal;
}

.fatal-error {
  position: absolute;
  inset: calc(3.2rem + env(safe-area-inset-top)) 0.75rem auto;
  z-index: 30;
  padding: 1rem;
  border: 1px solid rgba(252, 165, 165, 0.48);
  border-radius: 12px;
  background: #3f1d27;
  color: #fee2e2;
  font-size: 0.85rem;
  line-height: 1.4;
}

[hidden] {
  display: none !important;
}

@media (min-width: 641px) {
  :root {
    --feed-inset: 0.72rem;
  }

  .app-shell {
    border-left: 1px solid rgba(148, 163, 184, 0.16);
    border-right: 1px solid rgba(148, 163, 184, 0.16);
  }

  .feed-answer {
    min-height: 3.7rem;
    padding: 5.58rem 0.66rem 0.65rem;
  }

  .word-audio {
    right: 0.66rem;
    top: 5.58rem;
  }

  .word-lockup strong {
    font-size: 1.72rem;
  }

  .word-lockup span {
    font-size: 1rem;
  }

  .info-panel {
    padding: 1.25rem var(--feed-inset) 0;
  }

  .hook-grid {
    grid-template-columns: 0.82fr 1.18fr;
    gap: 0.45rem;
  }

  .hook-grid > div {
    padding: 0.38rem 0.55rem;
  }

  .hook-grid strong {
    font-size: 0.7rem;
  }

  .hook-grid p {
    font-size: 0.86rem;
    line-height: 1.18;
  }
}

@media (max-height: 700px) {
  .app-header {
    min-height: calc(2.35rem + env(safe-area-inset-top));
    padding-top: calc(0.26rem + env(safe-area-inset-top));
    padding-bottom: 0.22rem;
  }

  .brand {
    font-size: 0.98rem;
  }

  .feed-answer {
    min-height: 2.75rem;
    padding-top: 2.16rem;
    padding-bottom: 1.08rem;
  }

  .word-audio {
    top: 2.16rem;
  }

  .word-lockup strong {
    font-size: 1.18rem;
  }

  .info-panel {
    padding-top: 0.55rem;
  }

  .hook-grid > div {
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
  }
}
