:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  color: #1d1d1b;
  background: #fff;
  --surface: #fff;
  --rail: #f7f7f6;
  --shade: #efefee;
  --border: #e7e7e5;
  --muted: #62625f;
  --ink: #1d1d1b;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid #595958; outline-offset: 3px; }
a { color: inherit; }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); height: 100dvh; min-height: 360px; }
.shell.closed { grid-template-columns: minmax(0, 1fr); }
.shell.closed .rail { display: none; }
.rail { display: flex; flex-direction: column; gap: 20px; min-height: 0; padding: 15px 12px 14px; background: var(--rail); border-right: 1px solid #eeeeed; }
.rail-head, .topbar, .admin-actions { display: flex; align-items: center; gap: 10px; }
.rail-head { min-height: 37px; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; min-height: 34px; padding: 0 7px; border-radius: 7px; font-weight: 670; white-space: nowrap; text-decoration: none; }
.brand:hover { background: var(--shade); }
.brand:active { background: var(--border); }
.plain, .rail-button, .history-button, .icon { border: 0; background: transparent; color: var(--ink); border-radius: 8px; }
.plain { padding: 8px 10px; font-size: .87rem; }
.plain:hover, .rail-button:hover, .history-button:hover, .icon:hover, .history-button.current { background: var(--shade); }
.icon { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; flex: 0 0 auto; font-size: 18px; }
.panel-icon { width: 15px; height: 13px; border: 1.45px solid currentColor; border-radius: 3px; position: relative; }
.panel-icon::after { content: ''; position: absolute; inset: 0 auto 0 4px; border-left: 1.45px solid currentColor; }
.rail-button, .history-button { display: flex; align-items: center; text-align: start; padding: 9px 8px; gap: 8px; width: 100%; }
.rail-button { font-weight: 550; }
a.rail-button { text-decoration: none; }
.plus { font-size: 17px; line-height: 1; width: 16px; text-align: center; }
.rail-middle { min-height: 0; overflow: auto; flex: 1; }
.history-label { padding: 1px 8px 7px; color: var(--muted); font-size: .77rem; font-weight: 610; }
.history-button { overflow: hidden; display: block; white-space: nowrap; text-overflow: ellipsis; font-size: .88rem; font-weight: 400; }
.rail-foot { border-top: 1px solid var(--border); padding-top: 8px; }
.rail-foot .rail-button { font-size: .87rem; }
.veil { display: none; }

.main { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar { min-height: 63px; padding: 0 25px; justify-content: space-between; }
.topbar-group { display: flex; align-items: center; gap: 7px; }
.section-name { font-weight: 610; color: #373735; font-size: .94rem; }
.mode-picker { width: 6.25rem; min-height: 34px; padding: 0 8px; border: 0; border-radius: 7px; background-color: transparent; color: var(--ink); font-size: .89rem; font-weight: 570; cursor: pointer; }
.mode-picker:hover { background-color: var(--shade); }
.topbar .language { color: #4c4c49; }
.outline-button, .dark-button { border-radius: 9px; padding: 9px 13px; font-size: .87rem; font-weight: 580; }
.outline-button { background: var(--surface); color: var(--ink); border: 1px solid #d9d9d6; }
.outline-button:hover { background: #f7f7f6; }
.dark-button { color: white; background: var(--ink); border: 1px solid var(--ink); }
.dark-button:hover { background: #373734; }
.dark-button:disabled { opacity: .56; }
.view { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-body { width: 100%; flex: 1 1 auto; overflow: auto; min-height: 0; }
.empty .chat-body { display: none; }
.compose-space { padding: 0 22px max(13px, env(safe-area-inset-bottom)); flex: 0 0 auto; }
.empty .compose-space { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding-block: 22px max(42px, env(safe-area-inset-bottom)); }
.lab { width: min(100%, 668px); margin-inline: auto; }
.empty .lab { margin-block: auto; }
.intro { text-align: center; margin: 0 0 30px; }
.intro h1 { font-size: 2.1rem; line-height: 1.25; margin: 0; font-weight: 570; letter-spacing: 0; text-wrap: balance; overflow-wrap: anywhere; }
.starter-deck { margin-top: 16px; }
.starter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.starter-head h2 { margin: 0; font-size: .88rem; font-weight: 640; }
.starter-shuffle { color: var(--muted); font-size: .8rem; padding: 7px 8px; }
.starter-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.starter-card { display: grid; align-content: start; gap: 5px; min-width: 0; min-height: 91px; padding: 12px; text-align: start; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); overflow-wrap: anywhere; }
.starter-card[data-kind='resume'], .starter-card:hover { background: var(--rail); }
.starter-card:hover { border-color: #d2d2cf; }
.starter-card strong { font-size: .91rem; font-weight: 650; line-height: 1.42; }
.starter-card span { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 35px; align-items: end; gap: 12px; border: 1px solid #dcdcd8; border-radius: 23px; background: white; padding: 9px 10px 9px 16px; box-shadow: 0 2px 9px #00000007; }
.composer:focus-within { border-color: #a9a9a5; }
.composer.with-image { grid-template-columns: 35px minmax(0, 1fr) 35px; padding-left: 9px; gap: 8px; }
.attach { height: 35px; width: 35px; font-size: 1.3rem; }
.attachment-draft { grid-column: 1 / -1; position: relative; justify-self: start; margin: 2px; }
.attachment-draft img { width: 80px; height: 64px; object-fit: contain; display: block; border: 1px solid var(--border); border-radius: 7px; }
.attachment-draft button { position: absolute; right: -8px; top: -7px; width: 23px; height: 23px; background: white; border: 1px solid var(--border); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; background: transparent; resize: none; min-height: 35px; max-height: 145px; line-height: 1.55; color: var(--ink); padding: 6px 0; }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: #6e6e6b; }
.send { display: grid; place-items: center; width: 35px; height: 35px; background: var(--ink); border: 0; color: white; border-radius: 50%; font-size: 20px; line-height: 1; }
.send:hover { background: #3d3d3b; }
.send:disabled { background: #eaeae8; color: #5b5b58; }
.status { text-align: center; margin: 12px 0 0; min-height: 1.35em; font-size: .76rem; color: var(--muted); line-height: 1.5; }
.messages { padding: 20px 22px 24px; width: min(100%, 712px); margin: auto; display: flex; flex-direction: column; gap: 25px; }
.message { width: fit-content; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.68; max-width: 100%; }
.message.user {
  align-self: flex-end;
  min-width: min(14rem, 92%);
  max-width: 92%;
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--ink);
  color: var(--surface);
}
.message.user[data-shape="short"] { border-radius: 999px; }
.message.user[data-shape="long"] { border-radius: 14px; }
.message.assistant { width: 100%; min-width: 0; white-space: normal; }
.message.assistant > * { margin: 0; }
.message.assistant > * + * { margin-top: .85em; }
.message.assistant h3,.message.assistant h4,.message.assistant h5,.message.assistant h6 { line-height: 1.45; font-size: 1em; font-weight: 680; }
.message.assistant h3 { font-size: 1.12em; }
.message.assistant ol,.message.assistant ul { padding-inline-start: 1.4em; }
.message.assistant li + li { margin-top: .25em; }
.message.assistant li p { margin: .25em 0; }
.message.assistant blockquote { padding: .15em .9em; border-inline-start: 3px solid #d2d2cd; color: #464644; }
.message.assistant blockquote p { margin: .25em 0; }
.message.assistant a { text-underline-offset: .2em; }
.message.assistant hr { border: 0; border-top: 1px solid var(--border); }
.formula-block { padding: 10px 12px; background: #f6f6f5; border-radius: 7px; overflow-x: auto; text-align: center; white-space: pre; }
.formula-block .katex { display: block; min-width: max-content; }
.formula-inline math { font-size: 1.04em; }
.reply-code { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #f7f7f6; }
.reply-code-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 37px; padding: 0 8px 0 13px; background: #efefed; color: #454542; font-size: .78rem; }
.reply-code-bar button { min-width: 4.5rem; padding: 4px 6px; }
.reply-code pre { margin: 0; padding: 13px; overflow-x: auto; white-space: pre; line-height: 1.5; }
.message.assistant .reply-code code { background: transparent; padding: 0; }
.reply-table { overflow-x: auto; }
.reply-table table { width: 100%; border-collapse: collapse; font-size: .94em; text-align: start; }
.reply-table th,.reply-table td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: start; }
.reply-table th { background: #f5f5f4; font-weight: 650; }
.reply-table .align-right { text-align: right; }
.reply-table .align-center { text-align: center; }
.lesson-block { padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.lesson-choice { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.lesson-question { max-width: 100%; margin: 0 0 6px; padding: 0; font-weight: 670; }
.lesson-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 10px; min-height: 44px; padding: 9px 8px; border-radius: 6px; cursor: pointer; }
.lesson-option:hover { background: var(--rail); }
.lesson-option:has(:checked) { background: var(--shade); }
.lesson-radio { width: 16px; height: 16px; margin: .3em 0 0; accent-color: var(--ink); }
.lesson-bar { display: block; width: min(100%, 23rem); height: 8px; margin-block: 7px 4px; border-radius: 3px; overflow: hidden; }
.lesson-bar rect:nth-child(1) { fill: #478371; }
.lesson-bar rect:nth-child(2) { fill: #b7813d; }
.lesson-bar rect:nth-child(3) { fill: #9c9b96; }
.lesson-bar rect:nth-child(4) { fill: #565652; }
.lesson-bar-key { display: flex; flex-wrap: wrap; gap: 1px 12px; font-size: .87em; color: var(--muted); }
.lesson-feedback { margin: 0; }
.lesson-feedback:not(:empty) { margin-top: 8px; padding: 10px 8px 0; border-top: 1px solid var(--border); }
.lesson-steps summary { padding: 7px 0; min-height: 38px; cursor: pointer; font-weight: 560; }
.lesson-steps details p { margin: 0 0 8px; padding-inline-start: 1em; color: var(--muted); }
.message.assistant .lesson-flow { list-style: none; padding: 14px 16px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 26px; }
.message.assistant .lesson-flow li { margin: 0; position: relative; }
.lesson-flow li + li::before { content: ''; position: absolute; inset: .55em auto auto -19px; width: 7px; height: 7px; border: solid var(--muted); border-width: 1px 1px 0 0; transform: rotate(45deg); }
.lesson-flow strong, .lesson-flow span { display: block; }
.lesson-flow span { margin-top: 3px; font-size: .92em; color: var(--muted); }
.message-image-link { display: block; }
.message-image { display: block; max-width: min(100%, 250px); max-height: 230px; object-fit: contain; margin: 3px 0 7px; border-radius: 6px; }
.message.assistant code { background: var(--rail); padding: 1px 4px; border-radius: 4px; font-size: .91em; }
.message.pending, .message.note { color: var(--muted); }
.chat-actions { margin-left: auto; }

.sheet { max-width: 790px; margin: 3vh auto 0; width: 100%; padding: 3px 24px 36px; overflow: auto; }
.sheet h1 { font-size: 1.85rem; font-weight: 620; letter-spacing: -.035em; }
.sheet h2 { font-size: 1.1rem; margin: 0 0 15px; }
.sheet section { border-top: 1px solid var(--border); margin: 26px 0 0; padding: 20px 0 0; }
.sheet .notice { color: var(--muted); line-height: 1.5; }
.sheet form, .dialog-form { display: grid; gap: 11px; }
.sheet form { max-width: 490px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: .87rem; font-weight: 560; }
.field input { min-width: 0; border: 1px solid #d7d7d4; border-radius: 8px; padding: 10px; }
.check { display: flex; align-items: flex-start; gap: 7px; font-size: .86rem; line-height: 1.45; }
.sheet .dark-button { justify-self: start; }
.guided-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.guided-title h2 { margin: 0; }
.guided-state, .guided-indicator { font-size: .8rem; color: var(--muted); }
.guided-indicator { display: block; text-align: center; margin-top: 9px; }
.guided-settings details { margin-top: 9px; }
.guided-settings summary { width: fit-content; padding: 6px 0; font-size: .9rem; cursor: pointer; }
.guided-settings form { margin-top: 9px; }
.guided-settings button { justify-self: start; }
.guided-notice { margin: 9px 0 0; font-size: .87rem; color: var(--muted); }
.guided-notice:empty { display: none; }
.summary { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0; }
.summary b { display: block; font-size: 1.35rem; margin-bottom: 2px; }
.summary small { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th, .admin-table td { padding: 10px 7px; border-bottom: 1px solid var(--border); text-align: start; }
.usage-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.student-allowances { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.admin-actions { white-space: nowrap; gap: 4px; }
.invite-result { margin-top: 12px; width: 100%; overflow-wrap: anywhere; }
.invite-result code { user-select: all; }
.external { text-underline-offset: 3px; }
.saved-list { display: grid; }
.saved-row { border: 0; background: transparent; color: inherit; display: flex; justify-content: space-between; gap: 14px; text-align: start; align-items: baseline; padding: 10px 4px; }
.saved-row span { overflow-wrap: anywhere; }
.saved-row time,.local-flag { color: var(--muted); font-size: .78rem; }
.saved-row time { white-space: nowrap; }
.saved-row:hover { background: var(--border); }
.local-flag { display: block; text-align: center; margin-top: 10px; }
#student-editor form + form { margin-top: 15px; }
#student-editor button { justify-self: start; }
#student-editor { padding: 15px 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
#student-editor h3 { font-size: 1rem; margin: 0 0 12px; }
.student-heading,.student-editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.student-heading { justify-content: space-between; margin-bottom: 10px; }
.student-heading h2 { margin: 0; }
.danger { color: #a42620; }
.admin-actions { flex-wrap: wrap; min-width: 8rem; }
dialog .field input { width: 100%; }
dialog { border: 1px solid var(--border); border-radius: 18px; padding: 23px; width: min(405px, calc(100% - 30px)); color: var(--ink); box-shadow: 0 10px 55px #00000012; }
dialog::backdrop { background: #0005; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog-top h2 { font-size: 1.22rem; margin: 0; }
.dialog-form { margin: 17px 0 0; }
.dialog-form p { margin: 0; color: var(--muted); font-size: .86rem; }
.dialog-form .error { color: #272727; min-height: 1.15em; }
.crop-dialog { width: min(560px, calc(100% - 26px)); max-height: calc(100% - 36px); }
.crop-dialog p { color: var(--muted); font-size: .85rem; margin: 8px 0 14px; }
.crop-canvas { display: block; max-width: 100%; max-height: 45dvh; width: auto; height: auto; margin: 0 auto; cursor: crosshair; touch-action: none; }
.crop-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 14px; margin: 12px 0; font-size: .8rem; color: var(--muted); }
.crop-controls input { display: block; width: 100%; accent-color: var(--ink); }
.crop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

@media (max-width: 760px) {
  .shell { display: block; }
  .main { height: 100%; }
  .rail { position: fixed; z-index: 4; inset: 0 auto 0 0; width: min(265px, 78vw); }
  .veil { position: fixed; inset: 0; z-index: 3; background: #0004; border: 0; display: block; }
  .shell.closed .veil { display: none; }
  .topbar { padding: 0 14px; min-height: 57px; }
  .compose-space { padding-inline: 14px; }
  .empty .compose-space { padding-bottom: 36px; }
  .intro { margin-bottom: 25px; }
  .messages { padding-inline: 16px; }
  .sheet { padding-inline: 17px; }
}

@media (max-width: 550px) {
  .starter-grid { grid-template-columns: minmax(0,1fr); gap: 7px; }
  .starter-card { min-height: 59px; padding: 9px 11px; gap: 3px; }
  .message.assistant .lesson-flow { grid-auto-flow: row; gap: 20px; }
  .lesson-flow li + li::before { inset: -15px auto auto 4px; transform: rotate(135deg); }
}

@media (max-width: 630px) {
  .topbar .chat-brand { display: none; }
}

@media (max-width: 360px) {
  .topbar { padding-inline: 10px; gap: 4px; }
  .topbar-group { gap: 4px; }
  .topbar .plain, .topbar .outline-button { padding-inline: 6px; }
  .mode-picker { width: 5.5rem; padding-inline: 5px; }
}

.chat-account-menu{position:relative}
.chat-account-menu summary{list-style:none;cursor:pointer;max-width:145px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-account-menu summary::after{content:" ▾"}
.chat-account-menu>div{position:absolute;z-index:5;top:calc(100% + 5px);right:0;min-width:130px;background:white;border:1px solid #e0e4df;border-radius:9px;padding:4px;display:grid;box-shadow:0 6px 14px #151a1814}
.chat-account-menu button{font:inherit;text-align:start;white-space:nowrap;border:0;background:none;padding:8px 10px;border-radius:5px;cursor:pointer}
.chat-account-menu button:hover{background:#f1f4f1}
