:root {
  --bg: #ffffff;
  --panel: #f3f4f6;
  --panel-strong: #eceef1;
  --text: #101314;
  --muted: #6d747b;
  --line: #dee2e6;
  --black: #080c0d;
  --green-bg: #ecfbf2;
  --green: #26724a;
  --green-line: #bee9cf;
  --lilac-bg: #fbf5ff;
  --lilac: #7f568e;
  --lilac-line: #ead8f3;
  --blue-dot: #27366f;
  --orange-dot: #c65e38;
  --shadow: 0 16px 36px rgba(15, 20, 25, 0.08);
  --header-h: 92px;
  --composer-h: 96px;
  --desktop-sidebar-width: 0px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  position: relative;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  transition: width 180ms ease, margin-left 180ms ease;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  height: var(--header-h);
  padding: 24px 22px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(229, 232, 235, 0.8);
  backdrop-filter: blur(12px);
}

.top-bar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--text);
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button.bare {
  background: transparent;
}

.icon-button.soft {
  background: #dfe3e7;
}

.icon-button.light {
  background: #ffffff;
  box-shadow: 0 1px 8px rgba(18, 24, 31, 0.08);
}

#voiceButton {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.icon-button.recording {
  color: #ffffff;
  background: #b91c1c;
  box-shadow: 0 0 0 6px rgba(185, 28, 28, 0.12);
}

.icon-button.primary {
  color: #ffffff;
  background: var(--black);
}

.icon-button.primary:disabled {
  color: #8c949c;
  background: #d7dce1;
  cursor: default;
  transform: none;
}

.view {
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.view::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.robot-player {
  position: absolute;
  top: 24px;
  left: 22px;
  right: 22px;
  z-index: 6;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(15, 20, 25, 0.12);
  backdrop-filter: blur(14px);
}

.robot-player-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--black);
}

.robot-player-visual span {
  width: 3px;
  height: 14px;
  border-radius: 999px;
  background: #ffffff;
  animation: robot-playing-bar 1s ease-in-out infinite;
}

.robot-player-visual span:nth-child(2) {
  animation-delay: 0.14s;
}

.robot-player-visual span:nth-child(3) {
  animation-delay: 0.28s;
}

.robot-player-copy {
  min-width: 0;
}

.robot-player-copy p,
.robot-player-copy h2 {
  margin: 0;
}

.robot-player-copy p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.robot-player-copy h2 {
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.robot-stop-button {
  min-height: 44px;
  padding-inline: 16px;
}

.app-shell.robot-playing .chat-view {
  padding-top: calc(24px + 86px);
}

@keyframes robot-playing-bar {
  0%,
  100% {
    height: 10px;
    opacity: 0.6;
  }

  45% {
    height: 22px;
    opacity: 1;
  }
}

.chat-view {
  padding: 24px 22px calc(var(--composer-h) + 28px);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

.chat-log.is-empty {
  align-items: center;
  justify-content: center;
  padding-bottom: 130px;
}

.task-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: min(100%, 760px);
  text-align: left;
}

.task-welcome img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.task-welcome h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.message {
  max-width: min(86%, 720px);
  padding: 18px 20px;
  border-radius: 22px;
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.55;
}

.message.bot {
  position: relative;
  max-width: min(calc(100% - 56px), 720px);
  margin-left: 56px;
  align-self: flex-start;
  background: var(--panel);
}

.message.bot::before,
.chat-log .lesson-card::before {
  position: absolute;
  top: 4px;
  left: -56px;
  width: 42px;
  height: 42px;
  background: url("pic/Casper.png") center / contain no-repeat;
  content: "";
}

.thinking-message {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: none;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

.generation-error-message {
  background: #fff1f1;
}

.generation-error-message .error-detail {
  margin-top: 8px;
  color: #8a1f1f;
  font-size: 15px;
  line-height: 1.4;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-top: 8px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: thinking-dot 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes thinking-dot {
  0%,
  70%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }

  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.message.user {
  position: relative;
  align-self: flex-end;
  color: #ffffff;
  background: var(--black);
}

.message.user.has-attachments {
  display: grid;
  gap: 12px;
  max-width: min(86%, 660px);
  padding: 12px;
}

.message p {
  margin: 0;
}

.message-edit-button {
  position: absolute;
  right: 0;
  bottom: -44px;
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(8, 12, 13, 0.76);
  box-shadow: 0 2px 10px rgba(15, 20, 25, 0.12);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.message.user:hover .message-edit-button,
.message-edit-button:focus-visible {
  opacity: 1;
}

.message-edit-button:hover {
  transform: translateY(-1px);
}

.message.user.editing {
  display: grid;
  gap: 12px;
  width: min(86%, 760px);
  max-width: 760px;
  padding: 18px;
  color: #ffffff;
  background: #2f3030;
}

.inline-message-editor {
  display: grid;
  gap: 14px;
}

.inline-message-editor textarea {
  width: 100%;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: 0;
  color: #ffffff;
  background: transparent;
  font-size: 20px;
  line-height: 1.45;
}

.inline-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.inline-edit-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 760;
}

.inline-edit-button.cancel {
  color: #ffffff;
  background: #050707;
}

.inline-edit-button.send {
  color: var(--text);
  background: #ffffff;
}

.sent-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.sent-attachment {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.sent-attachment img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #ffffff;
}

.sent-attachment img[data-open-image-src] {
  cursor: zoom-in;
}

.sent-attachment figcaption {
  overflow: hidden;
  padding: 8px 10px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sent-file {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
}

.sent-file-icon,
.attachment-file-icon {
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--text);
  background: var(--panel);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.02em;
}

.sent-file-icon {
  width: 54px;
  height: 54px;
}

.sent-file-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-message-text {
  padding: 0 6px 2px;
}

.sent-voice-message {
  display: grid;
  gap: 8px;
  min-width: min(320px, 68vw);
  padding: 12px;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
}

.sent-voice-message span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.sent-voice-message audio {
  width: 100%;
}

.lesson-card {
  width: 100%;
  max-width: 650px;
  align-self: flex-start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.chat-log .lesson-card {
  position: relative;
  max-width: min(calc(100% - 56px), 720px);
  margin-left: 56px;
  align-self: flex-start;
  overflow: visible;
  border: 0;
  border-radius: 22px;
  color: var(--text);
  background: var(--panel);
  box-shadow: none;
}

.lesson-card.completed {
  background: var(--lilac-bg);
  border-color: var(--lilac-line);
}

.lesson-top {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  padding: 18px 18px 14px;
}

.lesson-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.lesson-title-block h2,
.archive-card h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.lesson-meta,
.archive-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 18px 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--green-line);
  color: var(--green);
  background: var(--green-bg);
  font-size: 15px;
  font-weight: 650;
}

.status-pill.sent {
  color: #334c84;
  background: #eef4ff;
  border-color: #d7e4ff;
}

.status-pill.completed {
  color: var(--lilac);
  background: var(--lilac-bg);
  border-color: var(--lilac-line);
}

.lesson-body {
  border-top: 0;
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.55;
}

.lesson-body h3 {
  margin: 0 0 10px;
  font-size: inherit;
  font-weight: 650;
  line-height: inherit;
}

.lesson-body p {
  margin: 0 0 18px;
}

.lesson-body ol {
  margin: 0 0 18px 22px;
  padding: 0;
}

.lesson-body li {
  margin: 0 0 8px;
}

.lesson-body strong {
  font-weight: 700;
}

.support-selector {
  display: grid;
  gap: 10px;
  margin: 4px 0 18px;
}

.support-selector p {
  margin: 0;
  color: var(--text);
  font-size: inherit;
  font-weight: 400;
  line-height: inherit;
}

.support-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.support-option {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #ffffff;
  font-size: 14px;
  font-weight: 760;
}

.support-option:hover,
.support-option.active {
  color: var(--text);
  background: #ffffff;
  border-color: var(--black);
}

.support-option:disabled {
  cursor: default;
}

.support-option:disabled:not(.active) {
  color: var(--text);
  background: #ffffff;
}

.message.bot .support-selector {
  margin: 0;
}

.message.bot .support-selector p {
  color: inherit;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.followup-copy {
  margin-top: 20px;
  color: var(--text);
}

.followup-suggestions {
  display: grid;
  gap: 4px;
  margin: 6px 0 0 20px;
  padding: 0;
}

.followup-suggestions li {
  margin: 0;
}

.robot-says {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.lesson-actions,
.archive-actions {
  display: grid;
  gap: 10px;
  padding: 0 20px 20px;
  border-top: 0;
}

.robot-prompt-panel {
  margin: 0 20px 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.robot-prompt-panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.2;
  text-transform: lowercase;
}

.robot-prompt-panel pre {
  overflow: auto;
  max-height: 360px;
  margin: 0;
  color: var(--text);
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

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

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  gap: 10px;
  border-radius: 8px;
  font-weight: 760;
}

.text-button.dark {
  color: #ffffff;
  background: var(--black);
}

.text-button.dark:disabled,
.text-button.dark.inactive {
  color: #69717a;
  background: #e8ebef;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.text-button.subtle {
  color: var(--text);
  background: var(--panel);
}

.text-button.danger {
  color: #ffffff;
  background: #b91c1c;
}

.composer {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  grid-template-columns: 48px 1fr 48px 48px;
  align-items: end;
  width: min(calc(100vw - 32px), 728px);
  min-height: 76px;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dce1e6;
  border-radius: 34px;
  background: #edf0f3;
  box-shadow: 0 12px 30px rgba(18, 24, 31, 0.12);
  transform: translateX(-50%);
}

.app-shell.empty-chat .composer {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.attachment-strip {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 0 2px 2px;
  scrollbar-width: none;
}

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

.attachment-chip {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 46px minmax(82px, 150px) 36px;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 4px 8px 4px 4px;
  border: 1px solid #d8dde3;
  border-radius: 8px;
  background: #ffffff;
}

.attachment-chip img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
}

.attachment-file-icon {
  width: 46px;
  height: 46px;
}

.attachment-preview-button {
  display: block;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.attachment-chip > span:not(.attachment-file-icon):not(.audio-chip-icon) {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-chip {
  grid-template-columns: 46px minmax(82px, 150px) 36px;
}

.audio-chip-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 6px;
  color: var(--text);
  background: var(--panel);
}

.remove-attachment {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
}

.remove-attachment svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 12, 13, 0.82);
}

.image-preview-modal figure {
  display: grid;
  gap: 10px;
  max-width: min(94vw, 920px);
  max-height: 88dvh;
  margin: 0;
}

.image-preview-modal img {
  max-width: 100%;
  max-height: 80dvh;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
}

.image-preview-modal figcaption {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-close {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--text);
  background: #ffffff;
}

.composer textarea {
  width: 100%;
  max-height: 132px;
  min-height: 48px;
  padding: 13px 6px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 18px;
  line-height: 1.25;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.composer textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.composer textarea::placeholder {
  color: #8a9299;
}

.archive-view {
  padding: 22px 22px 34px;
}

.archive-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 14px;
  background: linear-gradient(#ffffff 78%, rgba(255, 255, 255, 0));
}

.search-box {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--panel);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 18px;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #ffffff;
  font-size: 16px;
  font-weight: 760;
}

.filter-chip.active {
  color: #ffffff;
  background: var(--black);
  border-color: var(--black);
}

.archive-content {
  display: grid;
  gap: 22px;
}

.archive-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.archive-section-head .head-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.archive-list {
  display: grid;
  gap: 14px;
}

.archive-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 20, 25, 0.06);
}

.archive-card.completed {
  background: var(--lilac-bg);
  border-color: var(--lilac-line);
}

.archive-card-main {
  min-width: 0;
}

.archive-card .status-row {
  padding: 12px 0 0;
}

.archive-actions {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, 48px);
  justify-content: start;
  gap: 10px;
  padding: 6px 0 0;
  border: 0;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
}

.mini-button:disabled,
.mini-button.inactive {
  color: #7b838c;
  background: #e8ebef;
  cursor: not-allowed;
  opacity: 1;
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(16, 19, 20, 0.32);
}

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 9;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(86vw, 420px);
  padding: 28px 24px;
  background: #ffffff;
  box-shadow: 18px 0 36px rgba(15, 20, 25, 0.14);
  overflow: hidden;
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

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

.drawer-logo {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.drawer-brand-text {
  min-width: 0;
}

.drawer-head h2 {
  margin: 0;
  font-size: 26px;
}

.drawer-head p,
.drawer-note {
  color: var(--muted);
  line-height: 1.45;
}

.drawer-head p {
  margin: 8px 0 0;
}

.drawer-task-tools {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: stretch;
  gap: 12px;
  min-height: 0;
  margin-top: 34px;
}

.drawer-link {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-size: 18px;
  font-weight: 760;
}

.drawer-label,
.drawer-title,
.drawer-subtitle,
.drawer-note {
  transition: opacity 140ms ease;
}

.drawer-label {
  white-space: nowrap;
}

.drawer-link.active {
  background: var(--panel);
}

.drawer-search {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
}

.drawer-search:hover,
.drawer-search:focus-within {
  background: var(--panel);
}

.drawer-search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
}

.drawer-search input::placeholder {
  color: var(--text);
  opacity: 1;
}

.recent-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  padding-top: 12px;
  border-top: 1px solid rgba(222, 226, 230, 0.8);
}

.recent-section h3 {
  margin: 0 0 4px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.recent-list {
  display: grid;
  align-content: start;
  gap: 1px;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 0;
  scrollbar-width: none;
}

.recent-list::-webkit-scrollbar {
  display: none;
}

.recent-task-row {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: 8px;
}

.recent-task {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  padding: 7px 48px 7px 10px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  overflow: hidden;
  text-align: left;
}

.recent-task-row:hover .recent-task,
.recent-task-row:focus-within .recent-task,
.recent-task.active {
  background: var(--panel);
}

.recent-menu-button {
  position: absolute;
  top: 50%;
  right: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.recent-task-row:hover .recent-menu-button,
.recent-task-row:focus-within .recent-menu-button,
.recent-task-row.menu-open .recent-menu-button {
  opacity: 1;
  pointer-events: auto;
}

.recent-menu-button:hover,
.recent-task-row.menu-open .recent-menu-button {
  color: var(--text);
}

.recent-menu-dots {
  display: inline-grid;
  grid-template-columns: repeat(3, 5px);
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.recent-menu-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.recent-task-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 12;
  display: grid;
  min-width: 128px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 20, 25, 0.16);
}

.recent-task-menu button {
  width: 100%;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}

.recent-task-menu button:hover,
.recent-task-menu button:focus-visible {
  background: var(--panel);
}

.recent-task-menu button.danger {
  color: #d12b2b;
}

.recent-task-row.renaming {
  background: var(--panel);
}

.recent-rename-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px;
}

.recent-rename-form input {
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #d8dde3;
  border-radius: 6px;
  outline: 0;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
}

.recent-rename-form input:focus {
  border-color: var(--black);
}

.recent-rename-save,
.recent-rename-cancel {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.recent-rename-save {
  color: #ffffff;
  background: var(--black);
}

@media (hover: none) {
  .recent-menu-button {
    opacity: 1;
    pointer-events: auto;
  }
}

.recent-task span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-task span {
  font-size: 15px;
  font-weight: 450;
  line-height: 1.35;
}

.recent-empty {
  color: var(--muted);
  font-size: 13px;
}

.recent-empty {
  margin: 0;
  padding: 8px 10px;
}

.drawer-note {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.edit-dialog,
.confirm-dialog {
  width: min(calc(100vw - 28px), 620px);
  max-height: min(88dvh, 820px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.edit-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(16, 19, 20, 0.38);
}

.edit-dialog form {
  display: grid;
  gap: 16px;
  max-height: min(88dvh, 820px);
  overflow-y: auto;
  padding: 22px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
}

.dialog-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.edit-dialog label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.edit-dialog input,
.edit-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: 0;
  color: var(--text);
  background: #ffffff;
  font-size: 16px;
  line-height: 1.35;
}

.edit-dialog input:focus,
.edit-dialog textarea:focus,
.search-box:focus-within {
  border-color: #abb4bd;
  box-shadow: 0 0 0 4px rgba(72, 84, 96, 0.08);
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-actions .text-button {
  min-width: 140px;
}

.confirm-dialog {
  width: min(calc(100vw - 28px), 440px);
}

.confirm-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: #b91c1c;
  background: #fee2e2;
}

.confirm-panel h2 {
  margin: 0;
  font-size: 24px;
}

.confirm-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 118px;
  z-index: 12;
  max-width: min(calc(100vw - 32px), 440px);
  padding: 13px 16px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(8, 12, 13, 0.94);
  box-shadow: 0 12px 28px rgba(15, 20, 25, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

[hidden] {
  display: none !important;
}

@media (min-width: 860px) {
  body {
    --desktop-sidebar-width: 320px;
    background: #ffffff;
  }

  body.sidebar-collapsed {
    --desktop-sidebar-width: 76px;
  }

  .app-shell {
    width: calc(100vw - var(--desktop-sidebar-width));
    max-width: none;
    margin-left: var(--desktop-sidebar-width);
    border-inline: 0;
    box-shadow: none;
  }

  .top-bar {
    display: none;
  }

  .view {
    height: 100dvh;
  }

  .chat-view {
    padding-inline: clamp(28px, 4vw, 72px);
  }

  .robot-player {
    top: 24px;
    left: clamp(28px, 4vw, 72px);
    right: clamp(28px, 4vw, 72px);
  }

  .chat-log {
    width: min(100%, 920px);
  }

  .composer {
    left: calc((100vw + var(--desktop-sidebar-width)) / 2);
    width: min(920px, calc(100vw - var(--desktop-sidebar-width) - 96px));
  }

  .drawer-overlay {
    display: none !important;
  }

  .drawer {
    z-index: 7;
    width: var(--desktop-sidebar-width);
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    box-shadow: none;
    transform: none;
    transition: width 180ms ease, padding 180ms ease;
  }

  .drawer-head {
    align-items: center;
    min-height: 52px;
  }

  .drawer-task-tools {
    margin-top: 26px;
  }

  .drawer-link {
    min-height: 50px;
    font-size: 16px;
  }

  body.sidebar-collapsed .drawer {
    padding-inline: 12px;
  }

  body.sidebar-collapsed .drawer-head {
    justify-content: center;
  }

  body.sidebar-collapsed .drawer-head > div,
  body.sidebar-collapsed .drawer-label,
  body.sidebar-collapsed .drawer-search,
  body.sidebar-collapsed .recent-section,
  body.sidebar-collapsed .drawer-note {
    display: none;
  }

  body.sidebar-collapsed .drawer-link {
    grid-template-columns: 32px;
    justify-content: center;
    padding-inline: 10px;
  }

}

@media (max-width: 520px) {
  :root {
    --header-h: 44px;
    --composer-h: 96px;
  }

  .top-bar {
    grid-template-columns: 40px 1fr;
    padding: 2px 18px;
    border-bottom: 0;
    background: #ffffff;
    backdrop-filter: none;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .message {
    max-width: 92%;
    font-size: 18px;
  }

  .chat-log.is-empty {
    justify-content: center;
    padding-top: 0;
    padding-bottom: calc(var(--composer-h) + 112px);
  }

  .task-welcome {
    justify-content: center;
    width: min(100%, calc(100vw - 40px));
    margin-inline: auto;
    gap: 12px;
  }

  .task-welcome img {
    width: 48px;
    height: 48px;
  }

  .task-welcome h2 {
    max-width: 280px;
    font-size: 23px;
    line-height: 1.18;
    letter-spacing: 0;
  }

  .lesson-title-block h2,
  .archive-card h2 {
    font-size: 19px;
  }

  .composer {
    width: calc(100vw - 24px);
    grid-template-columns: 44px 1fr 44px 44px;
    gap: 8px;
  }

  .app-shell.empty-chat .composer {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
  }

  .archive-card {
    grid-template-columns: 56px 1fr;
    padding: 16px;
  }

  .archive-actions {
    grid-template-columns: repeat(4, 44px);
  }

  .mini-button {
    width: 44px;
    height: 44px;
  }

  .edit-grid,
  .action-row {
    grid-template-columns: 1fr;
  }
}
