:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #81857e;
  --line: #e8e9e4;
  --paper: #f7f8f5;
  --white: #fff;
  --green: #237b55;
  --green-light: #e8f4ec;
  --orange: #e38b55;
  --mono: "DM Mono", monospace;
  --sans: "DM Sans", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 14px; }
button, textarea { font: inherit; }
button { color: inherit; }
.app-shell { max-width: 1240px; margin: 0 auto; padding: 0 42px; }
.topbar { height: 74px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.brand-mark { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; background: var(--ink); color: #d7edbc; font-size: 17px; }
.brand-copy { display: grid; gap: 3px; }
.student-info { color: var(--muted); font-size: 10px; letter-spacing: 0; }
.brand-divider { color: #b7bab3; }
.api-key-card form[hidden] { display: none; }
.topbar-right { display: flex; gap: 22px; align-items: center; }
.course-tag, .section-kicker, footer, .trace-count { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .09em; }
.course-tag span { color: var(--orange); }
.status-pill { display: flex; gap: 7px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--white); color: #696e66; font-size: 10px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #d5a252; }
.status-pill.is-ready .status-dot { background: #38a675; }
.status-pill.is-error .status-dot { background: #d66b55; }
.intro { padding: 53px 0 28px; }
.eyebrow { display: flex; gap: 9px; align-items: center; color: var(--green); font-size: 11px; font-weight: 600; }
.eyebrow-line { width: 19px; height: 1px; background: var(--green); }
h1 { margin: 13px 0 7px; font-size: clamp(36px, 5vw, 55px); line-height: 1.1; letter-spacing: -.06em; }
.title-arrow { color: var(--orange); font-weight: 400; }
.intro > p { margin: 0; color: #70756d; font-size: 13px; line-height: 1.8; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 13px; background: #eff0ec; }
.mode-tab { display: flex; gap: 13px; align-items: center; min-height: 67px; padding: 10px 16px; border: 1px solid transparent; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.mode-tab:hover { background: #ffffff9c; }
.mode-tab.is-active { border-color: #e6e9e2; background: var(--white); box-shadow: 0 2px 6px #20231f08; }
.tab-number { align-self: flex-start; padding-top: 3px; color: #a7aaa3; font: 10px var(--mono); }
.mode-tab strong, .mode-tab small { display: block; }
.mode-tab strong { font-size: 12px; font-weight: 600; }
.mode-tab small { margin-top: 4px; color: #8a8e87; font-size: 10px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 17px; margin-top: 16px; align-items: start; }
.chat-card, .inspector-card { border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.chat-card { display: flex; min-height: 570px; flex-direction: column; padding: 22px 24px 17px; }
.chat-heading, .trace-heading { display: flex; align-items: center; justify-content: space-between; }
.chat-heading h2 { margin: 4px 0 0; font-size: 16px; letter-spacing: -.02em; }
.clear-button { padding: 6px 0 6px 8px; border: 0; background: transparent; color: #878b83; font-size: 10px; cursor: pointer; }
.clear-button span { margin-left: 4px; color: var(--orange); }
.mode-explainer { margin-top: 16px; padding: 10px 12px; border-radius: 7px; background: #f5f7f3; color: #72786f; font-size: 11px; line-height: 1.7; }
.messages { display: flex; min-height: 340px; flex: 1; flex-direction: column; gap: 13px; padding: 20px 2px 16px; overflow-y: auto; }
.welcome-card { display: flex; flex: 1; flex-direction: column; justify-content: center; align-items: center; padding: 20px 0; text-align: center; }
.welcome-icon { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #e8eee5; border-radius: 12px; color: var(--green); font-size: 18px; }
.welcome-card > p { max-width: 310px; margin: 12px 0 17px; color: #858980; font-size: 11px; line-height: 1.8; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.suggestion { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: white; color: #656a62; font-size: 9px; cursor: pointer; }
.suggestion:hover { border-color: #a9cbb5; color: var(--green); }
.message { display: flex; gap: 9px; align-items: flex-start; }
.message-avatar { display: grid; width: 25px; height: 25px; flex: 0 0 25px; place-items: center; border-radius: 8px; background: #eff1ed; color: #63685f; font-size: 10px; }
.message.assistant .message-avatar { background: var(--green-light); color: var(--green); }
.message-content { max-width: min(84%, 540px); padding: 9px 11px; border-radius: 3px 9px 9px; background: #f5f6f3; color: #373b35; font-size: 12px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { flex-direction: row-reverse; }
.message.user .message-avatar { background: #f8eee6; color: #a36840; }
.message.user .message-content { border-radius: 9px 3px 9px 9px; background: #f7f3ee; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 9px; border: 1px solid #e5e8e1; border-radius: 9px; background: #fcfcfb; }
.composer:focus-within { border-color: #a6c8b2; box-shadow: 0 0 0 3px #e8f4ec; }
.composer textarea { width: 100%; max-height: 130px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; line-height: 1.65; }
.composer textarea::placeholder { color: #a2a59e; }
.send-button { display: grid; width: 29px; height: 29px; flex: 0 0 29px; place-items: center; border: 0; border-radius: 7px; background: var(--ink); color: white; font-size: 17px; cursor: pointer; }
.send-button:disabled { opacity: .45; cursor: wait; }
.composer-foot { display: flex; justify-content: space-between; margin-top: 8px; color: #a0a39d; font: 9px var(--mono); }
.foot-divider { color: var(--orange); }
.error-message { margin: 10px 0 0; padding: 10px 12px; border: 1px solid #f1d8ce; border-radius: 7px; background: #fff8f4; color: #a34f36; font-size: 11px; line-height: 1.7; }
.inspector { display: flex; flex-direction: column; gap: 12px; }
.inspector-card { padding: 17px 17px 16px; }
.inspector-card h3 { margin: 5px 0 7px; font-size: 13px; }
.concept-card > p { min-height: 56px; margin: 0; color: #7f847b; font-size: 10px; line-height: 1.75; }
.flow-diagram { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 15px; }
.flow-node { padding: 6px 7px; border: 1px solid #e8eae5; border-radius: 5px; color: #62675f; font: 9px var(--mono); }
.flow-node.is-highlight { border-color: #c9e2d1; background: #f0f8f2; color: var(--green); }
.flow-arrow { color: #b2b5ae; font-size: 10px; }
.trace-heading h3 { margin-bottom: 0; }
.trace-count { font-size: 8px; }
.trace-content { margin-top: 13px; }
.trace-empty { display: flex; gap: 9px; align-items: flex-start; padding: 10px 0 2px; color: #9a9e97; }
.trace-empty > span { color: #b7c8b8; font-size: 15px; }
.trace-empty p { margin: 1px 0 0; font-size: 10px; line-height: 1.75; }
.trace-step { position: relative; margin-left: 5px; padding: 0 0 15px 16px; border-left: 1px solid #e5e9e2; }
.trace-step:last-child { padding-bottom: 0; border-left-color: transparent; }
.trace-step::before { position: absolute; top: 2px; left: -4px; width: 7px; height: 7px; border: 1px solid #82b493; border-radius: 50%; background: white; content: ""; }
.trace-step strong { display: block; color: #444a42; font-size: 10px; font-weight: 600; }
.trace-detail { margin-top: 5px; padding: 7px 8px; border-radius: 5px; background: #f5f7f3; color: #70766c; font: 9px/1.65 var(--mono); overflow-wrap: anywhere; white-space: pre-wrap; }
.trace-result { margin-top: 4px; color: var(--green); font: 9px/1.6 var(--mono); overflow-wrap: anywhere; }
.privacy-note { display: flex; gap: 9px; align-items: flex-start; padding: 12px; border: 1px solid #e6ede7; border-radius: 9px; background: #f0f5ef; color: var(--green); }
.privacy-note > span { font-size: 14px; }
.privacy-note p { margin: 0; color: #7d877c; font-size: 9px; line-height: 1.8; }
.privacy-note strong { color: #3c674c; font-weight: 600; }
.api-key-card > p { margin: 0 0 12px; color: #7f847b; font-size: 10px; line-height: 1.75; }
.api-key-card form { display: flex; flex-direction: column; gap: 7px; }
.api-key-card input { width: 100%; padding: 9px 10px; border: 1px solid #e5e8e1; border-radius: 6px; outline: 0; background: #fcfcfb; font: 10px var(--mono); }
.api-key-card input:focus { border-color: #a6c8b2; box-shadow: 0 0 0 3px #e8f4ec; }
.api-key-card button { padding: 8px 10px; border: 0; border-radius: 6px; background: var(--ink); color: white; font-size: 10px; cursor: pointer; }
.api-key-card button:disabled { opacity: .55; cursor: wait; }
.key-feedback { margin-top: 9px; color: var(--green); font-size: 10px; line-height: 1.7; }
.key-feedback.is-error { color: #a34f36; }
footer { display: flex; justify-content: space-between; padding: 26px 0 22px; font-size: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .app-shell { padding: 0 22px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 255px; }
}
@media (max-width: 650px) {
  .app-shell { padding: 0 15px; }
  .topbar { height: 61px; }
  .course-tag { display: none; }
  .intro { padding: 38px 0 22px; }
  .intro > p { max-width: 420px; }
  .mode-tabs { grid-template-columns: 1fr; gap: 3px; }
  .mode-tab { min-height: 55px; }
  .workspace { grid-template-columns: 1fr; }
  .chat-card { min-height: 535px; padding: 18px 16px 14px; }
  .messages { min-height: 290px; }
  .inspector { display: grid; grid-template-columns: 1fr; }
  footer { gap: 10px; flex-wrap: wrap; }
}
