:root {
  --primary: #5a23ce;
  --primary-dark: #351590;
  --primary-blue: #0f86c5;
  --primary-soft: #eee9ff;
  --amber: #f59e0b;
  --ink: #28263d;
  --muted: #6f7288;
  --line: #d9dcf6;
  --surface: #ffffff;
  --surface-soft: #f7f7ff;
  --page: #eef1ff;
  --danger: #b42318;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 10px 28px rgba(67, 42, 161, 0.12);
  --main-gradient: linear-gradient(135deg, #5a23ce 0%, #3d35ce 50%, #0f86c5 100%);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(90, 35, 206, .08), transparent 26%),
    radial-gradient(circle at 100% 18%, rgba(15, 134, 197, .09), transparent 28%),
    var(--page);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
button, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { display: block; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.site-header {
  background: var(--main-gradient);
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  padding: 25px 20px;
  box-shadow: 0 12px 30px rgba(61, 44, 170, .22);
}
.header-inner {
  width: min(1280px, 100%);
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.header-copy { min-width: 0; }
.eyebrow-light {
  margin: 0 0 7px;
  color: #f7d770;
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .14em;
}
.header-inner h1 {
  margin: 0 0 7px;
  color: #fff;
  font: 700 clamp(1.45rem, 3vw, 2.2rem)/1.2 "Lora", Georgia, serif;
  letter-spacing: -.025em;
}
.header-description {
  max-width: 780px;
  margin: 0;
  color: rgba(255, 255, 255, .9);
  font-size: clamp(.78rem, 1.6vw, .94rem);
  line-height: 1.65;
}
.header-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 12px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.header-button:hover { background: rgba(255, 255, 255, .23); transform: translateY(-1px); }
.header-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.page-wrap { flex: 1; width: min(1280px, 100%); margin: auto; padding: 20px 28px 28px; }
.status-banner {
  margin-bottom: 13px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #fde68a;
  background: #fff8e5;
  color: #78350f;
  font-size: .77rem;
  display: flex;
  gap: 9px;
  align-items: center;
  box-shadow: 0 4px 14px rgba(67, 42, 161, .06);
}
.status-banner.success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.status-banner.loading { background: #eee9ff; border-color: #cfc2ff; color: #351590; }
.status-banner.error { background: #fff1f1; border-color: #fecaca; color: var(--danger); }
.status-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: currentColor;
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  flex: 0 0 auto;
}
.status-banner.loading .status-icon { animation: spin 1s linear infinite; }
.status-text { flex: 1; line-height: 1.5; }
.status-action, .status-close {
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}
.status-action { padding: 5px 8px; border: 1px solid currentColor; border-radius: 8px; font-size: .69rem; }
.status-close { padding: 2px 5px; font-size: 1.05rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.grade-filter {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 7px;
  margin-bottom: 13px;
  border: 1px solid #d7d9f3;
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 5px 16px rgba(67, 42, 161, .08);
  scrollbar-width: none;
}
.grade-filter::-webkit-scrollbar { display: none; }
.grade-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #57536e;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.grade-button:hover { background: var(--primary-soft); color: var(--primary); }
.grade-button.active { background: var(--main-gradient); color: #fff; box-shadow: 0 5px 14px rgba(67, 42, 161, .2); }

.mobile-tabs { display: none; }
.content-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 22px; align-items: start; }
.sidebar, .detail-card {
  min-width: 0;
  background: var(--surface);
  border: 2px solid rgba(90, 35, 206, .28);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 224px);
  min-height: 530px;
  max-height: 790px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.detail-card { min-height: 530px; height: calc(100vh - 224px); max-height: 790px; overflow: hidden; }

.search-wrap { position: relative; margin-bottom: 9px; }
.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 38px;
  border: 1px solid #d6d9f3;
  border-radius: 15px;
  outline: none;
  background: #f1f2ff;
  color: var(--ink);
  font-size: .82rem;
  transition: .2s ease;
}
.search-wrap input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90, 35, 206, .16); }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: #77758b;
  stroke-width: 2;
  pointer-events: none;
}
.clear-search {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #78758c;
  font-size: 1.25rem;
  cursor: pointer;
}
.sidebar-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 8px; color: #78758c; font-size: .7rem; }
.sidebar-meta b { color: var(--primary); }
.text-button { border: 0; background: transparent; color: var(--primary); font-size: .68rem; font-weight: 700; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.recent-section { padding: 8px; margin-bottom: 8px; border: 1px solid #e1e1f6; border-radius: 13px; background: #f6f5ff; }
.small-label { margin: 0 0 6px; color: #88849a; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.recent-list { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.recent-list::-webkit-scrollbar { display: none; }
.recent-button {
  flex: 0 0 auto;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #d8d8ef;
  border-radius: 999px;
  background: #fff;
  color: #5c5871;
  padding: 4px 9px;
  font-size: .66rem;
  cursor: pointer;
}
.recent-button:hover { border-color: #9e83ec; color: var(--primary); }

.term-list { flex: 1; min-height: 0; overflow-y: auto; padding: 3px 3px 3px 0; display: flex; flex-direction: column; gap: 7px; scrollbar-width: thin; }
.term-list[aria-busy="true"] { opacity: .64; }
.term-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid #dde0f5;
  border-radius: 14px;
  background: var(--surface-soft);
  color: #334155;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  transition: .17s ease;
}
.term-item::before { content: ""; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); }
.term-item:hover { background: #eee9ff; border-color: #c8b9fb; transform: translateY(-1px); }
.term-item.active { background: linear-gradient(135deg, #f1edff 0%, #e9f6ff 100%); border: 2px solid var(--primary); color: var(--primary); }
.term-name { min-width: 0; font-size: .8rem; line-height: 1.42; font-weight: 700; overflow-wrap: anywhere; }
.no-results { min-height: 210px; display: grid; place-content: center; text-align: center; color: #78758c; padding: 20px; }
.no-results b { color: #454158; font-size: .8rem; }
.no-results p { margin: 6px 0 0; font-size: .69rem; line-height: 1.55; }
.load-more-button {
  flex: 0 0 auto;
  width: 100%;
  min-height: 37px;
  margin-top: 8px;
  border: 1px solid #c8b9fb;
  border-radius: 11px;
  background: #f1edff;
  color: var(--primary-dark);
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}
.load-more-button:hover:not(:disabled) { background: #e8e0ff; border-color: #9274e8; }
.load-more-button:disabled { opacity: .55; cursor: wait; }

button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid rgba(15, 134, 197, .72);
  outline-offset: 2px;
}

.empty-detail { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.empty-icon { width: 78px; height: 78px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(135deg, #eee9ff 0%, #e5f5ff 100%); border: 1px solid #c8b9fb; color: var(--primary); font-size: 2.2rem; }
.empty-detail h2 { margin: 18px 0 7px; font-size: 1.25rem; }
.empty-detail p { max-width: 450px; margin: 0; color: #78758c; font-size: .86rem; line-height: 1.7; }
.term-detail { min-height: 100%; height: 100%; display: flex; flex-direction: column; }
.detail-toolbar { padding: 13px 20px; background: rgba(247, 247, 255, .95); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.detail-meta, .toolbar-actions { display: flex; align-items: center; gap: 7px; }
.position-badge { padding: 5px 9px; border: 1px solid #c8b9fb; border-radius: 8px; background: #e9e2ff; color: #3c1d94; font-size: .7rem; font-weight: 700; }
.source-label { color: var(--muted); font-size: .65rem; }
.tool-button { min-height: 33px; display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #4c485c; font-size: .68rem; font-weight: 600; cursor: pointer; }
.tool-button:hover { background: #eeecfb; }
.tool-button.copied { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.detail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 23px 28px 28px; }
.term-heading { border-bottom: 1px solid #d9dcf6; padding-bottom: 16px; margin-bottom: 20px; }
.eyebrow { margin: 0; color: var(--primary); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-top: 7px; }
.term-heading h2 { min-width: 0; margin: 0; color: #29195f; font: 700 clamp(1.55rem, 4vw, 2.35rem)/1.22 "Lora", Georgia, serif; overflow-wrap: anywhere; }
.grade-badge { flex: 0 0 auto; margin-top: 4px; padding: 5px 10px; border: 1px solid #f5cf65; border-radius: 999px; background: #fff6cf; color: #7a4a00; font-size: .67rem; font-weight: 800; white-space: nowrap; }
.content-section + .content-section { margin-top: 20px; }
.section-title { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; font-size: .69rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.primary-title { color: var(--primary); }
.amber-title { color: #b66300; }
.definition-card, .example-card { border-radius: 15px; padding: 18px 20px; overflow-wrap: anywhere; }
.definition-card { border: 1px solid #d9dcf6; border-left: 4px solid var(--primary); background: linear-gradient(180deg, #fafaff 0%, #f5f6ff 100%); color: #292524; }
.example-card { border: 1px solid #f4dcab; border-left: 4px solid var(--amber); background: #fffaf0; color: #4b3b22; }
.rich-content { font-family: "Lora", Georgia, serif; font-size: 1rem; line-height: 1.82; }
.rich-content p { margin: 0 0 1em; text-align: justify; text-justify: inter-word; }
.rich-content p:last-child { margin-bottom: 0; }
.rich-content ul, .rich-content ol { padding-left: 1.5em; margin: .5em 0 1em; }
.rich-content li { margin-bottom: .4em; }
.rich-content blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid #9274e8; color: #57534e; }
.rich-content a { color: var(--primary); text-underline-offset: 3px; }

.ai-section {
  margin-top: 25px;
  padding: 18px;
  border: 1px solid #cfc6f7;
  border-radius: 18px;
  background: linear-gradient(155deg, #fbfaff 0%, #f2f7ff 100%);
  box-shadow: 0 8px 22px rgba(67, 42, 161, .08);
}
.ai-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.ai-kicker { margin: 0 0 4px; color: var(--primary-blue); font-size: .61rem; font-weight: 800; letter-spacing: .12em; }
.ai-section-heading h3 { margin: 0; color: #2d1d68; font: 700 1.08rem/1.35 "Lora", Georgia, serif; }
.ai-byok-badge { flex: 0 0 auto; padding: 5px 9px; border: 1px solid #b8acf0; border-radius: 999px; background: #eee9ff; color: #4a249f; font-size: .62rem; font-weight: 800; }

.ai-key-panel { margin-bottom: 13px; border: 1px solid #d9dcf6; border-radius: 13px; background: rgba(255, 255, 255, .88); overflow: hidden; }
.ai-key-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; color: #4c485c; font-size: .7rem; font-weight: 800; cursor: pointer; list-style: none; }
.ai-key-panel summary::-webkit-details-marker { display: none; }
.ai-key-panel summary::before { content: "▸"; color: var(--primary); transition: transform .18s ease; }
.ai-key-panel[open] summary::before { transform: rotate(90deg); }
.ai-key-panel summary span { flex: 1; }
.ai-key-panel summary strong { color: var(--danger); font-size: .64rem; }
.ai-key-panel.has-key summary strong { color: #067647; }
.ai-key-content { padding: 0 12px 12px; border-top: 1px solid #ececf8; }
.ai-key-content > label { display: block; margin: 10px 0 6px; color: #57536e; font-size: .66rem; font-weight: 700; }
.ai-provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
.ai-provider-grid label, .ai-custom-model { min-width: 0; color: #57536e; font-size: .66rem; font-weight: 700; }
.ai-provider-grid label span, .ai-custom-model span { display: block; margin-bottom: 6px; }
.ai-provider-grid select, .ai-custom-model input { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #cfd3ef; border-radius: 10px; background: #fff; color: var(--ink); font-size: .72rem; outline: none; }
.ai-provider-grid select:focus, .ai-custom-model input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90, 35, 206, .12); }
.ai-custom-model { margin-top: 9px !important; }
.ai-key-row { display: flex; gap: 7px; }
.ai-key-row input { min-width: 0; flex: 1; height: 40px; padding: 0 11px; border: 1px solid #cfd3ef; border-radius: 10px; background: #fff; color: var(--ink); font-size: .75rem; outline: none; }
.ai-key-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90, 35, 206, .12); }
.ai-key-row button, .ai-key-actions button { border-radius: 9px; font-size: .67rem; font-weight: 800; cursor: pointer; }
.ai-key-row button { flex: 0 0 auto; padding: 0 11px; border: 1px solid #d2d5ec; background: #fff; color: #4c485c; }
.ai-key-actions { display: flex; gap: 7px; margin-top: 8px; }
.ai-key-actions button { min-height: 34px; padding: 6px 11px; }
.ai-primary-button { border: 1px solid var(--primary); background: var(--primary); color: #fff; }
.ai-secondary-button { border: 1px solid #d2d5ec; background: #fff; color: #5b576b; }
.ai-key-note, .ai-terms-note { margin: 8px 0 0; color: #77738a; font-size: .62rem; line-height: 1.55; }
.ai-key-note a { color: var(--primary); font-weight: 800; text-underline-offset: 2px; }
.ai-terms-note { color: #8a5d14; }

.ai-suggestions { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 9px; scrollbar-width: thin; }
.ai-suggestions button { flex: 0 0 auto; max-width: 210px; padding: 7px 10px; border: 1px solid #cfc6f7; border-radius: 999px; background: #fff; color: #4a249f; font-size: .64rem; font-weight: 700; cursor: pointer; }
.ai-suggestions button:hover:not(:disabled) { background: #eee9ff; border-color: #9d88e6; }
.ai-suggestions button:disabled { opacity: .48; cursor: not-allowed; }

.ai-chat-log { min-height: 150px; max-height: 430px; overflow-y: auto; scrollbar-gutter: stable; display: flex; flex-direction: column; gap: 9px; padding: 12px; border: 1px solid #dfe2f5; border-radius: 14px; background: #fff; }
.ai-message { max-width: 91%; padding: 10px 12px; border-radius: 13px; font-size: .75rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message.assistant { align-self: flex-start; border: 1px solid #d9dcf6; border-bottom-left-radius: 4px; background: #f3f2ff; color: #343047; }
.ai-message.user { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--main-gradient); color: #fff; }
.ai-message.error { align-self: flex-start; border: 1px solid #fecaca; background: #fff1f1; color: var(--danger); }
.ai-message-meta { display: block; margin-bottom: 3px; font-size: .58rem; font-weight: 800; letter-spacing: .04em; opacity: .72; text-transform: uppercase; }
.ai-message strong { font-weight: 800; }
.ai-message.is-thinking { color: #706b81; font-style: italic; }

.ai-chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
.ai-chat-form textarea { width: 100%; min-height: 48px; max-height: 130px; resize: vertical; padding: 10px 11px; border: 1px solid #cfd3ef; border-radius: 12px; background: #fff; color: var(--ink); font-size: .75rem; line-height: 1.5; outline: none; }
.ai-chat-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(90, 35, 206, .12); }
.ai-chat-form textarea:disabled { background: #f4f4f8; color: #9692a3; }
.ai-chat-form button { align-self: stretch; min-width: 62px; padding: 8px 13px; border: 0; border-radius: 12px; background: var(--main-gradient); color: #fff; font-size: .7rem; font-weight: 800; cursor: pointer; }
.ai-chat-form button:disabled { opacity: .45; cursor: not-allowed; }
.ai-form-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; color: #898598; font-size: .58rem; line-height: 1.45; }
.ai-form-meta span:last-child { text-align: right; }

.related-section { border-top: 1px solid var(--line); margin-top: 25px; padding-top: 18px; }
.related-section h3 { margin: 0 0 10px; color: #78758c; text-transform: uppercase; letter-spacing: .08em; font-size: .67rem; }
.related-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.related-button { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: #f8f7ff; padding: 11px; text-align: left; cursor: pointer; }
.related-button:hover { border-color: #8b6ce1; background: #f2edff; }
.related-button b { display: block; color: #292524; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.related-button span { display: block; color: #78758c; font-size: .63rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-nav { padding: 10px 20px; border-top: 1px solid var(--line); background: #f5f4ff; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-nav button { border: 1px solid #d6d9ef; background: #fff; color: #292524; border-radius: 9px; padding: 7px 10px; font-size: .69rem; font-weight: 600; cursor: pointer; }
.detail-nav button:hover:not(:disabled) { background: #eeecfb; }
.detail-nav button:disabled { opacity: .38; cursor: not-allowed; }
.keyboard-hint { color: #a8a29e; font-size: .62rem; }

.site-footer { margin-top: auto; padding: 24px 16px; background: linear-gradient(135deg, #27105f 0%, #242279 52%, #0d577b 100%); color: #d7daf2; text-align: center; }
.footer-inner { max-width: 900px; margin: auto; }
.site-footer p { margin: 4px 0; font-size: .74rem; line-height: 1.65; }
.footer-note { color: #c9cbea; font-size: .67rem !important; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: rgba(227, 228, 248, .82); }
::-webkit-scrollbar-thumb { background: rgba(90, 35, 206, .32); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(61, 53, 206, .65); }

@media (max-width: 1023px) {
  .page-wrap { padding: 16px 15px 24px; }
  .content-grid { grid-template-columns: 315px minmax(0, 1fr); gap: 16px; }
  .sidebar, .detail-card { height: calc(100vh - 230px); min-height: 500px; }
}

@media (max-width: 820px) {
  .site-header { padding: 20px 15px; }
  .header-button span { display: none; }
  .header-button { width: 40px; justify-content: center; padding: 8px; }
  .page-wrap { padding: 13px 11px 22px; }
  .mobile-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: rgba(255, 255, 255, .96); border: 1px solid #d7d9f3; border-radius: 15px; box-shadow: 0 5px 16px rgba(67, 42, 161, .1); }
  .mobile-tab { flex: 1; border: 0; border-radius: 11px; background: transparent; color: #57534e; padding: 10px 7px; font-size: .75rem; font-weight: 700; cursor: pointer; }
  .mobile-tab b { margin-left: 3px; }
  .mobile-tab.active { background: var(--main-gradient); color: #fff; box-shadow: 0 5px 14px rgba(67, 42, 161, .2); }
  .content-grid { display: block; }
  .sidebar, .detail-card { position: static; width: 100%; height: calc(100dvh - 250px); min-height: 480px; max-height: none; }
  .panel-hidden-mobile { display: none !important; }
  .panel-visible { display: flex; }
  .detail-card.panel-visible { display: block; }
}

@media (max-width: 540px) {
  .site-header { border-bottom-left-radius: 24px; border-bottom-right-radius: 24px; padding: 18px 12px; }
  .header-inner { gap: 10px; }
  .eyebrow-light { font-size: .59rem; }
  .header-inner h1 { font-size: 1.35rem; }
  .header-description { font-size: .72rem; line-height: 1.55; }
  .grade-filter { margin-bottom: 10px; padding: 5px; border-radius: 13px; }
  .grade-button { min-height: 32px; padding: 5px 11px; font-size: .66rem; }
  .sidebar, .detail-card { height: calc(100dvh - 244px); min-height: 430px; border-radius: 18px; }
  .sidebar { padding: 9px; }
  .detail-toolbar { padding: 10px 11px; align-items: flex-start; }
  .detail-meta { width: 100%; justify-content: space-between; }
  .source-label { display: none; }
  .toolbar-actions { width: 100%; }
  .tool-button { flex: 1; justify-content: center; }
  .detail-scroll { padding: 18px 14px 22px; }
  .heading-row { display: block; }
  .grade-badge { display: inline-flex; margin-top: 10px; }
  .definition-card, .example-card { padding: 16px 14px; }
  .rich-content { font-size: .95rem; line-height: 1.75; }
  .ai-section { padding: 14px 12px; border-radius: 15px; }
  .ai-section-heading { align-items: center; }
  .ai-provider-grid { grid-template-columns: 1fr; }
  .ai-suggestions { margin-right: -4px; }
  .ai-chat-log { max-height: 360px; padding: 10px; }
  .ai-message { max-width: 96%; font-size: .72rem; }
  .ai-chat-form { grid-template-columns: 1fr; }
  .ai-chat-form button { min-height: 40px; }
  .ai-form-meta { display: block; }
  .ai-form-meta span { display: block; text-align: left !important; margin-top: 3px; }
  .related-grid { grid-template-columns: 1fr; }
  .detail-nav { padding: 9px 10px; }
  .detail-nav button span, .keyboard-hint { display: none; }
  .site-footer { padding: 18px 12px; }
}

@media print {
  body { background: #fff; }
  .site-header, .status-banner, .grade-filter, .mobile-tabs, .sidebar, .detail-toolbar, .detail-nav, .site-footer, .related-section, .ai-section { display: none !important; }
  .page-wrap { width: 100%; padding: 0; }
  .content-grid { display: block; }
  .detail-card { display: block !important; height: auto; min-height: 0; border: 0; box-shadow: none; }
  .detail-scroll { overflow: visible; padding: 0; }
  .definition-card, .example-card { break-inside: avoid; }
}
