:root {
  --rose: #c83b84;
  --rose-strong: #a9226b;
  --rose-soft: #ffe8f3;
  --ink: #27212a;
  --muted: #776d79;
  --line: #eee2e8;
  --paper: #fffafc;
  --surface: #ffffff;
  --blue: #1d73e8;
  --green: #18986b;
  --shadow: 0 16px 36px rgba(97, 38, 75, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 232, 243, .8), transparent 34rem),
    linear-gradient(180deg, #fff7fb 0%, #fff 42%, #fff7fb 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  min-height: 100dvh;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 72px;
  padding: 12px clamp(16px, 4vw, 42px);
  background: rgba(255, 255, 255, .84);
  border-bottom: 1px solid rgba(238, 226, 232, .8);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(200, 59, 132, .22);
}

.brand-title {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.15;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--rose);
  background: var(--surface);
}

.icon-button svg { width: 21px; height: 21px; }

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 4vw, 34px) 28px;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #fff;
}

.hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: contain;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 26px 0 14px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.15rem);
  letter-spacing: 0;
}

.section-head p {
  margin: 6px 0 0;
  max-width: 58ch;
  color: var(--muted);
}

.progress-pill {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--rose-strong);
  background: #fff;
  font-weight: 700;
  font-size: .88rem;
}

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

.module-card, .lesson-card, .post, .empty-state, .profile-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 10px 28px rgba(88, 43, 66, .08);
}

.module-card, .lesson-card {
  overflow: hidden;
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.module-card:hover, .lesson-card:hover {
  transform: translateY(-2px);
  border-color: rgba(200, 59, 132, .35);
  box-shadow: var(--shadow);
}

.module-card button:active, .lesson-card button:active {
  background: var(--rose-soft);
}

.module-card button, .lesson-card button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #ffe8f3, #d9ecff);
  object-fit: cover;
}

.module-card .thumb {
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center;
  padding: 0;
  background: linear-gradient(135deg, #fff7fb, #edf5ff);
}

.letter-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  color: var(--blue);
  background: linear-gradient(135deg, #d9ecff, #c8dcff);
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 800;
}

.card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 86px;
  padding: 13px 14px 15px;
}

.card-title {
  margin: 0;
  color: var(--rose-strong);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .86rem;
}

.check {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
}

.check svg { width: 17px; height: 17px; }

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 18px;
}

.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  border: 0;
  color: #fff;
  background: var(--rose);
}

.secondary {
  border: 1px solid var(--line);
  color: var(--rose-strong);
  background: #fff;
}

.link-button {
  text-decoration: none;
}

.primary svg, .secondary svg { width: 18px; height: 18px; }

.lesson-view,
.lesson-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(270px, .68fr);
  gap: 18px;
  align-items: start;
}

.lesson-media,
.lesson-content {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.lesson-media img, .lesson-media .letter-thumb,
.content-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.content-frame {
  display: block;
  width: 100%;
  height: min(76vh, 760px);
  min-height: 560px;
  border: 0;
  background: #fff;
}

.html-content {
  padding: 22px;
  line-height: 1.6;
}

.gamma-doc {
  background: #fff;
}

.gamma-hero {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(260px, 1.1fr);
  gap: 0;
  align-items: stretch;
  min-height: 360px;
  background: linear-gradient(135deg, #ffe8f3, #f8d3e7 55%, #fff);
}

.gamma-hero img {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
}

.gamma-hero div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(22px, 5vw, 48px);
}

.gamma-hero p {
  margin: 0 0 10px;
  color: var(--rose-strong);
  font-weight: 900;
  text-transform: uppercase;
  font-size: .78rem;
  letter-spacing: .08em;
}

.gamma-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: .98;
  letter-spacing: 0;
}

.gamma-hero span {
  display: block;
  margin-top: 18px;
  color: #5d4d58;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.45;
}

.gamma-sections {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.gamma-section {
  display: grid;
  grid-template-columns: minmax(210px, .72fr) minmax(0, 1.28fr);
  background: #fff;
}

.gamma-section.no-image {
  grid-template-columns: 1fr;
}

.gamma-section img {
  width: 100%;
  height: 100%;
  min-height: 260px;
  object-fit: cover;
}

.gamma-section div {
  padding: clamp(20px, 4vw, 40px);
}

.gamma-section h3 {
  margin: 0 0 12px;
  color: var(--rose-strong);
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.08;
}

.gamma-section p {
  margin: 0 0 10px;
  color: #443941;
  font-size: 1rem;
  line-height: 1.55;
}

.external-fallback {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(260px, 1.1fr);
  min-height: 420px;
  background: #fff;
}

.external-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.external-fallback div {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: clamp(24px, 5vw, 54px);
}

.lesson-notes {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lesson-notes h2 { margin: 0 0 8px; }
.lesson-notes p { color: var(--muted); line-height: 1.55; }

.attachments {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7fb;
}

.attachments a {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--rose-strong);
  text-decoration: none;
  font-weight: 800;
}

.attachments svg {
  width: 18px;
  height: 18px;
}

.attachments span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachments small {
  color: var(--muted);
  font-weight: 700;
}

.notes-box {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline-color: var(--rose);
  background: #fffafc;
}

.feed-layout {
  display: grid;
  gap: 16px;
}

.post {
  overflow: hidden;
}

.post-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  color: #fff;
  background: var(--rose);
  font-weight: 900;
  object-fit: cover;
}

.post h3, .post p { margin: 0; }
.post small { color: var(--muted); }
.post-text { padding: 0 15px 15px; color: #403841; line-height: 1.55; white-space: pre-line; }
.post-image { display: block; width: 100%; max-height: 520px; object-fit: cover; border-top: 1px solid var(--line); }

.post-actions {
  display: flex;
  gap: 8px;
  padding: 12px 15px;
  border-top: 1px solid var(--line);
}

.post-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--rose-strong);
  background: transparent;
  font-weight: 800;
}

.post-actions button:active {
  background: var(--rose-soft);
}

.compose {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compose textarea, .profile-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  outline-color: var(--rose);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 26px;
  text-align: center;
}

.empty-state h2 { margin: 8px 0; }
.empty-state p { margin: 0; color: var(--muted); }

.profile-panel {
  display: grid;
  gap: 16px;
  max-width: 680px;
  padding: 18px;
}

.profile-row {
  display: grid;
  gap: 8px;
}

.profile-row label {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
}

.profile-preview {
  display: flex;
  align-items: center;
  gap: 14px;
}

.install-card {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(200, 59, 132, .22);
  border-radius: 8px;
  background: #fff;
}

.install-card.show { display: flex; }
.install-card > div { min-width: 0; }
.install-card p { margin: 0; color: var(--muted); }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #a78899;
  background: transparent;
  font-size: .76rem;
  font-weight: 800;
}

.bottom-nav button.active {
  color: var(--rose);
  background: var(--rose-soft);
}

.bottom-nav svg { width: 21px; height: 21px; }
.bottom-nav span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-view, .lesson-detail { grid-template-columns: 1fr; }
  .gamma-hero,
  .gamma-section,
  .external-fallback {
    grid-template-columns: 1fr;
  }
  .gamma-hero div {
    order: 1;
  }
  .gamma-hero img {
    order: 2;
  }
}

@media (max-width: 560px) {
  .topbar { height: 60px; padding-inline: 12px; }
  .brand-subtitle { display: none; }
  .logo { width: 38px; height: 38px; border-radius: 10px; }
  .content { padding-inline: 12px; }
  .hero, .module-card, .lesson-card, .post, .profile-panel { border-radius: 8px; }
  .toolbar > .primary,
  .toolbar > .secondary {
    flex: 1 1 150px;
  }
  .section-head { align-items: start; flex-direction: column; gap: 6px; }
  .section-head h2 { font-size: clamp(1.25rem, 5vw, 1.6rem); }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .module-card button {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: stretch;
  }
  .module-card .thumb {
    width: 112px;
    height: 112px;
    aspect-ratio: auto;
  }
  .module-card .card-body {
    min-height: 112px;
  }
  .lesson-card .thumb, .letter-thumb { aspect-ratio: 16 / 9; }
  .content-frame {
    height: 60dvh;
    min-height: 320px;
  }
  .gamma-hero,
  .gamma-hero img {
    min-height: 0;
  }
  .gamma-hero img {
    height: auto;
    aspect-ratio: 16 / 10;
  }
  .gamma-section img {
    min-height: 200px;
  }
  .card-body { padding: 10px 12px; min-height: 0; }
  .card-title { font-size: .95rem; }
  .card-meta { font-size: .8rem; }
  .install-card { align-items: start; flex-direction: column; }
  .bottom-nav button { min-height: 52px; font-size: .72rem; }
  .primary, .secondary { min-height: 40px; font-size: .9rem; }
}

@media (max-width: 380px) {
  .topbar { height: 56px; }
  .logo { width: 34px; height: 34px; border-radius: 8px; }
  .brand-title { font-size: .9rem; }
  .content { padding-inline: 10px; }
  .module-card button {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .module-card .thumb {
    width: 96px;
    height: 96px;
  }
  .module-card .card-body {
    min-height: 96px;
  }
  .section-head { margin: 18px 0 10px; }
  .bottom-nav button { font-size: .68rem; gap: 2px; }
  .bottom-nav svg { width: 19px; height: 19px; }
}
