:root {
      font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      color: #20232a;
      background: #f5f5f6;
      font-synthesis: none;
    }

    * { box-sizing: border-box; }
    html, body { margin: 0; min-width: 320px; min-height: 100%; }
    body { min-height: 100vh; min-height: 100dvh; overflow: hidden; background: #f5f5f6; font-size: 14px; }
    button, textarea, input { font: inherit; }
    button { color: inherit; }
    svg { display: block; }

    .app-shell { min-height: 100vh; min-height: 100dvh; display: flex; }

    .sidebar {
      position: relative;
      flex: 0 0 228px;
      width: 228px;
      height: 100vh;
      height: 100dvh;
      padding: 31px 12px 18px;
      background: #f6f6f7;
      border-right: 1px solid #efeff0;
      z-index: 5;
      transition: flex-basis .2s ease, width .2s ease;
    }

    .brand { display: flex; align-items: center; gap: 10px; min-height: 48px; padding-left: 10px; margin-bottom: 20px; }
    .brand-mark {
      display: none;
      width: 30px;
      height: 30px;
      flex: 0 0 30px;
      border: 2px solid transparent;
      border-radius: 50%;
      background: linear-gradient(#fff,#fff) padding-box,linear-gradient(135deg,#3370ff,#8b5cf6 55%,#58d6cf) border-box;
      box-shadow: 0 5px 14px rgba(51,112,255,.14);
    }
    .brand-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; line-height: 1.25; }
    .brand-title { color: #20232a; font-size: 13px; font-weight: 760; white-space: nowrap; }
    .brand-subtitle { color: #7b8089; font-size: 11px; font-weight: 650; white-space: nowrap; }

    .sidebar-label {
      margin: 0 0 9px;
      padding: 0 13px;
      color: #979ba3;
      font-size: 12px;
      font-weight: 600;
    }

    .nav-item svg, .history-item svg { width: 18px; height: 18px; flex: none; }
    .nav-list { display: grid; gap: 4px; }

    .nav-item, .history-item {
      width: 100%;
      height: 41px;
      padding: 0 13px;
      border: 0;
      border-radius: 20px;
      display: flex;
      align-items: center;
      gap: 12px;
      background: transparent;
      cursor: pointer;
      text-align: left;
      color: #30343b;
      text-decoration: none;
      transition: background .16s ease, color .16s ease;
    }

    .nav-item:hover, .history-item:hover { background: #ececee; }
    .nav-item.active { background: #e6e6e8; color: #111318; font-weight: 700; }

    .history-label { margin-top: 29px; }

    .history-list { display: grid; gap: 2px; }
    .history-item { height: 34px; font-size: 13px; }
    .history-item span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .history-item.current { background: #ededee; }

    .collapse-handle {
      position: absolute;
      top: calc(50% - 23px);
      right: -8px;
      width: 16px;
      height: 46px;
      padding: 0;
      border: 1px solid #ececee;
      border-radius: 9px;
      display: grid;
      place-items: center;
      background: rgba(255,255,255,.95);
      box-shadow: 0 3px 10px rgba(24,28,38,.05);
      cursor: pointer;
      z-index: 7;
    }

    .collapse-handle svg { width: 11px; height: 11px; transition: transform .2s ease; }

    .side-footer { position: absolute; left: 12px; right: 12px; bottom: 18px; }
    .bottom-actions { display: flex; align-items: center; gap: 8px; }

    .new-chat-bottom {
      flex: 1;
      height: 42px;
      padding: 0 17px;
      border: 0;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 9px;
      background: #3370ff;
      color: #fff;
      cursor: pointer;
      font-weight: 650;
      box-shadow: 0 6px 14px rgba(51,112,255,.18);
    }

    .new-chat-bottom:hover { background: #245bdb; }
    .new-chat-bottom svg, .settings-trigger svg, .recent-chat-trigger svg { width: 17px; height: 17px; }

    .recent-chat-trigger { display: none; }

    .recent-drawer {
      width: min(420px, calc(100vw - 24px));
      max-height: min(72dvh, 620px);
      margin: auto;
      padding: 16px;
      border: 1px solid #e4e6e9;
      border-radius: 18px;
      background: #fff;
      color: #24272b;
    }
    .recent-drawer::backdrop { background: rgb(0 0 0 / .3); }
    .recent-drawer header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
    .recent-drawer-close { width: 38px; height: 38px; border: 0; border-radius: 10px; display: grid; place-items: center; background: #f2f3f5; color: #4b5058; cursor: pointer; }
    .recent-drawer-close svg { width: 18px; height: 18px; }
    .recent-list { display: grid; gap: 5px; }
    .recent-drawer-item { height: 44px; border-radius: 12px; }
    .recent-empty { margin: 18px 4px; color: #858b95; font-size: 13px; text-align: center; }

    .settings-trigger {
      flex: none;
      width: 42px;
      height: 42px;
      padding: 0;
      border: 1px solid #e3e5e8;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #fff;
      color: #555b64;
      cursor: pointer;
      box-shadow: 0 2px 7px rgba(28,32,40,.05);
    }

    .settings-trigger:hover { background: #f7f7f8; color: #20242b; }
    .mobile-settings-trigger { display: none; }
    .desktop-settings-trigger { width: 34px; height: 34px; }

    .workspace {
      position: relative;
      flex: 1;
      min-width: 0;
      height: calc(100vh - 24px);
      height: calc(100dvh - 24px);
      margin: 12px 12px 12px 0;
      overflow: hidden;
      background: #fff;
      border-radius: 13px;
    }

    .topbar {
      position: relative;
      height: 58px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 24px;
      border-bottom: 1px solid #f0f0f1;
      z-index: 4;
    }

    .topbar-title {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      min-width: 0;
      color: #25282e;
      font-size: 15px;
      font-weight: 700;
    }

    .desktop-lab-brand { color: #667085; font-size: 13px; font-weight: 700; }
    .lab-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .lab-name::after { content: ""; display: inline-block; width: 1px; height: 14px; margin-left: 10px; vertical-align: -2px; background: #d0d5dd; }
    .topbar-actions {
      position: absolute;
      right: 18px;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .guest-badge {
      height: 28px;
      padding: 0 10px;
      border: 1px solid #e4e7ec;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      color: #667085;
      background: #fafafa;
      font-size: 12px;
      font-weight: 650;
      white-space: nowrap;
    }

    .guest-badge.signed-in {
      border-color: #d6e3ff;
      color: #245bdb;
      background: #f3f7ff;
    }

    .chat-surface { position: relative; height: calc(100% - 58px); overflow: hidden; }

    .empty-state {
      position: absolute;
      inset: 0;
      padding-top: 184px;
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      transition: opacity .22s ease, visibility .22s ease, transform .28s ease;
    }

    .entry-card {
      width: min(920px,calc(100% - 72px));
      margin: 0 auto;
      text-align: center;
    }

    .hero-title {
      margin: 0 auto 22px;
      padding: 0 24px;
      text-align: center;
      font-size: clamp(27px,2.3vw,33px);
      line-height: 1.35;
      font-weight: 400;
      letter-spacing: 0;
    }

    .hero-subtitle { max-width: 650px; margin: -8px auto 18px; text-align: center; color: #8b9099; font-size: 14px; line-height: 1.7; }

    .login-guide {
      position: absolute;
      top: 14px;
      right: 18px;
      width: auto;
      min-height: 62px;
      height: auto;
      padding: 12px 16px;
      border: 1px solid #dce6ff;
      border-radius: 14px;
      display: flex;
      align-items: center;
      gap: 11px;
      text-align: left;
      background: linear-gradient(135deg,#f7faff,#fff);
      color: inherit;
      box-shadow: 0 14px 34px rgba(51,112,255,.13);
      cursor: pointer;
      z-index: 6;
      transition: transform .16s ease,box-shadow .16s ease;
    }

    .login-guide::before {
      content: "";
      position: absolute;
      top: -7px;
      right: 18px;
      width: 12px;
      height: 12px;
      border-top: 1px solid #dce6ff;
      border-left: 1px solid #dce6ff;
      background: #fff;
      transform: rotate(45deg);
    }
    .login-guide:hover { background: linear-gradient(135deg,#f2f7ff,#fff); transform: translateY(-1px); box-shadow: 0 16px 38px rgba(51,112,255,.17); }
    .login-guide:focus-visible { outline: 3px solid rgba(51,112,255,.22); outline-offset: 2px; }
    .login-guide[hidden] { display: none !important; }
    body.chat-active .login-guide { display: none; }

    .login-guide-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 11px; background: #3370ff; color: #fff; }
    .login-guide-icon svg { width: 18px; height: 18px; }
    .login-guide-copy { flex: 1; min-width: 0; }
    .login-guide-copy strong { display: block; color: #245bdb; font-size: 13px; font-weight: 800; }

    .composer-wrap {
      position: absolute;
      top: 344px;
      left: 50%;
      width: min(900px,calc(100% - 88px));
      transform: translateX(-50%);
      z-index: 3;
      transition: width .3s ease, top .32s ease, bottom .32s ease;
    }

    .composer-glow { position: absolute; left: 10%; right: 8%; bottom: -34px; height: 70px; background: linear-gradient(90deg,rgba(98,241,232,.14),rgba(113,138,255,.16),rgba(194,87,255,.14)); filter: blur(24px); pointer-events: none; }

    .composer {
      position: relative;
      padding: 1px;
      border-radius: 24px;
      background: linear-gradient(110deg,#b56fff 0%,#a269ff 25%,#66e6df 52%,#6fa5ff 74%,#9370ff 100%);
      filter: drop-shadow(0 13px 18px rgba(120,93,255,.08));
    }

    .composer-inner { border-radius: 23px; background: rgba(255,255,255,.985); overflow: hidden; }

    .input-panel {
      min-height: 92px;
      margin: 12px 12px 0;
      padding: 17px 18px 8px;
      border-radius: 12px;
      background: #f5f5f6;
    }

    .prompt-input {
      display: block;
      width: 100%;
      min-height: 50px;
      max-height: 126px;
      padding: 0;
      resize: none;
      overflow-y: auto;
      border: 0;
      outline: 0;
      background: transparent;
      color: #23262d;
      font-size: 16px;
      line-height: 1.65;
    }

    .prompt-input::placeholder { color: #aeb1b8; }

    .attachment-chip {
      display: none;
      width: fit-content;
      max-width: 100%;
      height: 28px;
      margin-top: 4px;
      padding: 0 9px;
      border-radius: 7px;
      align-items: center;
      gap: 6px;
      background: #fff;
      color: #737781;
      font-size: 12px;
    }

    .attachment-chip.show { display: flex; }
    .attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .attachment-chip svg { width: 13px; height: 13px; flex: none; }

    .composer-footer {
      height: 57px;
      padding: 0 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .input-tools, .footer-actions { display: flex; align-items: center; gap: 8px; }

    .icon-button {
      width: 32px;
      height: 32px;
      padding: 0;
      border: 0;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: transparent;
      color: #777c85;
      cursor: pointer;
    }

    .icon-button:hover { background: #f2f2f3; color: #20242b; }
    .icon-button svg { width: 18px; height: 18px; }
    .icon-button.recording { background: #fff0f2; color: #e64858; animation: pulse 1.2s ease-in-out infinite; }

    .model-pill { height: 30px; padding: 0 11px; border: 1px solid #ececef; border-radius: 16px; display: flex; align-items: center; gap: 6px; background: #fff; color: #737781; cursor: pointer; font-size: 12px; }
    .model-pill svg { width: 13px; height: 13px; }

    .send-button {
      width: 34px;
      height: 34px;
      padding: 0;
      border: 0;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: #b6b8bd;
      color: #fff;
      cursor: default;
      transition: background .16s ease, transform .16s ease;
    }

    .send-button.ready { background: #24272e; cursor: pointer; }
    .send-button.ready:hover { background: #000; transform: translateY(-1px); }
    .send-button svg { width: 18px; height: 18px; }

    .suggestions {
      position: absolute;
      top: 531px;
      left: 50%;
      width: min(900px,calc(100% - 88px));
      transform: translateX(-50%);
      display: grid;
      grid-template-columns: repeat(2,minmax(0,1fr));
      gap: 10px;
      transition: opacity .2s ease, transform .24s ease;
    }

    .suggestion {
      height: 43px;
      padding: 0 15px;
      border: 1px solid #eeeef0;
      border-radius: 13px;
      display: flex;
      align-items: center;
      gap: 9px;
      background: #fff;
      color: #555a63;
      cursor: pointer;
      text-align: left;
      transition: border-color .16s ease, background .16s ease, transform .16s ease;
    }

    .suggestion:hover { border-color: #dcdce2; background: #fafafa; transform: translateY(-1px); }
    .suggestion svg { width: 17px; height: 17px; color: #888d96; flex: none; }

    .conversation {
      position: absolute;
      inset: 0;
      opacity: 0;
      visibility: hidden;
      transition: opacity .25s ease .12s, visibility .25s ease .12s;
    }

    .message-list {
      position: absolute;
      top: 12px;
      left: 50%;
      bottom: 185px;
      width: calc(100% - 24px);
      transform: translateX(-50%);
      padding: 24px 24px 54px;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: #dedfe2 transparent;
    }

    .message { display: flex; gap: 12px; margin: 0 0 24px; animation: message-in .28s ease both; }
    .message.assistant { justify-content: flex-start; }
    .message.user { justify-content: flex-end; }

    .assistant-mark {
      width: 29px;
      height: 29px;
      margin-top: 2px;
      border-radius: 9px;
      display: grid;
      place-items: center;
      flex: none;
      background: linear-gradient(145deg,#efffff,#e7e9ff);
    }

    .mini-loader { position: relative; width: 19px; height: 19px; }
    .mini-loader::before, .mini-loader::after { content: ""; position: absolute; left: 3px; width: 13px; height: 7px; border-radius: 6px 2px 6px 2px; transform: rotate(14deg); }
    .mini-loader::before { top: 2px; background: linear-gradient(100deg,#78ece1,#b9e8ff); }
    .mini-loader::after { bottom: 2px; background: linear-gradient(100deg,#6bb8fa,#9975ee); }

    .message-content { max-width: none; font-size: 15px; line-height: 1.76; color: #31353c; }
    .message.assistant .message-content { width: 100%; max-width: none; }
    .message.assistant .message-content { padding-top: 1px; }
    .message.user .message-content { padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: #f1f1f2; color: #25282e; }
    .message-content p { margin: 0; white-space: pre-wrap; }
    .answer-content { display: grid; gap: 9px; }
    .answer-content p { margin: 0; white-space: normal; }
    .answer-content h3 { margin: 2px 0 0; font-size: 16px; line-height: 1.55; color: #17191d; }
    .answer-content strong { font-weight: 700; color: #17191d; }
    .answer-content code { padding: 1px 5px; border-radius: 5px; background: #f1f3f5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
    .answer-content ol, .answer-content ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
    .answer-content table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 8px; font-size: 14px; }
    .answer-content th, .answer-content td { border: 1px solid #e5e7eb; padding: 7px 9px; text-align: left; vertical-align: top; }
    .answer-content th { background: #f7f8fa; color: #17191d; font-weight: 700; }
    .math-inline { display: inline-flex; align-items: baseline; max-width: 100%; overflow-x: auto; vertical-align: baseline; }
    .math-display { display: block; max-width: 100%; margin: 10px 0; overflow-x: auto; text-align: center; }
    .math-display math { margin: 0 auto; }
    .knowledge-gallery { display: grid; gap: 12px; margin-top: 4px; }
    .knowledge-image { margin: 0; max-width: min(520px,100%); border: 1px solid #eceef2; border-radius: 10px; overflow: hidden; background: #fff; }
    .knowledge-image img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: contain; background: #f7f8fa; }
    .knowledge-image figcaption { padding: 8px 10px; color: #6b7280; font-size: 12px; line-height: 1.45; border-top: 1px solid #eceef2; }

    .message-actions { display: flex; gap: 4px; margin-top: 7px; opacity: 0; transition: opacity .15s ease; }
    .message.assistant:hover .message-actions { opacity: 1; }
    .message-action { width: 27px; height: 27px; padding: 0; border: 0; border-radius: 7px; display: grid; place-items: center; background: transparent; color: #9a9da4; cursor: pointer; }
    .message-action:hover { background: #f3f3f4; color: #555a63; }
    .message-action svg { width: 14px; height: 14px; }

    .typing { display: flex; align-items: center; gap: 5px; height: 28px; }
    .typing i { width: 6px; height: 6px; border-radius: 50%; background: #aeb1b7; animation: typing 1.1s ease-in-out infinite; }
    .typing i:nth-child(2) { animation-delay: .16s; }
    .typing i:nth-child(3) { animation-delay: .32s; }


    body.chat-active .empty-state { opacity: 0; visibility: hidden; transform: translateY(-22px); }
    body.chat-active .suggestions { opacity: 0; pointer-events: none; transform: translate(-50%,16px); }
    body.chat-active .conversation { opacity: 1; visibility: visible; }
    body.chat-active .composer-wrap { top: auto; bottom: 27px; width: calc(100% - 24px); }
    body.chat-active .composer-glow { opacity: .55; }
    body.chat-active .input-panel { min-height: 70px; padding-top: 13px; }
    body.chat-active .prompt-input { min-height: 42px; max-height: 92px; }

    .toast {
      position: fixed;
      left: calc(50% + 100px);
      bottom: 30px;
      z-index: 12;
      padding: 10px 16px;
      border-radius: 10px;
      background: rgba(28,30,35,.92);
      color: #fff;
      opacity: 0;
      pointer-events: none;
      transform: translate(-50%,12px);
      transition: opacity .2s ease, transform .2s ease;
      box-shadow: 0 8px 24px rgba(0,0,0,.16);
    }

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

    .auth-backdrop {
      position: fixed;
      inset: 0;
      z-index: 20;
      display: grid;
      place-items: center;
      padding: 24px;
      background: rgba(20,23,29,.28);
      backdrop-filter: blur(4px);
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity .18s ease, visibility .18s ease;
    }

    .auth-backdrop.open { opacity: 1; visibility: visible; pointer-events: auto; }

    .auth-dialog {
      position: relative;
      width: min(410px,100%);
      padding: 32px 30px 27px;
      border: 1px solid rgba(230,231,234,.95);
      border-radius: 20px;
      background: #fff;
      box-shadow: 0 24px 70px rgba(25,28,36,.18);
      text-align: center;
      transform: translateY(10px) scale(.985);
      transition: transform .2s ease;
    }

    .auth-backdrop.open .auth-dialog { transform: translateY(0) scale(1); }

    .auth-close {
      position: absolute;
      top: 14px;
      right: 14px;
      width: 32px;
      height: 32px;
      padding: 0;
      border: 0;
      border-radius: 50%;
      display: grid;
      place-items: center;
      background: transparent;
      color: #858991;
      cursor: pointer;
    }

    .auth-close:hover { background: #f4f4f5; color: #2e3239; }
    .auth-close svg { width: 16px; height: 16px; }

    .auth-brand {
      width: 48px;
      height: 48px;
      margin: 2px auto 18px;
      border-radius: 14px;
      display: grid;
      place-items: center;
      background: #f5f8ff;
    }

    .auth-brand svg { width: 31px; height: 31px; }
    .auth-dialog h2 { margin: 0; font-size: 21px; line-height: 1.45; font-weight: 650; }
    .auth-dialog p { margin: 9px 0 23px; color: #8a8e96; font-size: 13px; line-height: 1.7; }

    .campus-login-form { display: grid; gap: 11px; margin: 0 0 16px; text-align: left; }
    .auth-field { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 700; }
    .auth-field input {
      width: 100%;
      height: 42px;
      padding: 0 12px;
      border: 1px solid #dfe3ea;
      border-radius: 10px;
      outline: 0;
      background: #fff;
      color: #20232a;
      font-size: 14px;
      font-weight: 500;
    }

    .auth-field input:focus { border-color: #3370ff; box-shadow: 0 0 0 3px rgba(51,112,255,.12); }
    .code-field { margin-top: 3px; }

    .campus-code-button, .campus-login-button {
      width: 100%;
      height: 42px;
      border: 0;
      border-radius: 11px;
      background: #3370ff;
      color: #fff;
      cursor: pointer;
      font-size: 14px;
      font-weight: 700;
      transition: background .16s ease, transform .16s ease;
    }

    .campus-code-button:hover, .campus-login-button:hover { background: #245bdb; transform: translateY(-1px); }
    .campus-code-button:disabled, .campus-login-button:disabled { opacity: .62; cursor: default; transform: none; }

    .auth-status {
      min-height: 19px;
      color: #858991;
      font-size: 12px;
      line-height: 1.55;
      text-align: center;
    }

    .auth-status.success { color: #1f7a4f; }
    .auth-status.error { color: #d92d20; }

    .feishu-login {
      width: 100%;
      height: 44px;
      border: 0;
      border-radius: 11px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 9px;
      background: #3370ff;
      color: #fff;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: background .16s ease, transform .16s ease;
    }

    .feishu-login:hover { background: #245bdb; transform: translateY(-1px); }
    .feishu-login:focus-visible { outline: 3px solid rgba(51,112,255,.25); outline-offset: 2px; }
    .feishu-login svg { width: 19px; height: 19px; }
    .guest-limits {
      margin: 18px 0 14px;
      padding: 14px 15px;
      border: 1px solid #edf0f4;
      border-radius: 13px;
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 8px 11px;
      background: #fafbfc;
      text-align: left;
      font-size: 12px;
      line-height: 1.6;
      color: #717680;
    }

    .guest-limits strong { color: #30343b; white-space: nowrap; }

    .guest-continue {
      width: 100%;
      height: 40px;
      border: 1px solid #e4e7ec;
      border-radius: 11px;
      background: #fff;
      color: #424750;
      cursor: pointer;
      font-size: 14px;
      font-weight: 650;
    }

    .guest-continue:hover { background: #f7f8fa; }
    .auth-caption { margin-top: 14px !important; margin-bottom: 0 !important; color: #b1b3b8 !important; font-size: 12px !important; }

    body.sidebar-collapsed .sidebar { flex-basis: 68px; width: 68px; padding-left: 8px; padding-right: 8px; }
    body.sidebar-collapsed .brand { justify-content: center; padding-left: 0; }
    body.sidebar-collapsed .brand-mark { display: block; }
    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .sidebar-label, body.sidebar-collapsed .nav-item span,
    body.sidebar-collapsed .history-label, body.sidebar-collapsed .history-list,
    body.sidebar-collapsed .new-chat-bottom span { display: none; }
    body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
    body.sidebar-collapsed .bottom-actions { flex-direction: column; }
    body.sidebar-collapsed .new-chat-bottom { flex: none; width: 42px; padding: 0; }
    body.sidebar-collapsed .collapse-handle svg { transform: rotate(180deg); }

    @keyframes typing { 0%,60%,100% { transform: translateY(0); opacity: .42; } 30% { transform: translateY(-4px); opacity: 1; } }
    @keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(230,72,88,.12); } 50% { box-shadow: 0 0 0 6px rgba(230,72,88,0); } }
    @keyframes message-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

    @media (max-width: 1100px) {
      .sidebar { flex-basis: 56px; width: 56px; padding: 16px 6px; }
      .brand { justify-content: center; padding-left: 0; margin-bottom: 24px; }
      .brand-mark { display: block; }
      .brand-copy, .sidebar-label, .nav-item span, .history-label, .history-list { display: none; }
      .nav-item { height: 38px; justify-content: center; padding: 0; border-radius: 11px; }
      .side-footer { left: 6px; right: 6px; bottom: 10px; }
      .bottom-actions { flex-direction: column; gap: 8px; }
      .new-chat-bottom, .settings-trigger { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 13px; }
      .new-chat-bottom span { display: none; }
      .collapse-handle { right: -10px; width: 20px; height: 54px; }
      .workspace { margin: 12px 8px 12px 0; border-radius: 13px; }
      .topbar { height: 48px; }
      .topbar-actions { right: 12px; gap: 6px; }
      .guest-badge { display: none; }
      .topbar-title { font-size: 14px; }
      .desktop-lab-brand { display: none; }
      .lab-name::after { display: none; }
      .chat-surface { height: calc(100% - 48px); }
      body.chat-active .topbar { height: 0; padding: 0; border-bottom: 0; overflow: hidden; }
      body.chat-active .chat-surface { height: 100%; }
      .message-list { top: 0; bottom: 132px; width: calc(100% - 18px); padding: 14px 22px 22px; }
      .message { margin-bottom: 18px; }
      .message-content { font-size: 14px; line-height: 1.72; }
      body.chat-active .composer-wrap { bottom: 12px; width: calc(100% - 20px); }
      .composer { border-radius: 19px; filter: drop-shadow(0 8px 14px rgba(120,93,255,.06)); }
      .composer-inner { border-radius: 18px; }
      .input-panel { min-height: 48px; margin: 9px 10px 0; padding: 9px 15px 5px; border-radius: 11px; }
      .prompt-input { min-height: 28px; max-height: 62px; line-height: 1.55; }
      .composer-footer { height: 40px; }
      body.chat-active .input-panel { min-height: 46px; padding-top: 8px; }
      body.chat-active .prompt-input { min-height: 28px; max-height: 54px; }
      body.chat-active .composer:focus-within .input-panel { min-height: 64px; padding-top: 11px; }
      body.chat-active .composer:focus-within .prompt-input { min-height: 42px; max-height: 96px; }
    }

    @media (max-width: 900px) {
      .sidebar { flex-basis: 68px; width: 68px; padding-left: 8px; padding-right: 8px; }
      .brand { justify-content: center; padding-left: 0; }
      .brand-copy, .sidebar-label, .nav-item span, .history-label, .history-list { display: none; }
      .nav-item { justify-content: center; padding: 0; }
      .side-footer { left: 8px; right: 8px; bottom: 14px; }
      .bottom-actions { flex-direction: column; }
      .new-chat-bottom { flex: none; width: 42px; padding: 0; }
      .new-chat-bottom span { display: none; }
      .workspace { margin-right: 8px; }
      .empty-state { padding-top: 128px; }
      .entry-card { width: calc(100% - 32px); }
      .composer-wrap { top: 300px; width: calc(100% - 32px); }
      .suggestions { top: 487px; width: calc(100% - 32px); }
      body.chat-active .composer-wrap, .message-list { width: calc(100% - 24px); }
      .toast { left: calc(50% + 34px); }
    }

    @media (max-width: 640px) {
      html, body { height: 100%; overflow: hidden; }
      body { min-height: 100svh; min-height: 100dvh; }
      .app-shell { display: block; min-height: 100svh; min-height: 100dvh; }
      .sidebar { position: fixed; top: 0; left: 0; right: 0; width: 100%; height: 58px; height: calc(58px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; display: flex; align-items: center; border-right: 0; border-bottom: 1px solid #ececee; }
      .brand { justify-content: flex-start; padding: 0; margin: 0; }
      .brand-mark { display: none; }
      .brand-copy { display: flex; }
      body.sidebar-collapsed .brand-mark { display: none; }
      body.sidebar-collapsed .brand-copy { display: flex; }
      .brand-title { display: block; color: #25282e; font-size: 15px; font-weight: 760; }
      .brand-subtitle { display: none; }
      .sidebar-label, .nav-list, .history-label, .history-list, .collapse-handle { display: none !important; }
      .side-footer { position: static; display: block !important; margin-left: auto; }
      .side-footer .bottom-actions { flex-direction: row; }
      .side-footer .new-chat-bottom, .side-footer .settings-trigger, .side-footer .recent-chat-trigger { width: 36px; height: 36px; border-radius: 50%; padding: 0; }
      .recent-chat-trigger { display: grid !important; place-items: center; border: 1px solid #e3e5e8; background: #fff; color: #555b64; box-shadow: 0 2px 7px rgba(28,32,40,.05); cursor: pointer; }
      .mobile-settings-trigger { display: grid; }
      .side-footer .new-chat-bottom span { display: none; }
      .workspace {
        height: calc(100svh - 66px - env(safe-area-inset-bottom));
        height: calc(100dvh - 66px - env(safe-area-inset-bottom));
        margin: calc(66px + env(safe-area-inset-top)) 8px max(8px,env(safe-area-inset-bottom));
        border-radius: 12px;
      }
      .topbar { display: none; }
      .chat-surface { height: 100%; }
      body.chat-active .chat-surface { height: 100%; }
      .empty-state { padding-top: 110px; }
      .hero-title { max-width: 360px; font-size: 25px; }
      .hero-subtitle { font-size: 13px; }
      .entry-card { width: calc(100% - 20px); }
      .login-guide { position: fixed; top: calc(64px + env(safe-area-inset-top)); right: 13px; width: auto; min-height: 54px; padding: 10px 12px; gap: 9px; }
      .login-guide::before { right: 14px; }
      .login-guide-icon { width: 32px; height: 32px; flex-basis: 32px; }
      .composer-wrap { top: 280px; width: calc(100% - 20px); }
      .composer { border-radius: 20px; }
      .composer-inner { border-radius: 19px; }
      .suggestions { top: 445px; width: calc(100% - 20px); grid-template-columns: 1fr; }
      .suggestion:nth-child(n+3) { display: none; }
      .model-pill span { display: none; }
      .message-list {
        top: 0;
        bottom: calc(126px + env(safe-area-inset-bottom));
        width: calc(100% - 22px);
        padding: 18px 0 28px;
      }
      .message-content { max-width: 94%; }
      body.chat-active .composer-wrap { width: calc(100% - 20px); bottom: calc(14px + env(safe-area-inset-bottom)); }
      body.chat-active .input-panel { min-height: 46px; padding-top: 8px; }
      body.chat-active .prompt-input { min-height: 28px; max-height: 54px; }
      body.chat-active .composer:focus-within .input-panel { min-height: 66px; padding-top: 12px; }
      body.chat-active .composer:focus-within .prompt-input { min-height: 42px; max-height: 96px; }
      body.chat-active .composer-footer { height: 40px; }
      .toast { left: 50%; }
    }


    @media (max-height: 760px) and (orientation: landscape) {
      .topbar { height: 48px; }
      .chat-surface { height: calc(100% - 48px); }
      body.chat-active .topbar { height: 0; padding: 0; border-bottom: 0; overflow: hidden; }
      body.chat-active .chat-surface { height: 100%; }
      .message-list { top: 0; bottom: 124px; padding: 18px 26px 22px; }
      .message { margin-bottom: 18px; }
      .message.user .message-content { padding: 9px 13px; }
      body.chat-active .composer-wrap { bottom: 16px; width: calc(100% - 24px); }
      .composer { border-radius: 20px; }
      .composer-inner { border-radius: 19px; }
      .input-panel { min-height: 48px; margin: 9px 10px 0; padding: 9px 16px 5px; }
      .prompt-input { min-height: 28px; max-height: 58px; line-height: 1.55; }
      .composer-footer { height: 40px; }
      body.chat-active .input-panel { min-height: 46px; padding-top: 8px; }
      body.chat-active .prompt-input { min-height: 28px; max-height: 54px; }
      body.chat-active .composer:focus-within .input-panel { min-height: 64px; padding-top: 11px; }
      body.chat-active .composer:focus-within .prompt-input { min-height: 42px; max-height: 92px; }
      .typing { height: 22px; }
    }

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

/* Chat mobile polish: header targets and login dialog only.
 * Deliberately does not change composer, message-list, chat-surface,
 * recommendations, body scrolling, or body.chat-active layout. */
@media (max-width: 640px) {
  .app-shell > .sidebar > .brand {
    flex: 1 1 auto;
    min-width: 0;
    margin-right: 8px;
  }

  .app-shell > .sidebar > .brand .brand-copy {
    min-width: 0;
  }

  .app-shell > .sidebar > .brand .brand-title {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.35;
  }

  .app-shell > .sidebar > .side-footer {
    flex: 0 0 auto;
  }

  .app-shell > .sidebar .bottom-actions {
    gap: 4px;
  }

  .app-shell > .sidebar .side-footer .new-chat-bottom,
  .app-shell > .sidebar .side-footer .settings-trigger,
  .app-shell > .sidebar .side-footer .recent-chat-trigger {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .auth-backdrop {
    padding: 16px;
  }

  .auth-backdrop .auth-dialog {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: 32px 22px 24px;
  }

  .auth-backdrop .auth-close {
    top: 6px;
    right: 6px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .auth-backdrop .auth-field input {
    min-height: 44px;
    font-size: 16px;
  }

  .auth-backdrop .campus-code-button,
  .auth-backdrop .campus-login-button,
  .auth-backdrop .guest-continue {
    min-height: 44px;
  }
}

/* Constrain long course titles to the sidebar grid. */
.sidebar .history-list { min-width:0; max-width:100%; grid-template-columns:minmax(0,1fr); }
.sidebar .history-list .history-item { box-sizing:border-box; min-width:0; max-width:100%; overflow:hidden; }
.sidebar .history-list .history-item > span { flex:1 1 0; min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }

/* Shared AI answer formatting; scoped to rendered answers only. */
.answer-content { min-width: 0; overflow-wrap: anywhere; }
.answer-content h1, .answer-content h2, .answer-content h3, .answer-content h4, .answer-content h5, .answer-content h6 { font-weight: 650; line-height: 1.4; margin: 1.05em 0 .5em; }
.answer-content h1 { font-size: 1.4em; }
.answer-content h2 { font-size: 1.25em; }
.answer-content h3 { font-size: 1.12em; }
.answer-content h4, .answer-content h5, .answer-content h6 { font-size: 1em; }
.answer-content ul { list-style: disc outside; padding-left: 1.5em; }
.answer-content ol { list-style: decimal outside; padding-left: 1.5em; }
.answer-content li { margin: .3em 0; }
.answer-content li > ul, .answer-content li > ol { margin-top: .25em; margin-bottom: .25em; }
.answer-content a { color: #126b78; text-decoration: underline; text-underline-offset: 2px; }
.answer-content blockquote { margin: .8em 0; border-left: 3px solid #b8d5d9; padding-left: 1em; color: #4b626c; }
.answer-content pre.om-code-block { display: block; overflow-x: auto; max-width: 100%; margin: .8em 0; padding: 14px 16px; border: 1px solid #d8e3e8; border-radius: 10px; background: #f5f8fa; white-space: pre; overflow-wrap: normal; }
.answer-content pre.om-code-block > code { display: block; padding: 0; border: 0; background: transparent; color: inherit; font-size: .9em; line-height: 1.6; font-family: ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre; overflow-wrap: normal; }
.answer-content table { display: block; overflow-x: auto; width: max-content; max-width: 100%; border-collapse: collapse; margin: .8em 0; }
.answer-content th, .answer-content td { border: 1px solid #d8e3e8; padding: .5em .75em; vertical-align: top; }
.answer-content th { font-weight: 650; background: #f3f7f8; }
.answer-content input[type="checkbox"] { margin-right: .5em; }

.grading-entry { display:inline-flex; align-items:center; min-height:44px; padding:0 10px; color:#245bdb; font-size:14px; white-space:nowrap; text-decoration:none; }

/* Shared knowledge, explicit model choice. */
.model-choice { position:relative; flex:0 0 auto; }
.composer .composer-inner { overflow:visible; }
.model-choice .model-pill { gap:5px; white-space:nowrap; }
.model-choice .model-pill span { display:inline; }
.model-options { position:absolute; bottom:calc(100% + 10px); right:0; z-index:40; width:172px; padding:5px; border:1px solid #e1e1e1; border-radius:14px; background:#fff; box-shadow:0 10px 30px #0002; }
.model-options[hidden] { display:none; }
.model-options button { display:block; width:100%; min-height:44px; border:0; border-radius:9px; padding:10px 12px; text-align:left; background:transparent; color:#222; font:inherit; font-size:14px; cursor:pointer; }
.model-options button:hover,.model-options button:focus-visible { background:#f2f2f2; outline:2px solid #aaa; outline-offset:-2px; }
.model-options button[aria-pressed="true"] { background:#eee; font-weight:600; }
.model-options button[aria-pressed="true"]::after { content:'✓'; float:right; }

/* Compact, left-aligned response tools. Keep the existing answer/math layout. */
.message.assistant .message-actions{display:flex;justify-content:flex-start;align-items:center;gap:4px;flex-wrap:wrap;margin-top:12px;inline-size:100%;padding:0;}
.message-action-button{display:inline-flex;align-items:center;justify-content:center;flex:0 0 40px;width:40px;height:40px;min-width:40px;min-height:40px;padding:8px;border:0;border-radius:9px;background:transparent;color:#72767e;cursor:pointer;}
.message-action-button:hover,.message-action-button:focus-visible{background:#f0f1f3;color:#222;}
.message-action-button:focus-visible,.question-menu-item:focus-visible{outline:2px solid #4468b1;outline-offset:2px;}
.message-source-note{color:#858b95;font-size:12px;line-height:1.5;margin-left:6px;overflow-wrap:anywhere;}
.question-actions{display:flex;justify-content:flex-end;margin-top:2px;}
.question-actions-trigger{height:32px;min-height:32px;}
.message.user .message-body{-webkit-touch-callout:none;}
.message-action-dialog{box-sizing:border-box;width:min(680px,calc(100vw - 24px));max-height:min(86dvh,860px);margin:auto;border:1px solid #e4e6e9;border-radius:18px;background:#fff;color:#24272b;padding:20px;overflow:auto;overscroll-behavior:contain;}
.message-action-dialog::backdrop{background:rgb(0 0 0 / .3);}
.message-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:12px;}
.message-dialog-header h2{font-size:18px;line-height:1.4;margin:0;}
.message-dialog-close{border:0;border-radius:8px;background:#f2f3f5;padding:10px 14px;color:inherit;cursor:pointer;}
.message-dialog-note,.message-share-status{font-size:13px;line-height:1.7;color:#68707c;white-space:pre-wrap;overflow-wrap:anywhere;}
.answer-share-preview{border-top:1px solid #eceef1;border-bottom:1px solid #eceef1;margin:14px 0;padding:12px 0;overflow-wrap:anywhere;}
.answer-share-preview h3{font-size:13px;color:#68707c;}
.shared-question{white-space:pre-wrap;}
.message-dialog-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:10px;margin-top:12px;}
.message-dialog-actions button{min-height:44px;white-space:normal;}
.message-edit-input{box-sizing:border-box;display:block;width:100%;min-height:130px;max-height:45dvh;resize:vertical;border:1px solid #cfd3da;border-radius:10px;padding:12px;font:inherit;line-height:1.6;}
.question-action-menu{width:min(310px,calc(100vw - 24px));}
.question-menu-item{display:block;width:100%;min-height:46px;text-align:left;padding:10px 14px;background:transparent;color:inherit;border:0;border-radius:8px;font:inherit;cursor:pointer;}
.question-menu-item:hover{background:#f1f3f6;}
.message-copy-probe{position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;}
@media (pointer:coarse){.message-action-button{width:44px;height:44px;min-width:44px;min-height:44px;flex-basis:44px;}}
@media (max-width:480px){.message-action-dialog{padding:16px;}.message-source-note{margin-left:4px;font-size:11px;}.message-dialog-actions button{flex:1 1 120px;}}
