:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #151a28;
  --muted: #687386;
  --line: #dde3ee;
  --blue: #2f5bea;
  --blue-soft: #eef2ff;
  --green-soft: #eaf7ef;
  --violet-soft: #f2ecfb;
  --amber-soft: #f8f2df;
  --red: #d73737;
  --shadow: 0 16px 42px rgba(23, 31, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  white-space: nowrap;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 4px 12px;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-weight: 800;
}

.brand p,
.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.brand h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill,
.metric-pill,
.pill-link,
.pill-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.pill-button {
  font-weight: 800;
}

.status-pill.ready {
  color: #067647;
  border-color: rgba(6, 118, 71, 0.24);
}

.status-pill.error {
  color: var(--red);
  border-color: rgba(215, 55, 55, 0.24);
}

.notebook-layout {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(420px, 1fr) minmax(280px, 360px);
  gap: 14px;
  height: calc(100vh - 82px);
  transition: grid-template-columns 0.2s ease;
}

.app-shell.sources-collapsed .notebook-layout {
  grid-template-columns: 54px minmax(420px, 1fr) minmax(280px, 360px);
}

.app-shell.studio-collapsed .notebook-layout {
  grid-template-columns: minmax(270px, 360px) minmax(420px, 1fr) 54px;
}

.app-shell.sources-collapsed.studio-collapsed .notebook-layout {
  grid-template-columns: 54px minmax(420px, 1fr) 54px;
}

.home-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.home-head {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.notebook-create {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(460px, 100%);
}

.notebook-create input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  outline: none;
}

.notebook-create input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.12);
}

.notebook-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 18px;
}

.notebook-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.notebook-card.active {
  border-color: rgba(47, 91, 234, 0.5);
  background: #f6f8ff;
}

.notebook-open {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.notebook-icon {
  width: 34px;
  height: 34px;
  grid-row: span 2;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.notebook-open strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.notebook-open span:not(.notebook-icon),
.notebook-open small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.notebook-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.notebook-card-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sources-panel,
.chat-panel,
.studio-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sources-panel,
.studio-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.studio-panel {
  overflow: auto;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.panel-title,
.chat-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title.small {
  min-height: auto;
  padding: 0 0 10px;
  border-bottom: 0;
}

.panel-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.collapse-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
}

.collapse-button:hover,
.icon-button:hover,
.secondary-button:hover {
  border-color: #c6d0e3;
  background: #f8faff;
}

.app-shell.sources-collapsed .sources-panel > :not(.panel-title),
.app-shell.studio-collapsed .studio-panel > :not(.panel-title) {
  display: none;
}

.app-shell.sources-collapsed .sources-panel .panel-title,
.app-shell.studio-collapsed .studio-panel .panel-title {
  min-height: 100%;
  flex-direction: column;
  justify-content: start;
  padding: 12px 8px;
  border-bottom: 0;
}

.app-shell.sources-collapsed .sources-panel .panel-title h2,
.app-shell.studio-collapsed .studio-panel .panel-title h2 {
  writing-mode: vertical-rl;
  font-size: 14px;
}

.app-shell.sources-collapsed #refreshBtn,
.app-shell.studio-collapsed #lastUpdated {
  display: none;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  font-size: 17px;
}

.upload-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px 18px 10px;
}

.source-upload {
  min-height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.source-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.source-upload span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-primary,
.send-button {
  border: 0;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 800;
}

.mini-primary {
  min-height: 40px;
  min-width: 72px;
  padding: 0 16px;
  font-size: 14px;
}

.compact-check {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-search {
  padding: 0 18px 12px;
}

.source-search input,
.ask-controls input[type="number"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

.source-search input:focus,
.ask-controls input[type="number"]:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.12);
}

.source-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
}

.select-all,
.source-check,
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.source-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.source-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.source-item:hover,
.source-item.selected {
  border-color: #cfd8eb;
  background: #f8faff;
}

.source-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #fff1f1;
  color: #e03131;
  font-size: 12px;
  font-weight: 900;
}

.source-main {
  min-width: 0;
}

.source-pick {
  display: grid;
  place-items: center;
  min-height: 28px;
}

.source-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.source-main span,
.result-meta,
.composer-foot,
.studio-card span {
  color: var(--muted);
  font-size: 13px;
}

.source-delete-button {
  min-height: 28px;
  align-self: center;
  border: 1px solid rgba(215, 55, 55, 0.2);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff7f7;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.source-delete-button:hover {
  border-color: rgba(215, 55, 55, 0.38);
  background: #fff0f0;
}

.source-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
}

.reset-options {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.secondary-button,
.danger-button {
  min-height: 38px;
  border-radius: 999px;
  padding: 8px 13px;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(215, 55, 55, 0.22);
  color: var(--red);
  background: #fff7f7;
}

.ask-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.ask-controls label:not(.switch) {
  display: grid;
  gap: 5px;
  min-width: 78px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ask-controls label.disabled {
  opacity: 0.58;
}

.mode-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 3px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: #fff;
}

.mode-segment label {
  min-width: 0 !important;
  display: block !important;
  color: var(--muted) !important;
  font-size: 13px !important;
  font-weight: 800 !important;
}

.mode-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-segment span {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}

.mode-segment input:checked + span {
  background: #111827;
  color: #fff;
}

.switch {
  display: inline-flex;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.switch input:disabled {
  cursor: default;
}

.switch.disabled {
  opacity: 0.65;
}

.chat-history {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 24px 20px;
  background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}

.assistant-message,
.user-message {
  max-width: min(760px, 92%);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.72;
}

.assistant-message {
  justify-self: start;
  border: 1px solid #d7eadf;
  background: #f5fbf7;
}

.user-message {
  justify-self: end;
  background: #edf1ff;
  white-space: pre-wrap;
}

.assistant-message strong {
  display: block;
  margin-bottom: 6px;
}

.message-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.message-head strong {
  margin-bottom: 0;
}

.answer-tag {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfd8eb;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.assistant-message.error {
  border-color: rgba(215, 55, 55, 0.28);
  background: #fff7f7;
  color: #981b1b;
}

.message-body {
  color: #233047;
  font-size: 14px;
  line-height: 1.72;
}

.message-body p,
.message-body ul,
.message-body ol,
.message-body blockquote,
.message-body pre {
  margin: 8px 0 0;
}

.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5 {
  margin: 12px 0 6px;
  color: var(--text);
  line-height: 1.35;
}

.message-body h2 {
  font-size: 17px;
}

.message-body h3,
.message-body h4,
.message-body h5 {
  font-size: 15px;
}

.message-body ul,
.message-body ol {
  padding-left: 20px;
}

.message-body li {
  margin: 4px 0;
}

.message-body blockquote {
  border-left: 3px solid #cfd8eb;
  padding-left: 10px;
  color: var(--muted);
}

.message-body code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #eef2ff;
  color: #1f2a44;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 0.95em;
}

.message-body pre {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.message-body pre code {
  padding: 0;
  background: transparent;
}

.composer {
  margin: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 0;
  padding: 14px 16px;
  color: var(--text);
  background: transparent;
  outline: none;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid #eef1f6;
}

.composer-foot span {
  margin-right: auto;
}

.send-button {
  width: 42px;
  height: 42px;
  font-size: 22px;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 18px;
}

.studio-card {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 13px;
}

.studio-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.studio-card.blue {
  background: var(--blue-soft);
}

.studio-card.green {
  background: var(--green-soft);
}

.studio-card.violet {
  background: var(--violet-soft);
}

.studio-card.amber {
  background: var(--amber-soft);
}

.scope-panel,
.cross-reference-panel,
.results-panel,
.history-panel,
.llm-panel {
  padding: 0 18px 18px;
}

.llm-panel {
  border-top: 1px solid var(--line);
}

.history-panel {
  border-top: 1px solid var(--line);
}

.cross-reference-panel {
  border-top: 1px solid var(--line);
}

.llm-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.llm-badge.ready {
  border-color: rgba(6, 118, 71, 0.24);
  background: #f0fbf5;
  color: #067647;
}

.llm-badge.error {
  border-color: rgba(215, 55, 55, 0.24);
  background: #fff7f7;
  color: var(--red);
}

.llm-form {
  display: grid;
  gap: 10px;
}

.llm-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.llm-form input[type="text"],
.llm-form input[type="password"],
.llm-form input[type="url"],
.llm-form input[type="number"],
.llm-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.llm-form input:focus,
.llm-form select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.12);
}

.toggle-line {
  min-height: 32px;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  font-size: 13px !important;
}

.llm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.llm-actions .danger-button {
  grid-column: 1 / -1;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.result-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.cross-summary {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: #374151;
  font-size: 13px;
  line-height: 1.55;
}

.cross-summary strong,
.cross-analysis strong {
  color: var(--text);
  font-size: 13px;
}

.cross-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cross-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}

.cross-table th,
.cross-table td {
  border-bottom: 1px solid #eef1f6;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
}

.cross-table th {
  color: var(--muted);
  background: #fbfcff;
  font-size: 12px;
  font-weight: 900;
}

.cross-table tr:last-child td {
  border-bottom: 0;
}

.cross-table td:first-child {
  width: 24%;
}

.cross-table td strong {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cross-table td span {
  color: var(--muted);
  font-size: 12px;
}

.cross-analysis {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  color: #374151;
  font-size: 13px;
  line-height: 1.55;
}

.cross-analysis ul {
  margin: 5px 0 0;
  padding-left: 18px;
}

.mini-actions {
  display: inline-flex;
  gap: 6px;
}

.mini-actions button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-list {
  display: grid;
  gap: 9px;
  max-height: 260px;
  overflow: auto;
}

.conversation-search {
  padding-bottom: 10px;
}

.conversation-search input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.conversation-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.12);
}

.compact-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.conversation-item.active {
  border-color: #cfd8eb;
  background: #f6f8ff;
}

.conversation-open {
  width: 100%;
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.compact-item strong,
.compact-item p {
  overflow-wrap: anywhere;
}

.compact-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.compact-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-item p {
  margin-top: 7px;
  color: #374151;
  font-size: 12px;
  line-height: 1.5;
}

.compact-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.compact-actions button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.compact-actions button:hover {
  border-color: #cfd8eb;
  background: #eef3ff;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.result-item strong {
  display: block;
  overflow-wrap: anywhere;
  margin-bottom: 5px;
}

.result-title {
  margin-top: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.result-text {
  margin-top: 9px;
  color: #374151;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.empty-text {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  display: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  line-height: 1.5;
}

.toast.show {
  display: block;
}

.guide-open {
  overflow: hidden;
}

.usage-guide-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.38);
}

.usage-guide-modal.show {
  display: grid;
}

.usage-guide-card {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
}

.usage-guide-head,
.usage-guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
}

.usage-guide-head {
  border-bottom: 1px solid var(--line);
}

.usage-guide-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: #fbfcff;
}

.guide-close-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.guide-close-button:hover {
  border-color: #c6d0e3;
  background: #f8faff;
  color: var(--text);
}

.usage-guide-body {
  overflow: auto;
  padding: 18px 20px 20px;
}

.guide-intro,
.guide-note {
  color: #374151;
  line-height: 1.7;
}

.guide-steps {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.guide-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfcff;
}

.guide-step > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-weight: 900;
}

.guide-step strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.guide-step p {
  color: var(--muted);
  line-height: 1.6;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

@media (max-width: 1180px) {
  .notebook-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    height: auto;
  }

  .app-shell.sources-collapsed .notebook-layout {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .app-shell.studio-collapsed .notebook-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .app-shell.sources-collapsed.studio-collapsed .notebook-layout {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .studio-panel {
    grid-column: 1 / -1;
  }

  .app-shell.studio-collapsed .studio-panel {
    min-height: 54px;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .home-head,
  .notebook-create,
  .notebook-layout,
  .chat-head,
  .ask-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: start;
  }

  .brand h1 {
    white-space: normal;
  }

  .sources-panel,
  .chat-panel,
  .studio-panel {
    min-height: auto;
  }

  .usage-guide-modal {
    padding: 10px;
  }

  .usage-guide-head,
  .usage-guide-foot,
  .usage-guide-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .source-list,
  .result-list,
  .chat-history {
    max-height: none;
  }
}
