:root {
  --bg: #eaf5ff;
  --bg-2: #f7fbff;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.88);
  --panel-soft: rgba(246, 251, 255, 0.66);
  --ink: #10223f;
  --ink-soft: #32466f;
  --muted: #7586a8;
  --line: rgba(112, 143, 205, 0.22);
  --line-strong: rgba(84, 122, 214, 0.34);
  --blue: #3a8cff;
  --blue-2: #5ad8ff;
  --violet: #8b5cf6;
  --violet-2: #b46dff;
  --cyan: #21c8f6;
  --danger: #d24b61;
  --shadow: 0 24px 70px rgba(64, 104, 178, 0.20);
  --shadow-soft: 0 14px 36px rgba(64, 104, 178, 0.13);
  --shadow-tiny: 0 8px 22px rgba(64, 104, 178, 0.10);
  --glow: 0 0 0 1px rgba(255,255,255,0.66) inset, 0 18px 46px rgba(81,126,236,0.18);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-width: 292px;
  --topbar-height: 70px;
}

* { box-sizing: border-box; }

*::before,
*::after {
  box-sizing: border-box;
}

html, body, #app {
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
canvas,
iframe {
  max-width: 100%;
}
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(125deg, #eef8ff 0%, #f9fcff 45%, #edf1ff 100%);
  text-rendering: geometricPrecision;
}

img,
svg,
canvas,
iframe {
  max-width: 100%;
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: rgba(80, 130, 255, 0.18);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(76, 105, 175, 0.34);
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(76, 105, 175, 0.52);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(430px, 100%);
  padding: 32px;
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.18;
  font-weight: 950;
  color: var(--ink);
}

#loginForm h1 {
  margin-bottom: 24px;
}

.login-box p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.7;
}

.login-box input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(255,255,255,0.82);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255,255,255,0.9) inset;
}

.login-box .primary {
  width: 100%;
}

.login-error {
  min-height: 25px;
  margin-top: 10px;
  color: var(--danger);
}

.login-box input:focus,
.search input:focus,
textarea:focus {
  border-color: rgba(75, 133, 255, 0.68);
  box-shadow: 0 0 0 4px rgba(74, 141, 255, 0.13);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  padding: 18px;
  gap: 18px;
}

.sidebar {
  height: calc(100vh - 36px);
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px 16px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(243,249,255,0.66));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 22px;
}

.mark {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: transparent;
  background: linear-gradient(145deg, rgba(57,143,255,0.16), rgba(145,98,255,0.15));
  box-shadow: 0 12px 28px rgba(66, 121, 240, 0.24), 0 0 0 1px rgba(255,255,255,0.78) inset;
}

.mark::before,
.mark::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 13px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-2), var(--violet));
  transform-origin: 50% 50%;
  box-shadow: 0 8px 18px rgba(76, 133, 255, 0.28);
}

.mark::before {
  transform: rotate(35deg) translateY(-5px);
}

.mark::after {
  transform: rotate(-35deg) translateY(5px);
  background: linear-gradient(90deg, var(--violet), var(--blue));
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.32;
  font-weight: 950;
  color: #17315a;
}

.home-link,
.lesson-item,
.ghost,
.primary,
.stop-button,
.tone,
.attach-label {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.78);
  color: var(--ink);
  font-weight: 850;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.home-link,
.ghost,
.primary,
.stop-button,
.tone,
.attach-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
}

.home-link {
  width: 100%;
  margin-bottom: 12px;
  min-height: 48px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  border-color: rgba(255,255,255,0.5);
  box-shadow: 0 14px 28px rgba(90, 114, 250, 0.34);
}

.home-link::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 2px solid currentColor;
  box-shadow: 5px -5px 0 -3px currentColor;
}

.home-link:hover,
.primary:hover,
.ghost:hover,
.tone:hover,
.attach-label:hover,
.lesson-item:hover {
  transform: translateY(-1px);
}

.home-link.active {
  color: #fff;
}

.teacher-note-link {
  width: 100%;
  min-height: 42px;
  margin-bottom: 14px;
  border: 1px solid rgba(102, 140, 220, 0.22);
  border-radius: 14px;
  color: #244fbd;
  background: rgba(255,255,255,0.72);
  font-weight: 900;
  box-shadow: var(--shadow-tiny);
}

.teacher-note-link:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.94);
}

.home-history {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(124, 151, 205, 0.16);
}

.home-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  color: #203b67;
  font-size: 13px;
  font-weight: 950;
}

.home-history-head button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(102, 140, 220, 0.22);
  border-radius: 11px;
  color: #2f59ca;
  background: rgba(255,255,255,0.68);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(80, 124, 205, 0.08);
}

.home-thread-list {
  display: grid;
  gap: 6px;
  max-height: 168px;
  overflow: auto;
  padding-right: 2px;
}

.home-thread-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
}

.home-thread {
  width: 100%;
  min-height: 38px;
  padding: 8px 8px 8px 10px;
  border: 0;
  border-radius: 11px;
  color: #405277;
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.home-thread span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-thread-row:hover {
  color: #2456dc;
  background: rgba(255,255,255,0.58);
}

.home-thread-row.active {
  color: #2355dc;
  border-color: rgba(82, 128, 255, 0.22);
  background: linear-gradient(90deg, rgba(80,142,255,0.16), rgba(149,98,255,0.08));
  box-shadow: 0 10px 20px rgba(82, 128, 255, 0.10);
}

.home-thread-row.active .home-thread {
  color: #2355dc;
}

.home-thread-delete {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #8a9abd;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  opacity: 0.62;
}

.home-thread-row:hover .home-thread-delete,
.home-thread-row.active .home-thread-delete {
  opacity: 1;
}

.home-thread-delete:hover {
  color: #c7354d;
  background: rgba(255, 235, 240, 0.90);
}

.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 34, 63, 0.28);
  backdrop-filter: blur(10px);
}

.feedback-card {
  width: min(560px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 24px;
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow);
}

.feedback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.feedback-head h2 {
  margin: 0 0 6px;
  color: #17315a;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 950;
}

.feedback-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.feedback-close {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid rgba(122, 149, 205, 0.18);
  border-radius: 12px;
  color: #60749b;
  background: rgba(246, 250, 255, 0.86);
  font-size: 22px;
  line-height: 1;
}

.feedback-lesson {
  padding: 10px 12px;
  border: 1px solid rgba(80, 142, 255, 0.16);
  border-radius: 14px;
  color: #315181;
  background: rgba(238, 247, 255, 0.78);
  font-weight: 850;
}

.feedback-card label {
  display: grid;
  gap: 7px;
  color: #203b67;
  font-weight: 900;
}

.feedback-card select,
.feedback-card input,
.feedback-card textarea {
  width: 100%;
  border: 1px solid rgba(122, 149, 205, 0.22);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,0.82);
}

.feedback-card select,
.feedback-card input {
  height: 42px;
  padding: 0 12px;
}

.feedback-card textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

.feedback-status {
  min-height: 24px;
  color: var(--danger);
  font-weight: 850;
}

.feedback-status.ok {
  color: #227a57;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.teacher-page {
  min-height: 100vh;
  padding: 24px;
}

.teacher-head {
  max-width: 980px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 24px;
  background: rgba(255,255,255,0.82);
  box-shadow: var(--shadow-soft);
}

.teacher-head h1 {
  margin: 0 0 6px;
  color: #17315a;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 950;
}

.teacher-head p {
  margin: 0;
  color: var(--muted);
}

.teacher-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.teacher-list {
  max-width: 980px;
  margin: 0 auto 18px;
  display: grid;
  gap: 12px;
}

.teacher-list h2 {
  margin: 8px 0 2px;
  color: #17315a;
  font-size: 20px;
  line-height: 1.25;
}

.teacher-item,
.teacher-empty {
  position: relative;
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 20px;
  background: rgba(255,255,255,0.82);
  box-shadow: var(--shadow-tiny);
}

.teacher-item.question {
  border-color: rgba(85, 131, 230, 0.18);
  background: rgba(247, 251, 255, 0.88);
}

.teacher-delete {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(210, 75, 97, 0.18);
  border-radius: 11px;
  color: #b33b50;
  background: rgba(255,255,255,0.82);
  font-weight: 850;
}

.teacher-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-right: 72px;
  color: var(--muted);
  font-size: 14px;
}

.teacher-item-meta strong {
  color: #2456dc;
  font-size: 15px;
}

.teacher-lesson,
.teacher-name {
  margin-top: 10px;
  color: #315181;
  font-weight: 850;
}

.teacher-item p {
  margin: 12px 0 0;
  color: var(--ink);
  line-height: 1.8;
  white-space: normal;
}

.teacher-answer {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(111, 143, 210, 0.14);
  border-radius: 14px;
  background: rgba(255,255,255,0.74);
}

.teacher-error {
  color: var(--danger);
}

.teacher-empty {
  color: var(--muted);
  text-align: center;
}

.primary,
.tone.active {
  color: #fff;
  border-color: rgba(255,255,255,0.62);
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 12px 24px rgba(91, 116, 250, 0.28);
}

.primary::before {
  content: "";
  width: 15px;
  height: 15px;
  display: inline-block;
  clip-path: polygon(0 10%, 100% 50%, 0 90%, 18% 55%);
  background: currentColor;
}

.ghost {
  background: rgba(255,255,255,0.72);
  box-shadow: var(--shadow-tiny);
}

.ghost:hover {
  border-color: rgba(75, 132, 255, 0.46);
  background: rgba(255,255,255,0.94);
}

.stop-button {
  color: var(--danger);
  border-color: rgba(210, 75, 97, 0.28);
  background: rgba(255,245,248,0.92);
}

.search {
  display: grid;
  gap: 9px;
  margin: 0 0 12px;
  color: #203b67;
  font-size: 14px;
  font-weight: 950;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 8px 18px rgba(80, 124, 205, 0.08);
}

.search input::placeholder,
textarea::placeholder {
  color: #8a9abd;
}

.lesson-list {
  display: grid;
  gap: 7px;
  padding: 2px 0 4px;
}

.lesson-item {
  position: relative;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px 10px 36px;
  text-align: left;
  color: #33466f;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.lesson-item::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 14px;
  width: 13px;
  height: 15px;
  border: 1.7px solid #7692cb;
  border-radius: 3px;
  background: rgba(255,255,255,0.62);
}

.lesson-item::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 19px;
  width: 6px;
  height: 1.5px;
  background: #7692cb;
  box-shadow: 0 4px 0 #7692cb;
}

.lesson-item:hover {
  color: #224fc8;
  background: rgba(255,255,255,0.56);
}

.lesson-item.active {
  color: #2456dc;
  border-color: rgba(82, 128, 255, 0.22);
  background: linear-gradient(90deg, rgba(80,142,255,0.16), rgba(149,98,255,0.08));
  box-shadow: 0 10px 20px rgba(82, 128, 255, 0.12);
}

.lesson-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 850;
}

.lesson-item span {
  display: none;
}

.empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 14px;
}

.main {
  min-width: 0;
  height: calc(100vh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,0.76);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.74), rgba(243,249,255,0.58));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.topbar {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(123, 149, 205, 0.14);
  background: rgba(255,255,255,0.44);
  backdrop-filter: blur(18px);
}

.topbar h2 {
  min-width: 0;
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 950;
  color: #17315a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.mobile-menu-toggle,
.mobile-sidebar-backdrop {
  display: none;
}

.top-actions .ghost,
.top-actions .link-button {
  min-height: 40px;
  white-space: nowrap;
}

[data-open-novel] {
  color: #fff;
  border-color: rgba(255,255,255,0.62);
  background: linear-gradient(135deg, #6d8cff, #9b64ff);
  box-shadow: 0 12px 24px rgba(103, 112, 240, 0.24);
}

.home-chat {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  width: min(900px, calc(100% - 44px));
  margin: 0 auto;
  padding: 26px 0 26px;
}

.home-empty {
  min-height: 270px;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  text-align: center;
  color: var(--ink-soft);
  border: 1px solid rgba(146, 169, 215, 0.16);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255,255,255,0.68), rgba(239,248,255,0.54));
  box-shadow: 0 26px 60px rgba(68, 111, 185, 0.12);
}

.home-copy {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.hero-kicker {
  color: #4267dd;
  font-weight: 950;
  letter-spacing: 0.02em;
}

.home-empty h3 {
  margin: 0;
  font-size: clamp(30px, 4.8vw, 48px);
  line-height: 1.08;
  font-weight: 950;
  color: #2639d7;
  text-shadow: 0 12px 32px rgba(70, 110, 220, 0.18);
}

.home-empty p {
  margin: 0;
  color: #687ba2;
  font-size: 15px;
  line-height: 1.7;
}

.lesson-view {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 10px minmax(330px, var(--chat-width, 420px));
  background: rgba(241, 247, 255, 0.42);
}

.mobile-lesson-tabs {
  display: none;
}

.pdf-wrap {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 0 16px 16px;
}

.pdf-head {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 14px 12px 0;
}

.pdf-head h3 {
  min-width: 0;
  margin: 0;
  color: #17315a;
  font-size: 17px;
  line-height: 1.28;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-frame {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
  overflow: auto;
  border: 1px solid rgba(112, 143, 205, 0.20);
  border-radius: 18px;
  background: rgba(235, 243, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.pdf-empty {
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  font-size: 15px;
}

.pdf-loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: #59729d;
  font-weight: 850;
}

.pdf-pages {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 18px;
  justify-items: center;
  padding: 18px;
}

.pdf-image-viewer {
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scroll-behavior: auto;
}

.pdf-page {
  width: min(100%, 920px);
  margin: 0;
  display: grid;
  gap: 9px;
}

.pdf-page img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid rgba(118, 142, 195, 0.20);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(42, 79, 145, 0.15);
}

.pdf-page figcaption {
  color: #6680ae;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.divider {
  width: 10px;
  cursor: col-resize;
  background:
    linear-gradient(90deg, transparent 0, transparent 4px, rgba(86,130,255,0.28) 4px, rgba(86,130,255,0.28) 6px, transparent 6px);
}

.divider:hover {
  background:
    linear-gradient(90deg, transparent 0, transparent 4px, rgba(86,130,255,0.74) 4px, rgba(86,130,255,0.74) 6px, transparent 6px);
}

.side-chat {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 16px 16px 0;
}

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 4px 12px;
  scroll-behavior: smooth;
}

.msg {
  flex-shrink: 0;
  width: fit-content;
  max-width: min(740px, 92%);
  padding: 10px 14px;
  border: 1px solid #e5ebf4;
  border-radius: 14px;
  background: rgba(255,255,255,0.76);
  box-shadow: var(--shadow-tiny);
  line-height: 1.65;
  backdrop-filter: blur(16px);
}

.msg.user {
  align-self: flex-end;
  color: #14336c;
  background: linear-gradient(135deg, rgba(230,246,255,0.92), rgba(239,234,255,0.86));
  border-color: rgba(121, 168, 255, 0.28);
  border-bottom-right-radius: 5px;
  max-width: min(640px, 86%);
}

.msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.84);
  border-bottom-left-radius: 5px;
}

.side-chat .msg {
  max-width: 100%;
  width: fit-content;
}

.side-chat .msg.user {
  max-width: 86%;
}

.msg-content {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #132746;
  font-size: 16px;
}

.msg-content p {
  margin: 0 0 8px;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content h1,
.msg-content h2,
.msg-content h3 {
  margin: 16px 0 8px;
  color: #142f61;
  line-height: 1.35;
  font-weight: 950;
}

.msg-content h1:first-child,
.msg-content h2:first-child,
.msg-content h3:first-child {
  margin-top: 0;
}

.msg-content h1 { font-size: 22px; }
.msg-content h2 { font-size: 20px; }
.msg-content h3 { font-size: 18px; }

.msg-content strong {
  color: #173cc0;
  font-weight: 950;
  background: linear-gradient(transparent 62%, rgba(91, 142, 255, 0.18) 62%);
}

.msg-content ol,
.msg-content ul {
  margin: 10px 0 10px 1.35em;
  padding: 0;
}

.msg-content li {
  padding-left: 0.25em;
  margin: 7px 0;
}

.msg-content mjx-container,
.line mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 0;
}

.msg-content mjx-container[display="true"],
.line mjx-container[display="true"] {
  display: block;
  margin: 12px 0;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.chip {
  max-width: 100%;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border: 1px solid rgba(112, 143, 205, 0.20);
  border-radius: 999px;
  color: #3e598a;
  font-size: 13px;
  font-weight: 850;
  background: rgba(255,255,255,0.76);
}

.chip button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #5f739a;
  background: rgba(218, 228, 248, 0.9);
  font-weight: 950;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 20px;
  background: rgba(255,255,255,0.74);
  box-shadow: var(--glow);
  backdrop-filter: blur(18px);
}

.side-chat .composer {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.64) inset, 0 16px 36px rgba(77, 117, 218, 0.12);
}

.tones {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(120, 150, 210, 0.16);
  border-radius: 16px;
  background: rgba(244, 249, 255, 0.72);
}

.tone {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border-color: transparent;
  border-radius: 12px;
  background: transparent;
  color: #5d6f96;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: none;
}

.tone.active {
  color: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 110px;
  max-height: 260px;
  resize: vertical;
  padding: 14px;
  border: 1px solid rgba(122, 149, 205, 0.18);
  border-radius: 16px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
  line-height: 1.58;
}

.side-chat .composer textarea {
  min-height: 112px;
  max-height: 220px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attach-label {
  position: relative;
  overflow: hidden;
  min-height: 38px;
  color: #2c549f;
}

.attach-label::before {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 7px 0 0 -4px currentColor;
}

.attach-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.novel-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(125deg, #edf8ff, #fbfdff 46%, #edf1ff);
}

.novel-head {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(112, 143, 205, 0.18);
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(20px);
}

.novel-head h2 {
  margin: 0;
  color: #17315a;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 950;
}

.novel-body {
  min-height: 0;
  overflow: auto;
  padding: 24px max(22px, 9vw) 110px;
  scroll-behavior: auto;
}

.line {
  width: min(860px, 78%);
  margin: 0 0 18px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,0.74);
  border-radius: 20px;
  color: #142746;
  font-size: clamp(17px, 1.45vw, 21px);
  line-height: 1.72;
  background: rgba(255,255,255,0.76);
  box-shadow: var(--shadow-tiny);
  backdrop-filter: blur(18px);
}

.line.right {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(232,247,255,0.86), rgba(240,235,255,0.82));
  border-color: rgba(124, 165, 255, 0.28);
}

.line > strong {
  display: block;
  margin-bottom: 10px;
  color: #315cbb;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 950;
}

.line p {
  margin: 0 0 10px;
}

.line p:last-child {
  margin-bottom: 0;
}

.line div strong {
  display: inline;
  margin: 0;
  color: #173cc0;
  font-size: inherit;
  line-height: inherit;
  font-weight: 950;
  background: linear-gradient(transparent 62%, rgba(91, 142, 255, 0.18) 62%);
}

.line > div {
  overflow-wrap: anywhere;
}

.line mjx-container {
  font-size: 0.96em;
}

.story-diagram {
  margin: 16px 0 0;
  padding: 10px;
  border: 1px solid rgba(121, 168, 255, 0.22);
  border-radius: 16px;
  background: rgba(255,255,255,0.66);
}

.story-diagram svg {
  width: min(100%, 520px);
  height: auto;
  display: block;
  margin: 0 auto;
}

.story-diagram rect {
  fill: rgba(247, 251, 255, 0.96);
  stroke: rgba(116, 143, 205, 0.25);
}

.story-diagram .main {
  fill: none;
  stroke: #163157;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.story-diagram .aux {
  fill: none;
  stroke: #76a4d8;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 6 5;
}

.story-diagram .guide {
  stroke: #8d8bdc;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.story-diagram .target {
  stroke: #4d7dff;
  stroke-width: 3.2;
  stroke-linecap: round;
}

.story-diagram .mark {
  fill: none;
  stroke: #915bf4;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.story-diagram .shade {
  fill: rgba(83, 128, 255, 0.08);
  stroke: none;
}

.story-diagram .shade.small {
  fill: rgba(145, 91, 244, 0.10);
}

.story-diagram .dot {
  fill: #315cbb;
  stroke: #fff;
  stroke-width: 2;
}

.story-diagram text {
  fill: #1b355b;
  font: 750 16px "Segoe UI", Arial, sans-serif;
}

.story-diagram .note {
  fill: #4f70a4;
  font-size: 13px;
}

.novel-controls {
  position: fixed;
  right: 28px;
  bottom: 24px;
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.74);
  border-radius: 18px;
  background: rgba(255,255,255,0.76);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

@media (max-width: 1180px) {
  .lesson-view {
    grid-template-columns: minmax(320px, 1fr) 10px minmax(300px, var(--chat-width, 380px));
  }

  .tones {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  :root {
    --sidebar-width: 100%;
    --topbar-height: 58px;
  }

  html,
  body,
  #app {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .shell {
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    display: block;
    overflow: hidden;
    padding: 8px;
  }

  .shell > * {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    top: 10px;
    left: 10px;
    width: min(86vw, 340px);
    max-width: calc(100vw - 20px);
    min-width: 0;
    height: calc(100dvh - 20px);
    max-height: none;
    flex: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 16px 13px;
    border-radius: 20px;
    transform: translateX(calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    border: 0;
    background: rgba(22, 38, 68, 0.26);
    backdrop-filter: blur(4px);
  }

  .mobile-sidebar-backdrop.open {
    display: block;
  }

  .brand {
    min-width: 0;
    margin-bottom: 12px;
  }

  .mark {
    width: 40px;
    height: 40px;
  }

  .brand h1 {
    overflow-wrap: anywhere;
    font-size: 16px;
  }

  .home-link {
    min-height: 44px;
    margin-bottom: 12px;
  }

  .home-history {
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .home-history-head {
    min-width: 0;
    gap: 8px;
  }

  .home-history-head button {
    flex: 0 0 auto;
  }

  .home-thread-row {
    min-width: 0;
  }

  .home-thread-list {
    max-height: 110px;
  }

  .lesson-list {
    max-height: none;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    min-height: 58vh;
    overflow: hidden;
    border-radius: 20px;
  }

  .topbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 8;
    min-height: 54px;
    padding: 8px 10px;
    align-items: flex-start;
    border-radius: 20px 20px 0 0;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    min-height: 34px;
    padding: 0 11px;
    flex: 0 0 auto;
  }

  .topbar > * {
    min-width: 0;
  }

  .topbar h2 {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .top-actions {
    min-width: 0;
    max-width: 100%;
    gap: 7px;
  }

  .top-actions .ghost,
  .top-actions .link-button {
    min-height: 34px;
    padding: 0 10px;
  }

  .home-chat {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    min-height: calc(100dvh - 68px);
    gap: 8px;
    padding: 8px;
  }

  .home-messages,
  .home-copy,
  .home-composer {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .home-empty {
    width: 100%;
    max-width: 100%;
    min-height: 150px;
    padding: 16px 12px;
    border-radius: 22px;
  }

  .home-empty h3 {
    max-width: 100%;
    font-size: clamp(22px, 7vw, 30px);
    line-height: 1.16;
    overflow-wrap: anywhere;
  }

  .home-empty p {
    font-size: 12px;
    line-height: 1.55;
  }

  .hero-kicker {
    font-size: 13px;
  }

  .lesson-view {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: transparent;
  }

  .lesson-view > * {
    min-width: 0;
  }

  .mobile-lesson-tabs {
    position: sticky;
    top: var(--topbar-height);
    z-index: 7;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(120, 150, 210, 0.16);
    background: rgba(246, 250, 255, 0.88);
    backdrop-filter: blur(18px);
  }

  .mobile-lesson-tabs button {
    min-height: 38px;
    border: 1px solid rgba(100, 137, 220, 0.20);
    border-radius: 13px;
    color: #244fbd;
    background: rgba(255,255,255,0.78);
    font-weight: 950;
    box-shadow: 0 8px 18px rgba(80, 124, 205, 0.09);
  }

  .pdf-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 56vh;
    min-height: 360px;
    padding: 10px;
    scroll-margin-top: 112px;
    border-bottom: 12px solid rgba(125, 162, 226, 0.16);
    background: rgba(234, 243, 255, 0.52);
  }

  .pdf-head {
    padding: 0 0 10px;
  }

  .pdf-head h3 {
    white-space: normal;
    font-size: 16px;
  }

  .pdf-frame {
    height: 100%;
    min-height: 0;
    border-radius: 16px;
  }

  .pdf-pages {
    gap: 12px;
    padding: 10px;
  }

  .pdf-page {
    gap: 6px;
  }

  .pdf-page img {
    border-radius: 8px;
  }

  .divider {
    display: none;
  }

  .side-chat {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(260px, 1fr) auto;
    align-content: start;
    min-height: 72vh;
    padding: 12px;
    scroll-margin-top: 112px;
    border-top: 1px solid rgba(120, 150, 210, 0.18);
    background: rgba(246, 250, 255, 0.78);
  }

  .messages {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 260px;
    max-height: 58vh;
    padding: 4px 0 12px;
    scroll-padding-bottom: 180px;
  }

  .msg {
    max-width: 100%;
    padding: 14px;
  }

  .msg-content {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .composer {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    position: sticky;
    bottom: 8px;
    z-index: 6;
    gap: 7px;
    padding: 8px;
    border-radius: 16px;
  }

  .composer textarea,
  .side-chat .composer textarea {
    min-height: 58px;
    max-height: 126px;
    padding: 9px 10px;
    border-radius: 13px;
    font-size: 15px;
  }

  .tones {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding: 4px;
    scrollbar-width: none;
  }

  .tones::-webkit-scrollbar {
    display: none;
  }

  .tone {
    min-height: 30px;
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .composer-actions {
    width: 100%;
    min-width: 0;
    align-items: stretch;
    gap: 8px;
  }

  .attach-label,
  .composer-actions .primary,
  .composer-actions .stop-button,
  .composer-actions .ghost {
    min-height: 34px;
    border-radius: 12px;
    font-size: 14px;
  }

  .novel-head {
    min-height: 64px;
    padding: 12px;
    align-items: flex-start;
  }

  .novel-head h2 {
    font-size: 20px;
  }

  .novel-body {
    scroll-behavior: auto;
    padding: 16px 12px 94px;
  }

  .line {
    width: 92%;
    padding: 14px;
    font-size: 17px;
  }

  .novel-controls {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: flex-end;
  }
}

@media (max-width: 520px) {
  .login-page {
    padding: 16px;
  }

  .login-box {
    padding: 24px;
  }

  .sidebar {
    width: min(90vw, 330px);
    height: calc(100dvh - 16px);
    top: 8px;
    left: 8px;
  }

  .lesson-list {
    max-height: none;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 7px;
    min-height: 50px;
    padding: 7px 8px;
  }

  .mobile-menu-toggle,
  .top-actions .ghost,
  .top-actions .link-button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 13px;
    border-radius: 12px;
  }

  .topbar h2 {
    font-size: 15px;
    -webkit-line-clamp: 1;
  }

  .top-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    overflow-x: hidden;
    flex-wrap: wrap;
    padding-bottom: 2px;
  }

  .top-actions .ghost,
  .top-actions .link-button {
    flex: 0 0 auto;
  }

  .home-empty {
    min-height: 124px;
    padding: 13px 10px;
    border-radius: 20px;
  }

  .home-empty h3 {
    font-size: clamp(21px, 6.8vw, 27px);
  }

  .home-empty p {
    font-size: 12px;
  }

  .tones {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pdf-head {
    flex-direction: column;
  }

  .home-chat {
    gap: 7px;
    padding: 8px;
    min-height: calc(100dvh - 58px);
  }

  .msg-content {
    font-size: 14px;
  }

  .msg {
    padding: 12px;
    border-radius: 15px;
    line-height: 1.62;
  }

  .composer {
    gap: 6px;
    padding: 7px;
  }

  .composer textarea,
  .side-chat .composer textarea {
    min-height: 52px;
    max-height: 112px;
    padding: 8px 9px;
    font-size: 14px;
  }

  .tone {
    min-height: 28px;
    font-size: 12px;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .attach-label,
  .composer-actions .primary,
  .composer-actions .stop-button,
  .composer-actions .ghost {
    min-height: 32px;
    font-size: 13px;
  }

  .feedback-overlay {
    padding: 10px;
    align-items: end;
  }

  .feedback-card {
    padding: 16px;
    border-radius: 20px;
  }

  .feedback-head h2 {
    font-size: 22px;
  }

  .feedback-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .teacher-page {
    padding: 10px;
  }

  .teacher-head {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    border-radius: 20px;
  }

  .teacher-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mobile-lesson-tabs {
    top: 104px;
    padding: 8px 10px;
  }

  .pdf-wrap {
    height: 52vh;
    min-height: 320px;
    padding: 8px;
    scroll-margin-top: 154px;
  }

  .side-chat {
    min-height: 76vh;
    padding: 10px;
    scroll-margin-top: 154px;
  }

  .messages {
    max-height: 60vh;
  }

  .novel-head {
    flex-direction: column;
  }

  .novel-head .top-actions {
    width: 100%;
  }

  .line,
  .line.right {
    width: 100%;
  }
}

@media (max-width: 860px) {
  .lesson-main {
    min-height: calc(100dvh - 16px);
    background:
      linear-gradient(180deg, rgba(255,255,255,0.88), rgba(244,249,255,0.76)),
      radial-gradient(circle at 18% 0%, rgba(95, 160, 255, 0.16), transparent 34%);
  }

  .lesson-main .lesson-topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px 10px;
    min-height: auto;
    padding: 9px 10px 10px;
    border-radius: 20px 20px 0 0;
    background: rgba(255,255,255,0.78);
    box-shadow: 0 10px 26px rgba(82, 117, 185, 0.08);
  }

  .lesson-main .lesson-topbar h2 {
    grid-column: 2;
    margin: 0;
    font-size: 15px;
    line-height: 1.22;
    white-space: nowrap;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .lesson-main .lesson-topbar .mobile-menu-toggle {
    grid-column: 1;
    grid-row: 1;
    width: auto;
  }

  .lesson-main .lesson-topbar .top-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 0;
    overflow: visible;
  }

  .lesson-main .lesson-topbar .top-actions .ghost,
  .lesson-main .lesson-topbar .top-actions .link-button {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    justify-content: center;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 8px 18px rgba(80, 124, 205, 0.08);
  }

  .lesson-main .lesson-view {
    background: linear-gradient(180deg, rgba(237,246,255,0.56), rgba(250,252,255,0.88));
  }

  .lesson-main .mobile-lesson-tabs {
    position: relative;
    top: auto;
    z-index: 7;
    gap: 7px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(120, 150, 210, 0.13);
    background: rgba(250, 253, 255, 0.88);
    backdrop-filter: blur(18px);
  }

  .lesson-main .mobile-lesson-tabs button {
    min-height: 34px;
    border-radius: 999px;
    font-size: 13px;
    color: #2750bf;
    background: rgba(255,255,255,0.84);
    box-shadow: 0 8px 18px rgba(68, 104, 178, 0.08);
  }

  .lesson-main .pdf-wrap {
    height: min(64dvh, 620px);
    min-height: 410px;
    padding: 9px 10px 12px;
    border-bottom: 8px solid rgba(123, 160, 226, 0.13);
    background:
      linear-gradient(180deg, rgba(235,244,255,0.50), rgba(248,251,255,0.90));
    scroll-margin-top: 118px;
  }

  .lesson-main .pdf-frame {
    height: 100%;
    border-radius: 16px;
    border-color: rgba(119, 153, 220, 0.18);
    background: #fff;
    box-shadow: 0 16px 34px rgba(52, 89, 153, 0.12);
  }

  .lesson-main .pdf-pages {
    align-content: start;
    gap: 10px;
    padding: 8px;
  }

  .lesson-main .pdf-page {
    width: 100%;
    gap: 5px;
  }

  .lesson-main .pdf-page img {
    border-radius: 8px;
    box-shadow: 0 10px 22px rgba(42, 79, 145, 0.10);
  }

  .lesson-main .pdf-page figcaption {
    font-size: 11px;
  }

  .lesson-main .side-chat {
    min-height: calc(100dvh - 72px);
    padding: 10px;
    border-top: 8px solid rgba(123, 160, 226, 0.13);
    background:
      linear-gradient(180deg, rgba(250,253,255,0.92), rgba(239,247,255,0.72));
    scroll-margin-top: 118px;
  }

  .lesson-main .side-chat .messages {
    max-height: 56dvh;
  }
}

@media (max-width: 520px) {
  .lesson-main {
    min-height: calc(100dvh - 10px);
    border-radius: 18px;
  }

  .lesson-main .lesson-topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px;
    padding: 8px;
    border-radius: 18px 18px 0 0;
  }

  .lesson-main .lesson-topbar h2 {
    font-size: 14px;
  }

  .lesson-main .lesson-topbar .mobile-menu-toggle {
    min-height: 32px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 13px;
  }

  .lesson-main .lesson-topbar .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .lesson-main .lesson-topbar .top-actions .ghost,
  .lesson-main .lesson-topbar .top-actions .link-button {
    min-height: 31px;
    padding: 0 8px;
    font-size: 12px;
  }

  .lesson-main .mobile-lesson-tabs {
    position: relative;
    top: auto;
    padding: 7px 8px;
  }

  .lesson-main .mobile-lesson-tabs button {
    min-height: 32px;
    font-size: 13px;
  }

  .lesson-main .pdf-wrap {
    height: 58dvh;
    min-height: 390px;
    padding: 8px;
    scroll-margin-top: 150px;
  }

  .lesson-main .pdf-frame {
    border-radius: 14px;
  }

  .lesson-main .pdf-pages {
    padding: 6px;
    gap: 8px;
  }

  .lesson-main .pdf-page img {
    border-radius: 6px;
  }

  .lesson-main .side-chat {
    min-height: calc(100dvh - 54px);
    padding: 8px;
    scroll-margin-top: 150px;
  }

  .lesson-main .side-chat .messages {
    max-height: 58dvh;
  }
}

.reading-note { color: #697386; font-size: 12px; line-height: 1.6; padding: 5px 0; overflow-wrap: anywhere; }
.attachments .chip { max-width: 100%; flex-wrap: wrap; overflow-wrap: anywhere; }
.attachments .chip small { flex-basis: 100%; }
.pdf-start { width: 58px; min-width: 0; border: 1px solid #ccd3df; border-radius: 5px; padding: 3px; }
.pdf-page figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.pdf-page figcaption button { font-size: 12px; }

.lesson-group { display: flex; justify-content: space-between; gap: 8px; padding: 16px 10px 7px; font-weight: 700; color: #314766; font-size: 13px; }
.lesson-group span { font-size: 11px; font-weight: 400; color: #6a7890; }

.answer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 5px; margin-top: 5px; color: #70809c; font-size: 12px; line-height: 1.4; }
.answer-actions button, .answer-export summary { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 30px; padding: 4px 7px; border: 0; border-radius: 6px; background: transparent; color: #657797; font: inherit; cursor: pointer; box-shadow: none; }
.answer-actions button:hover, .answer-export summary:hover { background: #edf2fc; color: #3456b5; }
.answer-actions button:focus-visible, .answer-export summary:focus-visible { outline: 2px solid #567bed; outline-offset: 1px; }
.answer-actions button:disabled { opacity: .5; cursor: wait; }
.answer-export { position: relative; }
.answer-export summary { list-style: none; }
.answer-export summary::-webkit-details-marker { display: none; }
.answer-export-options { position: absolute; z-index: 6; left: 0; bottom: calc(100% + 4px); width: 138px; padding: 5px; border: 1px solid #dfe6f2; border-radius: 10px; background: #fff; box-shadow: 0 6px 22px #273b6521; }
.answer-export-options button { width: 100%; min-height: 36px; justify-content: flex-start; padding: 7px 10px; color: #24385d; font-size: 13px; }
.answer-action-status { padding-left: 3px; font-size: 11px; overflow-wrap: anywhere; }
.copy-answer-dialog { width: min(600px, 90vw); border: 1px solid #dfe6f2; border-radius: 14px; color: #24385d; padding: 16px; }
.copy-answer-dialog::backdrop { background: #192a4c66; }
.copy-answer-dialog form { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.copy-answer-dialog form button { background: transparent; border: 0; font-size: 24px; padding: 4px 12px; cursor: pointer; }
.copy-answer-dialog textarea { width: 100%; height: 50dvh; padding: 12px; border: 1px solid #dfe6f2; border-radius: 8px; font: inherit; resize: vertical; }
@media (max-width: 860px) {
  .answer-actions button, .answer-export summary { min-height: 36px; padding: 5px 8px; }
  .answer-export-options button { min-height: 40px; }
}
