:root {
  --bg: #fff2e7;
  --surface: #fffaf4;
  --text: #1c1f23;
  --muted: #626262;
  --border: #eadbd0;
  --accent: #f74a83;
  --accent-dark: #d9366b;
  --shadow: 0 18px 50px rgba(28, 31, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(255, 242, 231, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.store-link {
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  text-align: center;
  margin: 0 auto 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.05;
}

.intro {
  max-width: 720px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 17px;
}

.controls {
  display: grid;
  gap: 14px;
  margin: 0 0 26px;
}

.search {
  width: min(640px, 100%);
  height: 48px;
  margin: 0 auto;
  padding: 0 18px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 74, 131, 0.16);
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.categories button,
.format-tabs button,
.hand-tabs button,
.nav-row button,
.guide-actions button,
.guide-actions a,
.back {
  min-height: 40px;
  padding: 9px 14px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.categories button.active,
.format-tabs button.active,
.hand-tabs button.active,
.primary,
.nav-row button:last-child {
  color: white;
  background: var(--text);
  border-color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--desktop-columns, 4), minmax(0, 1fr));
  gap: 18px;
}

.card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 31, 35, 0.08);
}

.card-media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: #f3e7dd;
  border: 0;
  cursor: pointer;
}

.card-media img,
.viewer-head img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.card-body {
  padding: 16px;
}

.model {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.card h2 button {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.card p {
  color: var(--muted);
}

.card .primary {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
}

.viewer {
  display: grid;
  gap: 18px;
}

.viewer-head {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.viewer-head img {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
}

.viewer-head h2 {
  margin: 0 0 8px;
  font-size: 30px;
}

.viewer-head p {
  margin: 0;
  color: var(--muted);
}

.format-tabs,
.hand-tabs,
.nav-row,
.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.player {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 8px;
}

.player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.player p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: white;
}

.now-playing,
.playlist,
.guide {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.now-playing p:first-child {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.lesson-button {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 12px;
  text-align: left;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.lesson-button.active {
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
}

.lesson-button span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.guide-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 0 0 14px;
}

.guide-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.guide-stage {
  min-height: 520px;
  padding: 14px;
  overflow: auto;
  background: #f7eee6;
  border-radius: 8px;
}

.pdf-book {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.pdf-book canvas,
.image-reader img {
  width: 100%;
  height: auto;
  background: white;
  box-shadow: 0 8px 22px rgba(28, 31, 35, 0.16);
}

.image-reader {
  display: grid;
  place-items: center;
}

.modal[hidden],
[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  border: 0;
}

.dialog {
  position: relative;
  width: min(460px, 100%);
  padding: 26px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.kicker {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.selected-product {
  padding: 12px;
  margin: 14px 0;
  background: var(--bg);
  border-radius: 8px;
}

.dialog label {
  display: block;
  margin: 0 0 6px;
  font-weight: 700;
}

.dialog input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.message {
  min-height: 20px;
  color: var(--accent-dark);
}

.dialog .primary {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 24px, 640px);
    padding-top: 28px;
  }

  .grid {
    grid-template-columns: repeat(var(--mobile-columns, 1), minmax(0, 1fr));
  }

  .viewer-head,
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .viewer-head img {
    width: 120px;
  }

  .guide-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .guide-stage {
    min-height: 420px;
  }

  .pdf-book {
    grid-template-columns: 1fr;
  }
}
