:root {
  --brand: #0d6e63;
  --brand-hover: #0a584f;
  --brand-soft: #e6f4f1;
  --brand-pale: #f2faf8;
  --canvas: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f1f5f9;
  --ink-950: #0f172a;
  --ink-900: #1e293b;
  --ink-800: #334155;
  --ink-700: #475569;
  --ink-600: #526174;
  --ink-500: #536276;
  --ink-400: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --amber: #b45309;
  --amber-soft: #fff7ed;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --radius-card: 16px;
  --radius-control: 12px;
  --radius-tag: 999px;
  --shadow-sm: 0 4px 20px -2px rgba(15, 23, 42, .04), 0 2px 6px -1px rgba(15, 23, 42, .025);
  --shadow-md: 0 18px 45px -18px rgba(15, 23, 42, .2), 0 8px 18px -12px rgba(15, 23, 42, .12);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Inter, "SF Pro Text", sans-serif;
}

html,
body {
  background: var(--canvas);
}

body,
button,
input,
textarea,
select {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Inter, "SF Pro Text", sans-serif;
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  transition: border-color .18s ease, background-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease, opacity .18s ease;
}

img,
video,
canvas {
  max-width: 100%;
}

button,
[role="button"] {
  line-height: 1.25;
}

.app-view,
.app-view > *,
.workspace > *,
.view-heading > *,
.community-heading > *,
.profile-section > *,
.record-item > * {
  min-width: 0;
}

.lesson-document h1,
.lesson-document h2,
.lesson-document h3,
.lesson-document p,
.lesson-document li,
.record-item h3,
.record-item p,
.community-card h3,
.community-card p,
.setting-action b,
.setting-action small,
.danger-row b,
.danger-row small {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lesson-document mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

button:not(:disabled):active,
a:active {
  transform: scale(.98);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: none;
  border-color: rgba(13, 110, 99, .72) !important;
  box-shadow: 0 0 0 4px rgba(13, 110, 99, .12) !important;
}

.shell {
  background: var(--canvas);
}

.shell > header {
  border-right: 1px solid rgba(255, 255, 255, .08);
  background: #103c35;
}

.logo {
  border-radius: 10px;
  font-family: inherit;
  box-shadow: 0 10px 24px rgba(4, 31, 27, .22);
}

.brand-button b {
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
}

.brand-button small {
  color: rgba(236, 253, 248, .68);
  font-size: 11px;
}

.header-energy,
.icon-btn {
  min-height: 40px;
  border: 1px solid rgba(203, 213, 225, .75);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px) saturate(140%);
}

.page-view {
  padding-top: 34px;
}

.view-heading,
.community-heading {
  align-items: center;
  gap: 16px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--line);
}

.view-heading-badges {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view-heading h2,
.community-heading h2 {
  margin: 4px 0 0;
  color: var(--ink-950);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 650;
}

.view-badge,
.ai-generated-disclosure,
.mode {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(13, 110, 99, .14);
  border-radius: var(--radius-tag);
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 650;
}

.auth-legal-links,
.auth-legal-links a,
.empty-state span,
.community-empty p,
.sync-note span,
.lesson-meta span,
.section-title,
.community-filters > label > span,
.wechat-native-checkout p,
.account-deletion-warning p {
  color: var(--ink-600);
}

.learning-mode-switcher button {
  color: var(--ink-600);
}

/* Home */
.hero {
  min-height: auto;
  align-items: center;
  padding: 10px 0 26px;
}

.hero-copy {
  max-width: 690px;
}

.hero .tag {
  min-height: 30px;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(13, 110, 99, .16);
  border-radius: var(--radius-tag);
  background: rgba(230, 244, 241, .76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 650;
}

.hero .tag::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .1);
  content: "";
}

.hero h2 {
  margin: 16px 0 8px;
  color: var(--ink-950);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.34;
}

.hero h2 em {
  color: var(--brand);
  font-style: normal;
}

.hero p {
  max-width: 660px;
  margin: 0;
  color: var(--ink-600);
  font-size: 14px;
  line-height: 1.7;
}

.hero-art {
  opacity: .86;
}

.workspace {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.workspace-title {
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 0;
}

.workspace-title > div {
  min-width: 0;
}

.workspace-title b {
  color: var(--ink-950);
  font-size: 17px;
  font-weight: 650;
}

.workspace-title span,
.secure {
  color: var(--ink-600);
  font-size: 12px;
}

.secure {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: var(--radius-tag);
  color: var(--brand);
  background: var(--brand-soft);
}

.home-flow {
  min-height: 48px;
  margin-bottom: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.home-flow span {
  min-width: 0;
  min-height: 34px;
  justify-content: center;
  padding: 0 9px;
  border-radius: 9px;
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 600;
}

.home-flow span.active {
  color: var(--brand);
  background: #fff;
  box-shadow: 0 1px 5px rgba(15, 23, 42, .08);
}

.home-flow span b {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  font-size: 10px;
}

.home-flow i {
  height: 1px;
  background: var(--line-strong);
}

.home-quota {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.home-quota > div {
  display: grid;
  min-width: 0;
  align-content: center;
  padding: 7px 8px;
  border-radius: 9px;
  background: #fff;
  text-align: center;
}

.home-quota span {
  color: var(--ink-600);
  font-size: 11px;
}

.home-quota strong {
  color: var(--ink-950);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

.home-quota button {
  border-radius: 9px;
}

.drop {
  min-height: 292px;
  border: 1px solid rgba(13, 110, 99, .2);
  border-radius: var(--radius-card);
  background: #fbfefd;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8), inset 0 26px 60px rgba(13, 110, 99, .025);
  text-align: center;
}

.drop:hover {
  border-color: rgba(13, 110, 99, .42);
  background: #f8fcfb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 10px 30px rgba(13, 110, 99, .07);
}

.camera-ring {
  border-color: rgba(13, 110, 99, .18);
  background: var(--brand-soft);
  box-shadow: 0 12px 30px rgba(13, 110, 99, .09);
}

.drop > strong {
  color: var(--ink-950);
  font-size: 17px;
  font-weight: 650;
}

.drop > span:not(.camera-ring) {
  color: var(--ink-600);
  font-size: 13px;
}

.upload-choice,
.action-row button,
.primary,
.secondary {
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
}

.upload-choice,
.action-row button,
.prompt-list button,
.chat-composer button,
.community-toolbar button,
.record-tools button,
.record-actions button,
.energy-package button,
.visitor-guide-controls button,
.visitor-guide-foot button,
footer nav .nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-choice.camera-choice,
button.primary,
.primary {
  border-color: var(--brand);
  color: #fff;
  background: linear-gradient(135deg, #0d6e63 0%, #10a27f 100%);
  box-shadow: 0 10px 22px rgba(13, 110, 99, .16);
}

.upload-choice.gallery-choice,
button.secondary,
.secondary {
  border: 1px solid var(--line-strong);
  color: var(--brand);
  background: #fff;
  box-shadow: none;
}

.continue-learning,
.quick .quick-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.quick {
  gap: 12px;
}

.quick .quick-item {
  min-height: 92px;
  padding: 16px;
}

.quick .quick-item:hover {
  transform: translateY(-2px);
  border-color: rgba(13, 110, 99, .25);
  box-shadow: var(--shadow-md);
}

.quick .quick-item b {
  color: var(--ink-900);
  font-size: 15px;
  font-weight: 650;
}

.quick .quick-item small {
  color: var(--ink-600);
  font-size: 12px;
}

.quick-icon {
  border-radius: 10px !important;
}

/* AI chat */
#chatView {
  min-height: calc(100dvh - 76px);
}

.chat-context,
.feature-usage-line {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: rgba(255, 255, 255, .84);
  box-shadow: var(--shadow-sm);
}

.chat-context {
  margin: 18px 0 10px;
  padding: 14px 16px;
}

.feature-usage-line {
  margin: 0;
  padding: 12px 16px;
}

.chat-context small,
.feature-usage-line span {
  color: var(--ink-600);
  font-size: 12px;
}

.chat-context b {
  color: var(--ink-900);
  font-size: 15px;
}

.chat-empty {
  display: grid;
  min-height: 360px;
  place-content: center;
  justify-items: center;
  padding: 48px 20px;
}

.chat-empty::before {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid rgba(13, 110, 99, .18);
  border-radius: 24px;
  color: var(--brand);
  background: rgba(230, 244, 241, .9);
  box-shadow: 0 0 0 12px rgba(13, 110, 99, .035), 0 16px 35px rgba(13, 110, 99, .1);
  content: "AI";
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
  animation: ai-breathe 3.2s ease-in-out infinite;
}

@keyframes ai-breathe {
  0%, 100% { box-shadow: 0 0 0 10px rgba(13, 110, 99, .03), 0 16px 35px rgba(13, 110, 99, .08); }
  50% { box-shadow: 0 0 0 17px rgba(13, 110, 99, .055), 0 18px 42px rgba(13, 110, 99, .13); }
}

.chat-empty h3 {
  margin: 0 0 22px;
  color: var(--ink-950);
  font-size: 22px;
  font-weight: 700;
}

.prompt-list {
  gap: 10px;
}

.prompt-list button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-tag);
  color: var(--ink-700);
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 3px 12px rgba(15, 23, 42, .035);
  font-size: 13px;
}

.prompt-list button:hover {
  border-color: rgba(13, 110, 99, .32);
  color: var(--brand);
  background: var(--brand-pale);
}

.chat-composer {
  bottom: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 18px !important;
  padding: 10px !important;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .92) !important;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .12);
  backdrop-filter: blur(20px) saturate(140%);
}

.chat-composer input {
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}

.chat-composer button {
  min-width: 84px;
  min-height: 46px;
  border: 0;
  border-radius: var(--radius-control);
  color: #fff;
  background: var(--brand);
  font-size: 14px;
  font-weight: 650;
}

/* Community */
.community-heading p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--ink-600);
  font-size: 14px;
  line-height: 1.6;
}

.community-toolbar {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  grid-template-areas: "subjects search filter";
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.community-subjects {
  grid-area: subjects;
}

.community-search {
  grid-area: search;
}

.community-filter-toggle {
  grid-area: filter;
}

.segmented,
.community-subjects {
  gap: 3px;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.segmented button,
.community-subjects button {
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-600);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.segmented button.active,
.community-subjects button.active {
  color: var(--ink-950);
  background: #fff;
  box-shadow: 0 1px 5px rgba(15, 23, 42, .09);
}

.community-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.community-search input {
  width: 100%;
  min-width: 0;
}

.community-search input {
  color: var(--ink-900);
  font-size: 14px;
}

.community-search button,
.community-filter-toggle {
  min-height: 40px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 650;
}

.community-search button {
  color: var(--brand);
  background: var(--brand-soft);
}

.community-filter-toggle {
  border: 1px solid var(--line-strong);
  background: #fff;
}

.community-filters {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
}

.community-feed {
  gap: 20px;
}

.community-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.community-card:hover,
.community-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(13, 110, 99, .24);
  box-shadow: var(--shadow-md);
}

.community-cover {
  border-radius: 0;
  background: #eaf2ff;
}

.community-cover.subject-math {
  background: #eaf2ff;
}

.community-cover.subject-physics {
  background: #e5f7f5;
}

.community-cover.subject-chemistry {
  background: #fff1e6;
}

.community-cover::before {
  opacity: .24;
}

.community-cover-paper {
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: 10px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
  backdrop-filter: blur(10px);
}

.community-cover-paper p {
  color: var(--ink-900);
  font-size: 13px;
  line-height: 1.55;
}

.community-card-body {
  padding: 15px 16px 16px;
}

.community-card-subject {
  border-radius: 6px;
  font-size: 11px;
}

.community-card h3 {
  display: -webkit-box;
  min-height: 48px;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--ink-900);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.community-card-body > p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.community-card-meta {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-500);
  font-size: 11px;
}

/* Records */
.record-stats {
  gap: 10px;
  margin: 18px 0;
  padding: 0;
  background: transparent;
}

.record-stats > div {
  min-height: 104px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.record-stats > div + div {
  border-left: 1px solid var(--line);
}

.record-stats strong {
  color: var(--ink-950);
  font-family: "DIN Alternate", "SF Pro Display", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 32px;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
}

.record-stats span {
  color: var(--ink-600);
  font-size: 12px;
}

.sync-note,
.record-tools {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.record-tools {
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.record-tools > * {
  min-width: 0;
}

.record-tools input {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  font-size: 14px;
}

.record-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.record-item {
  position: relative;
  min-height: 148px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.record-item:hover {
  border-color: rgba(13, 110, 99, .24);
  box-shadow: var(--shadow-md);
}

.record-content {
  padding-right: 84px;
  text-align: left;
}

.record-item h3 {
  display: -webkit-box;
  margin: 10px 0 6px;
  overflow: hidden;
  color: var(--ink-900);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-item p {
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.55;
}

.record-actions {
  position: relative;
  display: grid;
  width: 216px;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 8px;
}

.record-actions button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-600);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.record-action-utilities {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.record-action-utilities > button,
.record-more > summary {
  display: grid;
  width: 40px;
  height: 40px;
  min-width: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-600);
  background: #fff;
  cursor: pointer;
  list-style: none;
}

.record-more {
  position: relative;
}

.record-more > summary::-webkit-details-marker {
  display: none;
}

.record-more[open] > summary {
  color: var(--brand);
  border-color: rgba(13, 110, 99, .25);
  background: var(--brand-soft);
}

.record-overflow-menu {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 8;
  width: 132px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}

.record-overflow-menu button.record-delete {
  justify-content: flex-start;
  min-height: 40px;
  color: #b42318;
  border-color: transparent;
  background: transparent;
}

.record-overflow-menu button.record-delete:hover {
  background: #fff1f0;
}

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

.record-actions button.watch-video {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 6px 16px rgba(13, 110, 99, .16);
}

.record-actions button.open-record {
  color: var(--ink-700);
  border-color: var(--line-strong);
  background: #fff;
}

.record-actions button.open-interactive {
  color: var(--brand);
  border-color: rgba(13, 110, 99, .2);
  background: var(--brand-soft);
}

.record-actions .share-record {
  position: relative;
}

.record-actions .share-record.is-loading svg {
  opacity: 0;
}

.record-actions .share-record.is-loading::after {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(13, 110, 99, .25);
  border-top-color: var(--brand);
  border-radius: 50%;
  content: '';
  animation: record-share-spin .7s linear infinite;
}

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

.record-pagination {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
}

/* Profile */
.profile-identity {
  overflow: hidden;
  margin: 18px 0;
  padding: 20px;
  border: 1px solid rgba(13, 110, 99, .1);
  border-radius: var(--radius-card);
  color: #fff;
  background: linear-gradient(135deg, #0d6e63 0%, #0a584f 58%, #123f3a 100%);
  box-shadow: 0 18px 38px -18px rgba(13, 110, 99, .45);
}

.profile-avatar {
  border: 1px solid rgba(255, 255, 255, .42);
  color: var(--brand);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 24px rgba(4, 36, 31, .2);
}

.profile-identity b {
  color: #fff;
  font-size: 17px;
}

.profile-identity small {
  color: rgba(236, 253, 248, .72);
  font-size: 12px;
}

.profile-identity .profile-logout {
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.profile-section,
.auth-panel {
  margin-bottom: 12px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.profile-section-title {
  padding-bottom: 13px;
}

.profile-section-title h3 {
  color: var(--ink-900);
  font-size: 16px;
  font-weight: 650;
}

.profile-section-title span {
  color: var(--ink-500);
  font-size: 11px;
}

.usage-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}

.usage-list > div {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  padding: 11px 0 17px;
  border-bottom: 0;
}

.usage-list > div::after {
  position: absolute;
  right: 0;
  bottom: 5px;
  left: 0;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(to right, var(--brand) var(--usage-progress, 0%), var(--surface-muted) var(--usage-progress, 0%));
  content: "";
}

.usage-list span,
.usage-list strong {
  font-size: 12px;
}

.usage-list strong {
  color: var(--ink-900);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 600;
}

.energy-section {
  border-color: rgba(13, 110, 99, .16);
  background: #fff;
}

.energy-balance-row {
  border-radius: 14px;
  background: #103c35;
}

.energy-balance-row strong {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.energy-pricing {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.energy-packages {
  gap: 12px;
}

.energy-package {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: none;
}

.energy-package.recommended,
.energy-package.selected {
  border-color: rgba(13, 110, 99, .55);
  box-shadow: 0 12px 28px rgba(13, 110, 99, .1);
}

.setting-action,
.setting-row,
.danger-row,
.account-security-row {
  min-height: 54px;
  border-bottom-color: var(--line);
}

.setting-action > span:first-child,
.setting-row > span:first-child,
.danger-row > span:first-child,
.account-security-row > span:first-child {
  min-width: 0;
}

.setting-action > span:last-child,
.danger-row > span:last-child {
  flex: 0 0 auto;
}

.context-tutor-welcome {
  display: none;
}

.setting-action b,
.setting-row b,
.danger-row b,
.account-security-row b {
  color: var(--ink-900);
  font-size: 14px;
}

.setting-action small,
.setting-row small,
.danger-row small,
.account-security-row small {
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .shell {
    padding-top: calc(74px + env(safe-area-inset-top));
    padding-right: 16px;
    padding-left: 16px;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .shell > header {
    height: calc(64px + env(safe-area-inset-top));
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(226, 232, 240, .9);
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 1px 10px rgba(15, 23, 42, .025);
    backdrop-filter: blur(20px) saturate(160%);
  }

  .logo {
    color: #fff;
    background: var(--brand);
    box-shadow: 0 8px 18px rgba(13, 110, 99, .2);
  }

  .brand-button b {
    color: var(--ink-950);
  }

  .brand-button small {
    display: none;
  }

  .header-actions {
    top: calc(12px + env(safe-area-inset-top));
    right: 16px;
  }

  .header-energy {
    top: calc(12px + env(safe-area-inset-top));
  }

  #homeView:not(.hidden) {
    gap: 14px;
  }

  .page-view {
    min-height: calc(100dvh - 166px);
    padding-top: 22px;
  }

  .view-heading,
  .community-heading {
    padding-bottom: 15px;
  }

  .view-heading h2,
  .community-heading h2,
  .hero h2,
  .chat-empty h3 {
    font-size: 22px;
  }

  .hero {
    padding: 12px 0 18px;
  }

  .hero p {
    font-size: 13px;
  }

  .hero-art {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .workspace-title b {
    font-size: 16px;
  }

  .home-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow: hidden;
  }

  .home-flow span {
    display: flex;
    width: 100%;
    padding: 0 5px;
    font-size: 11px;
    white-space: nowrap;
  }

  .home-flow i {
    display: none;
  }

  .home-quota {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-quota button {
    grid-column: 1 / -1;
    min-height: 36px;
  }

  .drop {
    min-height: 300px;
    padding: 26px 16px;
  }

  .upload-choice-row {
    width: 100%;
  }

  .upload-choice {
    min-width: 0;
    padding: 0 12px;
  }

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

  .quick .quick-item {
    min-height: 90px;
    padding: 14px;
  }

  .chat-empty {
    min-height: 330px;
    padding: 38px 10px;
  }

  .chat-empty::before {
    width: 64px;
    height: 64px;
    border-radius: 20px;
  }

  .prompt-list {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .prompt-list button {
    width: 100%;
  }

  .chat-composer {
    bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .chat-composer button {
    min-width: 68px;
  }

  .community-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "search filter"
      "subjects subjects";
    padding: 12px;
  }

  .community-subjects {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .community-feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 10px;
  }

  .community-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .community-cover {
    border-radius: 0;
  }

  .community-cover-paper {
    border-radius: 7px;
  }

  .community-card-body {
    padding: 10px 10px 11px;
  }

  .community-card h3 {
    min-height: 40px;
    margin-top: 0;
    font-size: 13px;
    line-height: 1.52;
  }

  .community-card-meta {
    margin-top: 8px;
    padding-top: 8px;
    font-size: 10px;
  }

  .record-stats {
    gap: 8px;
  }

  .record-stats > div {
    min-height: 88px;
    padding: 12px 6px;
  }

  .record-stats strong {
    font-size: 28px;
  }

  .record-tools {
    padding: 12px;
  }

  .record-tools .segmented {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }

  .record-tools .segmented button {
    width: 100%;
    min-width: 0;
    padding-inline: 6px;
  }

  .record-item {
    display: grid;
    min-height: 0;
    padding: 16px;
  }

  .record-content {
    padding-right: 0;
  }

  .record-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    margin-top: 10px;
  }

  .record-action-utilities > button,
  .record-more > summary {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .record-actions button {
    min-height: 44px;
  }

  .profile-identity,
  .profile-section,
  .auth-panel {
    border-radius: 14px;
  }

  .profile-section,
  .auth-panel {
    padding: 16px;
  }

  .usage-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .energy-pricing {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .energy-pricing > span:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  footer nav {
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(226, 232, 240, .9);
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 -8px 28px rgba(15, 23, 42, .055);
    backdrop-filter: blur(22px) saturate(150%);
  }

  footer nav .nav-item {
    display: grid;
    place-items: center;
    min-height: 64px;
    border-radius: 12px;
    color: var(--ink-500);
  }

  footer nav .nav-item.active {
    color: var(--brand);
    background: var(--brand-soft);
  }

  footer nav .nav-item small {
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
  }

  .context-tutor {
    right: 10px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  body[data-active-view="chat"] .context-tutor:not(.is-open) {
    bottom: calc(170px + env(safe-area-inset-bottom));
  }

  .context-tutor-welcome {
    display: none;
  }

  .context-tutor:not(.is-open) .context-tutor-launcher {
    width: 48px;
    height: 48px;
    padding: 5px;
  }

  .context-tutor:not(.is-open) .tutor-image-avatar-launcher {
    width: 38px;
    height: 38px;
  }

  .context-tutor:not(.is-open) .context-tutor-launcher-label {
    min-width: 24px;
    height: 18px;
    padding: 0 4px;
    font-size: 7px;
  }
}

@media (min-width: 721px) {
  .shell > footer .nav-item,
  .shell > footer .nav-item small {
    color: rgba(240, 253, 250, .76);
  }

  .shell > footer .nav-item.active,
  .shell > footer .nav-item.active small {
    color: #ffffff;
  }

  .shell > footer .nav-item.active {
    background: rgba(255, 255, 255, .1);
  }
}

@media (max-width: 380px) {
  .shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .workspace {
    padding: 15px;
  }

  .home-flow span b {
    display: none;
  }

  .home-flow span {
    min-height: 32px;
    padding-inline: 2px;
    font-size: 10px;
  }

  .community-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "subjects"
      "filter";
  }

  .community-filter-toggle {
    width: 100%;
  }

  .record-tools .segmented button {
    padding-inline: 3px;
    font-size: 11px;
  }

  .upload-choice-row {
    grid-template-columns: 1fr;
  }

  .community-feed {
    gap: 12px 8px;
  }

  .community-card-body {
    padding: 9px;
  }

  .record-stats span {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Global density and alignment pass. Keep controls touch-safe while reducing
   decorative height and giving long learning content a predictable viewport. */
.page-view {
  padding-top: 26px;
}

.view-heading,
.community-heading {
  padding-bottom: 16px;
}

.chat-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  margin-top: 14px;
  padding: 10px 14px;
}

.chat-context > div,
#chatContextTitle {
  min-width: 0;
  max-width: 100%;
}

#chatContextTitle {
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 3px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

#chatContextTitle mjx-container {
  max-width: none;
  margin: 0 2px !important;
}

#chatContextToggle {
  min-width: 64px;
  min-height: 44px;
  padding: 0 10px;
}

.feature-usage-line {
  min-height: 52px;
  padding-block: 8px;
}

.chat-empty {
  min-height: 290px;
  padding-block: 34px;
}

.chat-empty::before {
  margin-bottom: 18px;
}

.chat-empty h3 {
  margin-bottom: 16px;
}

.record-stats > div {
  min-height: 92px;
}

.record-stats strong {
  font-size: 28px;
  font-weight: 650;
}

.record-tools {
  gap: 10px;
  padding: 12px;
}

.profile-identity {
  margin-block: 14px;
  padding: 17px 18px;
}

.profile-section,
.auth-panel {
  padding: 16px 18px;
}

.profile-section-title {
  padding-bottom: 10px;
}

.setting-action,
.setting-row,
.danger-row,
.account-security-row {
  min-height: 50px;
}

.segmented button,
.community-subjects button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding-block: 0;
  text-align: center;
}

.email-binding-form button[aria-busy="true"] {
  cursor: wait;
  opacity: .78;
}

.community-empty,
#recordEmpty.empty-state {
  min-height: clamp(230px, 40dvh, 360px);
}

@media (max-width: 720px) {
  .page-view {
    padding-top: 20px;
  }

  .view-heading,
  .community-heading {
    gap: 10px;
    padding-bottom: 14px;
  }

  .view-heading h2,
  .community-heading h2 {
    font-size: 21px;
  }

  .chat-context {
    min-height: 58px;
    margin-top: 12px;
    padding: 8px 12px;
  }

  .chat-context b {
    font-size: 14px;
  }

  .chat-empty {
    min-height: 250px;
    padding-block: 28px;
  }

  .chat-empty::before {
    width: 58px;
    height: 58px;
    margin-bottom: 16px;
    border-radius: 18px;
  }

  .chat-empty h3 {
    margin-bottom: 14px;
    font-size: 20px;
  }

  .record-stats > div {
    min-height: 76px;
    padding: 10px 6px;
  }

  .record-stats strong {
    font-size: 26px;
  }

  .record-stats span {
    font-size: 11px;
  }

  .profile-identity {
    padding: 15px 16px;
  }

  .profile-section,
  .auth-panel {
    padding: 14px;
  }

  .profile-section-title {
    padding-bottom: 8px;
  }

  .segmented button,
  .community-subjects button {
    min-height: 44px;
  }

  .community-empty,
  #recordEmpty.empty-state {
    min-height: clamp(220px, 36dvh, 310px);
  }
}

/* Daily challenge final layout: loaded last to protect reading width and mobile actions. */
body[data-active-view="daily"] .daily-view {
  width: min(860px, 100%);
  max-width: 860px;
  margin-inline: auto;
}

body[data-active-view="daily"] .context-tutor:not(.is-open) {
  display: none;
}
