:root {
  color-scheme: light;
  --bg: #f6fafb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #edf3f8;
  --text: #111827;
  --muted: #62748a;
  --subtle: #8ba0b7;
  --border: #d7e1ec;
  --border-strong: #b8c6d6;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --teal: #0f9f9a;
  --teal-deep: #0f766e;
  --green: #15803d;
  --amber: #b7791f;
  --coral: #c2410c;
  --violet: #6d5bd0;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.11);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 270px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 159, 154, 0.08), rgba(246, 250, 251, 0) 320px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.05), rgba(246, 250, 251, 0) 38%),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.noscript,
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  width: min(460px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 28px;
  text-align: center;
}

.product-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  border-right: 1px solid rgba(215, 225, 236, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  padding: 22px;
}

.brand,
.account-panel,
.status-line,
.header-actions,
.panel-title,
.mini-title,
.split-actions,
.composer-row,
.prompt-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(15, 159, 154, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, #1d4ed8 0%, #0f9f9a 54%, #13c2aa 100%);
  color: white;
  box-shadow: var(--shadow-soft);
}

.brand-letter {
  font-size: 1.2rem;
  font-weight: 950;
}

.brand strong {
  display: block;
  font-size: 1rem;
  font-weight: 900;
}

.brand small,
.account-panel small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.nav-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.94rem;
  font-weight: 850;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(15, 159, 154, 0.2);
  background: #e9fbf8;
  color: var(--teal-deep);
}

.sidebar-top,
.sidebar-footer,
.quick-tools {
  display: grid;
  gap: 12px;
}

.workspace-switcher {
  display: grid;
  grid-template-columns: 28px 1fr 18px;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.workspace-switcher strong {
  font-size: 0.86rem;
  font-weight: 900;
}

.workspace-switcher.static {
  cursor: default;
}

.quick-tools {
  align-content: start;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.quick-tools > span {
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.quick-tool {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  padding: 7px 8px;
  text-align: left;
}

.quick-tool strong {
  display: grid;
  gap: 2px;
  font-size: 0.84rem;
  font-weight: 850;
}

.quick-tool strong small,
.action-chip small {
  color: var(--subtle);
  font-size: 0.68rem;
  font-weight: 850;
}

.quick-tool:hover {
  border-color: rgba(15, 159, 154, 0.2);
  background: #f0fdfa;
  color: var(--teal-deep);
}

.quick-tool:disabled,
.quick-tool.is-disabled,
.action-chip:disabled,
.action-chip.is-disabled,
.tool-icon:disabled,
.tool-icon.is-disabled,
.btn:disabled,
.btn.is-disabled,
.icon-btn:disabled,
.icon-btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.quick-tool:disabled:hover,
.quick-tool.is-disabled:hover,
.action-chip:disabled:hover,
.action-chip.is-disabled:hover,
.tool-icon:disabled:hover,
.tool-icon.is-disabled:hover,
.btn:disabled:hover,
.btn.is-disabled:hover,
.icon-btn:disabled:hover,
.icon-btn.is-disabled:hover {
  border-color: var(--border);
  background: inherit;
  color: inherit;
  transform: none;
  box-shadow: none;
}

.account-panel {
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.sidebar-plan {
  display: grid;
  gap: 9px;
  border: 1px solid rgba(15, 159, 154, 0.2);
  border-radius: var(--radius);
  background: #f0fdfa;
  padding: 12px;
}

.sidebar-plan span,
.sidebar-plan strong {
  display: block;
}

.sidebar-plan span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.sidebar-plan strong {
  margin-top: 2px;
  color: var(--teal-deep);
  font-size: 0.88rem;
  font-weight: 950;
}

.quota-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.14);
}

.quota-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.system-status i,
.bot-header i {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(183, 121, 31, 0.15);
}

.system-status i.ok,
.bot-header i.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.14);
}

.system-status strong {
  margin-left: auto;
  color: var(--green);
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: #dbeafe;
  color: var(--blue-deep);
  font-weight: 900;
}

.account-panel div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.account-panel strong {
  display: block;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
}

.main-area {
  min-width: 0;
  padding: 22px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  min-height: 70px;
  margin-bottom: 22px;
}

.app-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 2rem;
  line-height: 1.08;
  font-weight: 950;
}

.app-header p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.notify-btn {
  position: relative;
}

.notify-btn i {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ef4444;
}

.status-line {
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-line span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  padding: 6px 11px;
  white-space: nowrap;
}

.status-line i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(183, 121, 31, 0.15);
}

.status-line i.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.15);
}

.btn,
.chip,
.option,
.text-btn {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  font-size: 0.9rem;
  line-height: 1;
}

.btn.primary {
  border-color: var(--teal);
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: white;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.78);
}

.btn.full {
  width: 100%;
}

.btn.outline {
  border-color: rgba(15, 159, 154, 0.35);
  background: #ffffff;
  color: var(--teal-deep);
}

.btn:hover,
.chip:hover,
.option:hover,
.text-btn:hover,
.icon-btn:hover {
  border-color: var(--blue);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.38fr);
  gap: 22px;
  align-items: start;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.34fr);
  gap: 22px;
  align-items: start;
}

.student-dashboard {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.34fr) minmax(270px, 0.27fr);
  gap: 20px;
  align-items: start;
}

.dashboard-main,
.dashboard-rail,
.overview-rail {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.home-chat-card {
  min-height: auto;
}

.unit-overview-panel {
  overflow: hidden;
}

.help-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(15, 159, 154, 0.26);
  border-radius: 999px;
  background: #ffffff;
  color: var(--teal-deep);
  box-shadow: var(--shadow-soft);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 900;
}

.hero-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(15, 159, 154, 0.12) 46%, rgba(255, 255, 255, 0.96) 47%),
    #ffffff;
  box-shadow: var(--shadow);
  padding: 26px;
}

.hero-copy {
  align-self: center;
}

.hero-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(15, 159, 154, 0.26);
  border-radius: var(--radius);
  background: #ecfeff;
  color: var(--teal);
}

.hero-copy h2 {
  max-width: 780px;
  margin: 16px 0 10px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.02;
  font-weight: 950;
}

.hero-copy p {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: center;
}

.unit-strip,
.unit-card-grid,
.rag-results {
  display: grid;
  gap: 12px;
}

.unit-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 20px;
}

.unit-mini {
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 13px;
  text-align: left;
}

.unit-mini strong,
.unit-mini span {
  display: block;
}

.unit-mini strong {
  font-size: 0.95rem;
  font-weight: 950;
}

.unit-mini span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.unit-mini.active,
.unit-detail.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: #eff6ff;
}

.unit-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px;
}

.unit-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 16px;
}

.unit-select {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.unit-select span,
.unit-meta span,
.rag-row span {
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.unit-select strong {
  font-size: 1.08rem;
  line-height: 1.35;
  font-weight: 950;
}

.unit-detail p {
  min-height: 58px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.unit-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 5px 9px;
}

.video-list {
  display: grid;
  gap: 8px;
}

.video-more,
.library-more {
  border: 1px dashed rgba(37, 99, 235, 0.26);
  border-radius: var(--radius-sm);
  background: #f8fbff;
  padding: 8px 10px;
}

.video-more summary,
.library-more summary {
  cursor: pointer;
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 950;
}

.video-list-more,
.library-more-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.library-more {
  grid-column: 1 / -1;
}

.library-more-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.video-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 10px;
  text-decoration: none;
}

.video-row strong {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.rag-search {
  display: grid;
  grid-template-columns: minmax(160px, 0.28fr) minmax(0, 1fr) auto;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding: 16px 20px;
}

.rag-search select,
.rag-search input {
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  padding: 9px 11px;
}

.rag-results {
  padding: 16px 20px 0;
}

.rag-row {
  border: 1px solid rgba(15, 159, 154, 0.25);
  border-radius: var(--radius);
  background: #f0fdfa;
  padding: 14px;
}

.rag-row strong {
  display: block;
  margin-top: 5px;
  font-size: 0.98rem;
}

.rag-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.inline-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 900;
  text-decoration: none;
}

.panel,
.conversation-panel,
.rail-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.panel,
.conversation-panel {
  min-width: 0;
}

.panel-title {
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
}

.panel-title h2,
.rail-panel h3,
.mini-title h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 950;
}

.panel-title p,
.rail-panel p,
.question-card p,
.library-card p,
.admin-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto auto auto;
  min-height: calc(100vh - 124px);
  overflow: hidden;
}

.chat-layout > .conversation-panel {
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  height: clamp(560px, calc(100vh - 178px), 780px);
  min-height: 0;
}

.bot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
}

.bot-avatar,
.message-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: #e9fbf8;
  color: var(--teal-deep);
}

.bot-avatar {
  width: 42px;
  height: 42px;
}

.message-avatar {
  width: 30px;
  height: 30px;
  margin-top: 22px;
}

.bot-header h2 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 950;
}

.bot-header p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.bot-header .session-chip {
  margin-left: auto;
}

.session-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 850;
}

.messages {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(241, 245, 249, 0.65), rgba(255, 255, 255, 0.9)),
    var(--surface);
}

.compact-messages {
  min-height: 270px;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 78%;
}

.message.user {
  justify-self: end;
  justify-content: flex-end;
}

.message-label {
  margin: 0 0 6px;
  color: var(--subtle);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.message.user .message-label {
  text-align: right;
}

.bubble {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 13px 15px;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.7;
  white-space: pre-line;
}

.message.user .bubble {
  border-color: rgba(15, 159, 154, 0.28);
  background: #dffaf5;
  color: #083f3d;
}

.composer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding: 16px 20px 20px;
}

.composer.compact {
  border-top: 0;
}

.composer > small {
  display: block;
  margin-top: 8px;
  color: var(--subtle);
  font-size: 0.76rem;
  line-height: 1.45;
}

.prompt-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  min-height: 34px;
  padding: 7px 12px;
  background: #f8fafc;
  font-size: 0.84rem;
  line-height: 1.25;
}

.action-chip-row,
.suggestion-block {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 12px 18px;
}

.action-chip-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.action-chip {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 60px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--teal-deep);
  padding: 8px;
  font-size: 0.78rem;
  font-weight: 900;
}

.action-chip span {
  display: grid;
  gap: 2px;
  text-align: center;
}

.chat-layout .action-chip-row {
  padding: 10px 18px;
}

.chat-layout .action-chip {
  min-height: 52px;
  padding: 6px;
}

.suggestion-block {
  display: grid;
  gap: 8px;
}

.suggestion-block > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
}

.suggestion-block > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-layout .suggestion-block {
  gap: 6px;
  padding: 10px 18px;
}

.chat-layout .suggestion-block > div,
.chat-layout .prompt-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chat-layout .suggestion-pill,
.chat-layout .prompt-row .chip {
  flex: 0 0 auto;
  white-space: nowrap;
}

.suggestion-pill {
  min-height: 32px;
  border: 1px solid rgba(15, 159, 154, 0.22);
  border-radius: 999px;
  background: #f0fdfa;
  color: var(--teal-deep);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 850;
}

.composer-tool-row {
  display: flex;
  gap: 7px;
  margin-bottom: 10px;
}

.chat-layout .composer {
  padding: 10px 18px 12px;
}

.chat-layout .composer-tool-row {
  margin-bottom: 8px;
}

.chat-layout textarea {
  min-height: 62px;
}

.tool-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--muted);
}

.composer-row {
  gap: 10px;
  align-items: stretch;
}

textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 13px;
  color: var(--text);
  background: #ffffff;
  font-size: 0.95rem;
  line-height: 1.55;
}

.send-btn {
  min-width: 96px;
}

.learning-rail,
.question-stack,
.library-grid,
.admin-grid,
.timeline {
  display: grid;
  gap: 14px;
}

.rail-panel {
  padding: 18px;
}

.rail-panel.accent {
  border-color: rgba(15, 159, 154, 0.25);
  background:
    linear-gradient(135deg, rgba(15, 159, 154, 0.1), rgba(255, 255, 255, 0) 48%),
    #ffffff;
}

.rail-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.mini-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.text-btn {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--blue);
  background: #ffffff;
  font-size: 0.8rem;
}

.plan-list {
  display: grid;
  gap: 10px;
}

.plan-list div {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-soft);
}

.plan-list b {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #dbeafe;
  color: var(--blue-deep);
}

.plan-list span,
.resource-row span,
.empty-row {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.task-progress-list,
.document-list,
.reminder-list {
  display: grid;
  gap: 10px;
}

.task-progress-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 11px;
}

.task-progress-list b {
  font-size: 0.88rem;
}

.task-progress-list span {
  color: var(--teal-deep);
  font-size: 0.8rem;
  font-weight: 950;
}

.task-progress-list i {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--teal) var(--value), rgba(15, 159, 154, 0.14) var(--value));
}

.mini-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.mini-metrics.vertical {
  grid-template-columns: 1fr;
}

.metric {
  min-height: 88px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 13px;
}

.metric strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.05;
  font-weight: 950;
}

.metric span,
.metric small {
  display: block;
}

.metric span {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 850;
}

.metric small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.metric.blue strong { color: var(--blue); }
.metric.green strong { color: var(--green); }
.metric.teal strong { color: var(--teal); }
.metric.amber strong { color: var(--amber); }

.resource-list {
  display: grid;
  gap: 10px;
}

.resource-row,
.empty-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 11px;
}

.resource-row strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.35;
}

.practice-recommendations,
.practice-inline-recommendations .rail-panel {
  display: grid;
  gap: 12px;
}

.practice-inline-recommendations {
  padding: 0 20px;
}

.recommend-card {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 11px;
}

.recommend-card > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #e9fbf8;
  color: var(--teal-deep);
}

.recommend-card strong,
.document-row strong,
.settings-row strong,
.provider-row strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.35;
}

.recommend-card small,
.document-row small,
.settings-row small,
.provider-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.recommend-card b,
.document-row b,
.settings-row b,
.provider-row b {
  border-radius: 999px;
  background: #ecfeff;
  color: var(--teal-deep);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 950;
  white-space: nowrap;
}

.recommend-card button {
  grid-column: 2 / -1;
  justify-self: start;
  border: 1px solid rgba(15, 159, 154, 0.32);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--teal-deep);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.document-row,
.provider-row,
.settings-row,
.reminder-list div {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.document-row > span,
.provider-row > span,
.settings-row > span,
.reminder-list div > svg {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--teal-deep);
}

.reminder-list div {
  grid-template-columns: 32px 1fr;
}

.reminder-list strong {
  display: block;
  font-size: 0.88rem;
}

.reminder-list small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.question-stack {
  padding: 20px;
}

.question-card,
.library-card,
.admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 16px;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(15, 159, 154, 0.24);
  border-radius: 999px;
  background: #ecfeff;
  color: var(--teal-deep);
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 950;
}

.question-card h3,
.library-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 900;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.question-media,
.solution-media {
  margin: 14px 0 0;
}

.question-media {
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 12px;
}

.question-media img,
.solution-media img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
}

.solution-media {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px 12px;
}

.solution-media summary {
  cursor: pointer;
  color: var(--blue-deep);
  font-weight: 900;
}

.solution-media img {
  margin-top: 10px;
}

.option {
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  line-height: 1.4;
  background: var(--surface-soft);
}

.manual-check-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  min-height: 42px;
  padding: 10px 14px;
  border-color: rgba(15, 159, 154, 0.28);
  background: #e9fbf7;
  color: var(--teal-deep);
  font-weight: 900;
}

.manual-check-note svg {
  width: 18px;
  height: 18px;
}

.option.selected {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue-deep);
}

.answer-gate,
.explanation-text {
  margin: 12px 0 0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.55;
}

.answer-gate {
  border: 1px dashed rgba(100, 116, 139, 0.35);
  background: #f8fafc;
  color: var(--muted);
}

.explanation-text {
  border: 1px solid rgba(15, 159, 154, 0.18);
  background: #ecfdf5;
  color: var(--text);
}

.score-block {
  display: grid;
  place-items: center;
  min-height: 126px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius);
  background: #eef5ff;
  text-align: center;
}

.score-block strong {
  display: block;
  color: var(--blue-deep);
  font-size: 2.4rem;
  line-height: 1;
  font-weight: 950;
}

.score-block span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 850;
}

.library-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px;
}

.library-card span,
.admin-card span {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.library-card.dataset {
  border-color: rgba(15, 159, 154, 0.24);
  background:
    linear-gradient(135deg, rgba(15, 159, 154, 0.08), rgba(255, 255, 255, 0) 48%),
    #ffffff;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.timeline {
  padding: 0 20px 20px;
}

.timeline div {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
}

.timeline b {
  color: var(--blue-deep);
}

.timeline span {
  color: var(--muted);
  line-height: 1.55;
}

.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
}

.settings-card,
.overview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.settings-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.settings-card h3,
.overview-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 950;
}

.student-scope-note {
  display: grid;
  gap: 5px;
  margin: 0 20px 20px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius);
  background: #f8fbff;
  padding: 14px 16px;
}

.student-scope-note strong {
  color: var(--blue-deep);
  font-size: 0.9rem;
  font-weight: 950;
}

.student-scope-note span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.overview-card > span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.overview-metrics {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.overview-metrics .metric {
  min-height: 74px;
}

.week-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 128px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px 12px 10px;
}

.week-chart div {
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 7px;
  height: 100%;
}

.week-chart i {
  width: 100%;
  min-height: 16px;
  border-radius: 999px 999px 3px 3px;
  background: rgba(15, 159, 154, 0.42);
}

.week-chart .active i {
  background: var(--blue);
}

.week-chart span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.account-status-card {
  display: grid;
  gap: 10px;
}

.advanced-status {
  margin: 0 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.advanced-status summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 950;
}

.advanced-status .admin-grid {
  padding-top: 0;
}

.admin-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.2rem;
  line-height: 1.25;
  font-weight: 950;
}

.oauth-box {
  margin: 0 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 18px;
}

.oauth-box h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 950;
}

.split-actions {
  gap: 10px;
  margin-top: 14px;
}

.notice {
  margin-top: 14px;
  border: 1px solid #f0d8a8;
  border-radius: var(--radius);
  background: #fff7ed;
  color: #7c4a03;
  padding: 12px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.55;
}

.auth-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.1), rgba(255, 255, 255, 0.94));
  box-shadow: var(--shadow-soft);
}

.auth-gate strong,
.auth-gate span {
  display: block;
}

.auth-gate strong {
  font-size: 1rem;
  font-weight: 950;
}

.auth-gate span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.6;
}

code {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  padding: 12px;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: #ffffff;
  padding: 22px;
  text-align: center;
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  border: 1px solid rgba(21, 128, 61, 0.25);
  border-radius: var(--radius);
  background: #ecfdf5;
  color: #14532d;
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.45;
}

.toast.error {
  border-color: rgba(194, 65, 12, 0.25);
  background: #fff7ed;
  color: #7c2d12;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .product-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    grid-template-columns: 1fr;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .quick-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .account-panel {
    max-width: 420px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .home-grid,
  .student-dashboard,
  .hero-panel,
  .unit-strip,
  .unit-card-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .sidebar,
  .main-area {
    padding: 16px;
  }

  .app-header,
  .header-actions,
  .status-line,
  .panel-title,
  .composer-row,
  .split-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header h1 {
    font-size: 1.62rem;
  }

  .header-actions,
  .status-line,
  .btn,
  .account-panel,
  .split-actions .btn {
    width: 100%;
  }

  .status-line span,
  .send-btn {
    width: 100%;
  }

  .conversation-panel {
    min-height: 680px;
  }

  .chat-layout > .conversation-panel {
    height: calc(100vh - 96px);
    min-height: 620px;
    max-height: none;
  }

  .messages {
    min-height: 280px;
    padding: 16px;
  }

  .message {
    max-width: 100%;
  }

  .prompt-row,
  .action-chip-row,
  .option-grid,
  .library-grid,
  .library-more-grid,
  .metrics-grid,
  .admin-grid,
  .settings-grid,
  .mini-metrics,
  .hero-board,
  .rag-search {
    grid-template-columns: 1fr;
  }

  .quick-tools,
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .quick-tools {
    display: grid;
  }

  .topbar-actions,
  .action-chip-row {
    width: 100%;
  }

  .question-stack,
  .library-grid,
  .metrics-grid,
  .admin-grid,
  .settings-grid {
    padding: 16px;
  }

  .oauth-box,
  .timeline {
    margin: 0;
    padding: 0 16px 16px;
  }

  .timeline div {
    grid-template-columns: 1fr;
  }
}
