@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn/Vazirmatn.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #13211f;
  --ink-soft: #2d423e;
  --muted: #6d807c;
  --muted-2: #92a19e;
  --line: #dce8e4;
  --line-strong: #c7d9d4;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --surface-tint: #f0f7f4;
  --canvas: #eef5f2;
  --brand: #0b6b5d;
  --brand-2: #0e8270;
  --brand-dark: #064f45;
  --brand-soft: #e4f3ee;
  --brand-softer: #f2f9f6;
  --info: #246b9b;
  --info-soft: #edf6fc;
  --warning: #a96a0d;
  --warning-soft: #fff7e8;
  --danger: #b33b48;
  --danger-soft: #fff0f2;
  --success: #19745f;
  --success-soft: #eaf7f2;
  --shadow-xs: 0 1px 2px rgba(19, 33, 31, .04);
  --shadow-sm: 0 8px 24px rgba(20, 55, 48, .07);
  --shadow-md: 0 18px 48px rgba(20, 55, 48, .10);
  --shadow-lg: 0 28px 78px rgba(16, 57, 49, .14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --transition: .18s ease;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(53, 147, 123, .12), transparent 27rem),
    radial-gradient(circle at 95% 5%, rgba(71, 116, 153, .08), transparent 30rem),
    var(--canvas);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; transition: color var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition); }
button, input, textarea, select { font: inherit; }
button { transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(11, 107, 93, .18); outline-offset: 2px; }
::selection { background: #c8e8df; color: #0c443c; }
code { color: #71429b; background: #f6f1fa; border-radius: 7px; padding: 2px 6px; font-size: .83em; }
.app-main { min-height: calc(100vh - 72px); min-height: calc(100dvh - 72px); }
.chat-page { height: 100vh; height: 100dvh; overflow: hidden; }
.chat-page .app-main { height: calc(100vh - 72px); height: calc(100dvh - 72px); min-height: 0; overflow: hidden; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 72px;
  border-bottom: 1px solid rgba(203, 220, 215, .85);
  background: rgba(250, 253, 252, .90);
  backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 2px 18px rgba(25, 65, 56, .035);
}
.topbar-inner {
  width: min(1540px, 95vw);
  min-height: 72px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(12px, 2vw, 26px);
}
.topbar-brand { display: inline-flex; align-items: center; gap: 11px; min-width: max-content; }
.topbar-brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #13927b, #07594e 68%, #063f38);
  box-shadow: 0 8px 20px rgba(11, 107, 93, .22);
  font: 700 1.2rem Georgia, serif;
}
.topbar-brand-copy { display: grid; line-height: 1.25; }
.topbar-brand-copy strong { font-size: .98rem; letter-spacing: -.25px; }
.topbar-brand-copy strong b { color: var(--brand-2); }
.topbar-brand-copy small { margin-top: 3px; color: var(--muted-2); font-size: .58rem; letter-spacing: .02em; direction: ltr; text-align: right; }
.topbar-nav { min-width: 0; justify-self: center; display: flex; flex-flow: row nowrap; align-items: center; gap: 7px; padding: 5px; border: 1px solid rgba(218, 231, 227, .8); border-radius: 14px; background: rgba(255,255,255,.72); }
.topbar-nav a { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 13px; border-radius: 10px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.topbar-nav a:hover { color: var(--brand); background: var(--brand-softer); }
.topbar-nav a.active { color: var(--brand-dark); background: var(--brand-soft); box-shadow: inset 0 0 0 1px rgba(11,107,93,.08); }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #a8bab5; }
.topbar-nav a.active .nav-dot { background: var(--brand); box-shadow: 0 0 0 4px rgba(11,107,93,.1); }
.topbar-account { min-width: 0; justify-self: end; }
.account-nav, .topbar-account form { display: flex; flex-flow: row nowrap; align-items: center; gap: 6px; }
.account-nav { margin: 0; padding: 0; list-style: none; }
.account-link { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 6px 10px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-size: .72rem; white-space: nowrap; }
button.account-link { cursor: pointer; }
.account-link:hover { border-color: var(--line); background: #fff; color: var(--brand); }
.account-login { border-color: #bfdad3; background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; }
.account-icon { width: 25px; height: 25px; display: grid; place-items: center; flex: 0 0 25px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: .65rem; font-weight: 800; }
.account-profile .account-label { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* Common buttons / forms */
.btn { font-weight: 700; border-radius: 12px; padding-inline: 15px; }
.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-dark);
  --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark);
  --bs-btn-active-border-color: var(--brand-dark);
  box-shadow: 0 7px 18px rgba(11,107,93,.12);
}
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #a8cec4; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); }
.btn-outline-warning { --bs-btn-color: #94600d; --bs-btn-border-color: #e8c98e; --bs-btn-hover-bg: #fff4de; --bs-btn-hover-color: #81510a; --bs-btn-hover-border-color: #dfb762; }
.form-label { margin-bottom: 7px; color: #314843; font-size: .75rem; font-weight: 700; }
.form-control, .form-select {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  font-size: .82rem;
}
.form-control:hover, .form-select:hover { border-color: #aac8c1; }
.form-control:focus, .form-select:focus { border-color: #7fb7aa; box-shadow: 0 0 0 .2rem rgba(11,107,93,.10); }
.form-control::placeholder { color: #a1afac; }
.form-text { margin-top: 6px; color: var(--muted); font-size: .68rem; line-height: 1.7; }
.text-danger { font-size: .69rem; }
.validation-summary-valid, .field-validation-valid { display: none; }
.alert { border: 0; border-radius: 14px; font-size: .78rem; line-height: 1.8; }

/* Chat */
.chat-shell {
  width: min(1560px, 96vw);
  height: calc(100dvh - 96px);
  min-height: 0;
  margin: 12px auto;
  display: grid;
  grid-template-columns: 306px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(203, 220, 215, .95);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.conversation-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 20px 18px 16px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbfa 0%, #f2f8f5 100%);
}
.conversation-panel-top { padding: 1px 2px 12px; border-bottom: 1px solid #e3ece9; }
.brand-card { display: flex; gap: 11px; align-items: center; }
.brand-card strong, .brand-card small { display: block; }
.brand-card strong { font-size: .92rem; }
.brand-card small { margin-top: 3px; color: var(--muted); font-size: .66rem; }
.brand-mark { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #0f8b75, #06564b); box-shadow: 0 8px 22px rgba(11,107,93,.18); font: 700 1.35rem Georgia, serif; }
.new-chat-button {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #bdd8d1;
  border-radius: 13px;
  color: var(--brand-dark);
  background: #fff;
  box-shadow: 0 5px 14px rgba(20,61,52,.045);
  font-size: .78rem;
  font-weight: 700;
}
.new-chat-button:hover { border-color: var(--brand); background: var(--brand-softer); transform: translateY(-1px); }
.new-chat-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 1rem; }
.conversation-section-title { display: flex; justify-content: space-between; align-items: center; padding: 16px 5px 9px; color: #4f625e; font-size: .68rem; font-weight: 700; }
.conversation-section-title small { color: #96a5a2; font-size: .58rem; font-weight: 400; }
.conversation-list {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 1px 2px 8px;
    scrollbar-color: #c6d7d2 transparent;
}
.conversation-item { width: 100%; border: 1px solid transparent; background: transparent; padding: 10px 11px; border-radius: 12px; color: var(--ink); text-align: right; }
.conversation-item > * { pointer-events: none; }
.conversation-item:hover { border-color: #d6e4e0; background: rgba(255,255,255,.82); }
.conversation-item.active { border-color: #bcd9d1; background: #fff; box-shadow: 0 6px 16px rgba(20,61,52,.06); }
.conversation-item.loading { cursor: wait; opacity: .68; }
.conversation-item-main { display: flex !important; align-items: center; gap: 8px; min-width: 0; }
.conversation-bullet { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #c3d1cd; }
.conversation-item.active .conversation-bullet { background: var(--brand); box-shadow: 0 0 0 4px rgba(11,107,93,.08); }
.conversation-title { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .76rem; font-weight: 600; }
.conversation-item small { display: block; margin-top: 5px; padding-right: 15px; color: var(--muted-2); font-size: .59rem; direction: ltr; text-align: right; }
.conversation-panel-footer { display: flex; align-items: flex-start; gap: 7px; padding: 12px 5px 2px; border-top: 1px solid #e0eae7; color: var(--muted); font-size: .59rem; line-height: 1.6; }
.privacy-indicator { color: #48a68c; font-size: .55rem; line-height: 1.8; }

.chat-panel { min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: linear-gradient(180deg, #fff 0%, #fbfdfc 100%); }
.chat-header { min-height: 91px; padding: 17px 28px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.78); }
.chat-header-copy { min-width: 0; }
.page-kicker, .section-kicker { display: block; margin-bottom: 5px; color: var(--brand); font-size: .55rem; font-weight: 800; letter-spacing: .10em; direction: ltr; text-align: right; }
.chat-header h1 { margin: 0 0 4px; font-size: 1.03rem; font-weight: 800; letter-spacing: -.2px; }
.chat-header p { margin: 0; color: var(--muted); font-size: .70rem; line-height: 1.65; }
.status-pill { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid #cce2dc; border-radius: 999px; color: var(--brand-dark); background: var(--brand-softer); font-size: .65rem; font-weight: 700; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: #2da581; box-shadow: 0 0 0 4px rgba(45,165,129,.10); }
.messages { min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 28px clamp(18px, 7vw, 104px); overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-gutter: stable; scrollbar-color: #cadbd6 transparent; }
.messages.has-messages::after { content: ""; display: block; height: max(48px, calc(100% - 110px)); pointer-events: none; }
.conversation-loading { min-height: 100%; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); font-size: .76rem; }
.conversation-loading::before { content: ""; width: 30px; height: 30px; border: 3px solid #d9e9e5; border-top-color: var(--brand); border-radius: 50%; animation: conversationSpin .7s linear infinite; }
@keyframes conversationSpin { to { transform: rotate(360deg); } }
.empty-chat { max-width: 820px; margin: clamp(34px, 8vh, 92px) auto 0; text-align: center; }
.empty-icon { width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 16px; border: 1px solid #c6e2da; border-radius: 23px; color: var(--brand); background: linear-gradient(145deg, #f5fbf8, #e1f2ed); box-shadow: 0 14px 34px rgba(11,107,93,.11); font-size: 1.85rem; }
.empty-chat-kicker { display: inline-block; margin-bottom: 7px; color: var(--brand); font-size: .65rem; font-weight: 800; }
.empty-chat h2 { margin: 0; font-size: clamp(1.25rem, 2.5vw, 1.65rem); font-weight: 800; letter-spacing: -.3px; }
.empty-chat > p { max-width: 610px; margin: 9px auto 0; color: var(--muted); font-size: .78rem; line-height: 1.8; }
.suggestions { margin-top: 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; text-align: right; }
.suggestions button { min-height: 48px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 13px; padding: 9px 12px; background: #fff; color: #455954; box-shadow: var(--shadow-xs); font-size: .70rem; text-align: right; }
.suggestions button span { flex: 0 0 auto; padding: 4px 7px; border-radius: 8px; color: var(--brand); background: var(--brand-soft); font-size: .57rem; font-weight: 800; }
.suggestions button:hover { border-color: #9fc9be; color: var(--brand-dark); background: #fcfffe; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.message { max-width: 880px; margin: 0 auto 19px; display: flex; gap: 11px; align-items: flex-start; scroll-margin-block-start: 18px; }
.message.user { flex-direction: row-reverse; }
.message-avatar { width: 35px; height: 35px; flex: 0 0 35px; display: grid; place-items: center; border: 1px solid #c9e0da; border-radius: 12px; background: var(--brand-soft); color: var(--brand); box-shadow: var(--shadow-xs); font-size: .76rem; font-weight: 800; }
.message.user .message-avatar { border-color: #d9dde0; background: #eff1f2; color: #566063; }
.message-body { max-width: min(100%, 790px); padding: 14px 17px; border: 1px solid #e1ebe8; border-radius: 18px 6px 18px 18px; background: #f7fbf9; color: #263b37; box-shadow: 0 4px 14px rgba(20,55,48,.035); line-height: 1.95; font-size: .86rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .message-body { border-color: var(--brand); border-radius: 6px 18px 18px 18px; background: linear-gradient(145deg, #0d7565, #095c51); color: #fff; box-shadow: 0 8px 22px rgba(11,107,93,.13); }
.message-link { display: inline-flex; align-items: center; max-width: 100%; padding: 1px 8px; border: 1px solid #9cc6e8; border-radius: 8px; background: #edf6ff; color: #0969da; font-weight: 700; line-height: 1.7; direction: ltr; unicode-bidi: isolate; }
.message-link:hover { border-color: #0969da; background: #dceeff; color: #0556b3; text-decoration: underline; }
.message.user .message-link { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.12); color: #fff; }
.citations { margin-top: 12px; display: grid; gap: 7px; white-space: normal; }
.citation { position: relative; border: 1px solid #d6e6e1; border-radius: 12px; padding: 9px 11px 9px 12px; background: #fff; color: #5b706b; font-size: .67rem; line-height: 1.65; }
.citation::before { content: ""; position: absolute; inset-block: 9px; inset-inline-start: 0; width: 3px; border-radius: 4px; background: #78b8a8; }
.citation a { display: block; font-weight: 700; }
.citation a:hover { color: var(--brand); }
.citation-source-url { display: block; margin-top: 4px; color: #7a8e89; direction: ltr; text-align: left; overflow-wrap: anywhere; font-size: .61rem; }
.message-meta { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: .62rem; direction: ltr; text-align: left; white-space: normal; }
.typing .message-body { position: relative; overflow: hidden; }
.typing .message-body::after { content: ""; display: inline-block; width: 18px; height: 4px; margin-right: 8px; border-radius: 999px; background: linear-gradient(90deg, #9dcfc2 0 25%, #4fa890 25% 50%, #9dcfc2 50% 75%, #4fa890 75%); background-size: 36px 4px; animation: typingDots 1s linear infinite; vertical-align: middle; }
@keyframes typingDots { to { background-position: 36px 0; } }

.composer { margin: 0 clamp(18px, 7vw, 104px) 22px; display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: end; gap: 9px; padding: 8px; border: 1px solid #cbdcd7; border-radius: 19px; background: rgba(255,255,255,.97); box-shadow: 0 14px 38px rgba(20,60,51,.10); }
.composer:focus-within { border-color: #78b8a8; box-shadow: 0 16px 42px rgba(11,107,93,.13), 0 0 0 3px rgba(11,107,93,.05); }
.composer-input-wrap { min-width: 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: start; gap: 3px; }
.composer-spark { width: 28px; height: 38px; display: grid; place-items: center; color: #65a997; font-size: .84rem; }
.composer textarea { width: 100%; max-height: 150px; min-height: 43px; padding: 10px 7px; border: 0; outline: 0; resize: none; background: transparent; color: var(--ink); line-height: 1.7; font-size: .83rem; }
.composer > button { width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 14px; background: linear-gradient(145deg, var(--brand-2), var(--brand-dark)); color: #fff; box-shadow: 0 8px 20px rgba(11,107,93,.20); font-size: 1.35rem; }
.composer > button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(11,107,93,.26); }
.composer > button:disabled { cursor: wait; opacity: .55; }
.composer-hint { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 0 36px 2px 6px; color: #98a5a2; font-size: .57rem; }
.composer-hint span + span::before { content: "•"; margin-left: 10px; color: #b9c4c1; }

/* Related knowledge / routing / guided tools */
.related-knowledge-host { margin-top: 13px; white-space: normal; }
.related-knowledge { overflow: hidden; border: 1px solid #d0e1dc; border-radius: 15px; background: rgba(255,255,255,.86); }
.related-knowledge-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; cursor: pointer; list-style: none; user-select: none; }
.related-knowledge-summary::-webkit-details-marker { display: none; }
.related-knowledge-summary::before { content: "⌄"; color: var(--brand); transition: transform var(--transition); }
.related-knowledge[open] .related-knowledge-summary::before { transform: rotate(180deg); }
.related-knowledge-heading { color: var(--ink); font-size: .73rem; font-weight: 800; }
.related-knowledge-hint { color: var(--muted); font-size: .61rem; }
.related-knowledge-body { border-top: 1px solid var(--line); padding: 10px; }
.related-all-link { display: inline-flex; margin: 1px 3px 8px; color: var(--brand); font-size: .65rem; font-weight: 800; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.guided-tool, .adaptive-route-choice { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); white-space: normal; }
.adaptive-route-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 9px; }
.adaptive-route-option { position: relative; min-height: 90px; display: flex; flex-direction: column; gap: 5px; align-items: stretch; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: inherit; text-align: right; cursor: pointer; }
.adaptive-route-option:hover:not(:disabled) { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.adaptive-route-option:disabled { cursor: wait; opacity: .58; }
.adaptive-route-option.combined { border-color: #a9cec4; background: var(--brand-softer); }
.route-option-title { padding-inline-end: 48px; font-size: .81rem; line-height: 1.55; }
.route-option-description { color: var(--muted); font-size: .70rem; line-height: 1.7; }
.route-option-badge { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; padding: 2px 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: .57rem; }
.guided-progress { margin-bottom: 9px; color: var(--muted); font-size: .66rem; }
.guided-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; }
.guided-option, .guided-cancel { min-height: 39px; border: 1px solid #b7d3cb; border-radius: 11px; background: #fff; color: var(--brand); font-size: .73rem; }
.guided-option:hover { border-color: var(--brand); background: var(--brand-soft); }
.guided-option:disabled, .guided-cancel:disabled { opacity: .55; }
.guided-cancel { margin-top: 9px; padding: 6px 13px; border-color: var(--line); color: var(--muted); }
.persian-date-picker { width: min(390px, 100%); padding: 12px; border: 1px solid #cfe0db; border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm); direction: rtl; }
.persian-calendar-header { display: grid; grid-template-columns: 38px 1fr 38px; gap: 8px; align-items: center; margin-bottom: 10px; }
.persian-calendar-header button { width: 38px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--brand); font-size: 1.35rem; line-height: 1; }
.persian-calendar-title { text-align: center; color: var(--ink); font-size: .81rem; }
.persian-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(34px, 1fr)); gap: 4px; text-align: center; }
.persian-weekday { padding: 5px 0; color: var(--muted); font-size: .64rem; font-weight: 800; }
.persian-calendar-empty { min-height: 36px; }
.persian-calendar-day { min-height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: .73rem; }
.persian-calendar-day:hover { background: var(--brand-soft); color: var(--brand); }
.persian-calendar-day.today { box-shadow: inset 0 0 0 1px #78b9a9; color: var(--brand); font-weight: 800; }
.persian-calendar-day.selected { background: var(--brand); color: #fff; box-shadow: none; }
.persian-date-submit-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.persian-selected-date { color: var(--muted); font-size: .69rem; }
.submit-persian-date { min-height: 36px; padding: 6px 14px; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: .71rem; }
.submit-persian-date:disabled { opacity: .45; }

.admin-diagnostics { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #9bb8b1; direction: ltr; text-align: left; white-space: normal; color: #314946; font-family: Consolas, "Courier New", monospace; font-size: .68rem; }
.admin-diagnostics summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; color: var(--brand-dark); font-family: Tahoma, "Segoe UI", sans-serif; font-weight: 800; }
.admin-diagnostics-count { padding: 2px 7px; border-radius: 999px; background: var(--brand-soft); font-size: .60rem; font-weight: 400; }
.admin-process { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.admin-process-step { padding: 4px 7px; border: 1px solid #c9dbd6; border-radius: 7px; background: var(--surface-soft); }
.admin-diagnostics-grid { display: grid; grid-template-columns: minmax(115px, auto) minmax(0, 1fr); gap: 4px 10px; margin: 8px 0; }
.admin-diagnostics-grid dt { color: #647976; }
.admin-diagnostics-grid dd { margin: 0; overflow-wrap: anywhere; color: #172d2a; }
.admin-evidence-scores, .admin-route-options { margin-top: 9px; padding-top: 7px; border-top: 1px solid #dce8e5; line-height: 1.7; overflow-wrap: anywhere; }

/* Knowledge search */
.knowledge-search-shell, .knowledge-reader-shell { width: min(1120px, 92vw); margin: 32px auto 70px; }
.search-hero { position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: 34px 36px; border: 1px solid rgba(255,255,255,.12); border-radius: 28px; color: #fff; background: linear-gradient(135deg, #053f38 0%, #086052 52%, #0c7a67 100%); box-shadow: var(--shadow-lg); }
.search-hero::after { content: ""; position: absolute; width: 340px; height: 340px; inset-inline-end: -110px; inset-block-start: -190px; border: 1px solid rgba(255,255,255,.10); border-radius: 50%; box-shadow: 0 0 0 48px rgba(255,255,255,.025), 0 0 0 96px rgba(255,255,255,.018); pointer-events: none; }
.search-hero-copy { position: relative; z-index: 1; max-width: 760px; }
.search-eyebrow, .admin-eyebrow { display: block; margin-bottom: 8px; color: #bce4d9; font-size: .58rem; font-weight: 800; letter-spacing: .12em; direction: ltr; text-align: right; }
.search-hero h1, .knowledge-reader-header h1 { margin: 0; font-size: clamp(1.35rem, 3vw, 2.15rem); font-weight: 800; letter-spacing: -.45px; }
.search-hero p { max-width: 700px; margin: 10px 0 0; color: #d5eee7; font-size: .78rem; line-height: 1.85; }
.search-hero-features { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.search-hero-features span { padding: 5px 9px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: rgba(255,255,255,.08); color: #e7f6f2; font-size: .61rem; }
.search-back-link { position: relative; z-index: 1; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid rgba(255,255,255,.28); border-radius: 12px; color: #fff; background: rgba(255,255,255,.07); font-size: .70rem; font-weight: 700; }
.search-back-link:hover { border-color: rgba(255,255,255,.45); background: rgba(255,255,255,.13); color: #fff; }
.knowledge-search-workspace { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.82); box-shadow: var(--shadow-md); backdrop-filter: blur(8px); }
.knowledge-search-form { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid #cbded8; border-radius: 17px; background: #fff; box-shadow: var(--shadow-sm); }
.knowledge-search-form:focus-within { border-color: #78b6a7; box-shadow: 0 12px 32px rgba(11,107,93,.11), 0 0 0 3px rgba(11,107,93,.05); }
.knowledge-search-icon { width: 40px; display: grid; place-items: center; color: #6ea999; font-size: 1.35rem; }
.knowledge-search-form input { min-width: 0; height: 46px; padding: 8px 3px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .84rem; }
.knowledge-search-form button, .semantic-load-more { border: 0; border-radius: 12px; background: linear-gradient(145deg, var(--brand-2), var(--brand-dark)); color: #fff; font-size: .72rem; font-weight: 800; box-shadow: 0 7px 18px rgba(11,107,93,.13); }
.knowledge-search-form button { min-width: 112px; height: 44px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 8px 18px; }
.knowledge-search-form button:hover, .semantic-load-more:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(11,107,93,.20); }
.search-help-row { display: flex; justify-content: space-between; gap: 15px; padding: 9px 8px 3px; color: var(--muted-2); font-size: .59rem; }
.semantic-search-host { min-height: 120px; margin-top: 8px; padding: 4px 8px 10px; border-radius: 18px; background: transparent; }
.semantic-search-host.compact { min-height: 0; padding: 0; margin: 0; border: 0; }
.semantic-search-status { min-height: 30px; display: flex; align-items: center; gap: 7px; padding: 5px 7px; color: var(--muted); font-size: .67rem; }
.semantic-search-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #a9bbb6; }
.semantic-results-feed { display: grid; gap: 9px; }
.semantic-result { position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 15px; border: 1px solid #dce8e5; border-radius: 15px; background: #fff; box-shadow: 0 5px 16px rgba(20,55,48,.04); transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); }
.semantic-result:hover { border-color: #b9d5ce; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.semantic-result-rank { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #c7e0d9; border-radius: 11px; background: var(--brand-soft); color: var(--brand); font-size: .68rem; font-weight: 800; }
.semantic-result-content { min-width: 0; }
.semantic-result-location { margin-bottom: 3px; color: #7d938e; font-size: .61rem; }
.semantic-result-title { display: inline-block; color: #075f52; font-size: .91rem; font-weight: 800; line-height: 1.6; }
.semantic-result-title:hover { color: var(--brand-dark); text-decoration: underline; }
.semantic-result-snippet { margin: 6px 0 10px; color: #475b56; font-size: .75rem; line-height: 1.9; overflow-wrap: anywhere; }
.semantic-result-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: .59rem; }
.semantic-result-meta span, .semantic-source-link { padding: 4px 8px; border: 1px solid #e3ece9; border-radius: 999px; background: #f5f9f7; }
.semantic-score { color: #086554; background: #edf8f4 !important; border-color: #d5ece5 !important; }
.semantic-lexical { color: #225f91; background: var(--info-soft) !important; border-color: #dbeaf5 !important; }
.semantic-source-link { max-width: min(100%, 440px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #0969da; direction: ltr; text-align: left; }
.semantic-load-row { display: flex; justify-content: center; padding-top: 14px; }
.semantic-load-more { min-width: 140px; min-height: 40px; padding: 8px 18px; }
.semantic-load-more:disabled { cursor: wait; opacity: .55; }
.compact .semantic-search-status { min-height: 24px; padding-inline: 2px; font-size: .60rem; }
.compact .semantic-result { grid-template-columns: 31px minmax(0, 1fr); gap: 8px; padding: 10px; border-radius: 12px; box-shadow: none; }
.compact .semantic-result-rank { width: 28px; height: 28px; border-radius: 9px; font-size: .58rem; }
.compact .semantic-result-title { font-size: .73rem; }
.compact .semantic-result-snippet { margin-block: 4px 7px; font-size: .66rem; line-height: 1.75; }

/* Knowledge reader */
.knowledge-reader-nav { display: flex; align-items: center; gap: 7px; margin: 0 4px 12px; color: var(--muted); font-size: .66rem; }
.knowledge-reader-nav a { color: var(--brand); font-weight: 700; }
.knowledge-reader-header { position: relative; overflow: hidden; padding: 30px 32px 25px; border-radius: 25px 25px 0 0; background: linear-gradient(140deg, #053f38, #086052 58%, #0d7e6a); color: #fff; box-shadow: var(--shadow-md); }
.knowledge-reader-header::after { content: ""; position: absolute; width: 230px; height: 230px; inset-inline-end: -80px; inset-block-start: -120px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 38px rgba(255,255,255,.025); }
.knowledge-reader-heading-row { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 15px; }
.knowledge-reader-icon { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 15px; background: rgba(255,255,255,.09); color: #e8faf5; font-size: 1.35rem; }
.knowledge-reader-header p { margin: 9px 0 0; color: #d5eee7; font-size: .75rem; line-height: 1.75; }
.knowledge-reader-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; font-size: .62rem; }
.knowledge-reader-meta span, .knowledge-reader-meta a { padding: 6px 9px; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; background: rgba(255,255,255,.08); }
.knowledge-reader-meta b { color: #bfe7dc; font-weight: 700; }
.knowledge-reader-meta a:hover { background: rgba(255,255,255,.15); color: #fff; }
.knowledge-canonical-card { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 25px 25px; background: #fff; box-shadow: var(--shadow-md); }
.knowledge-content-label { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px clamp(22px, 4vw, 44px); border-bottom: 1px solid var(--line); background: #fbfdfc; }
.knowledge-content-label span { color: var(--ink-soft); font-size: .73rem; font-weight: 800; }
.knowledge-content-label small { color: var(--muted-2); font-size: .60rem; }
.knowledge-canonical-content { min-height: 280px; padding: clamp(28px, 5vw, 54px); color: #263a36; font-size: .86rem; line-height: 2.15; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Admin */
.admin-wrap { width: min(1450px, 94vw); margin: 26px auto 64px; }
.admin-hero { position: relative; overflow: hidden; min-height: 176px; display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 31px 34px; border-radius: 28px; color: #fff; background: linear-gradient(135deg, #063d37 0%, #07594e 48%, #0b7866 100%); box-shadow: var(--shadow-lg); }
.admin-hero::before, .admin-hero::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none; }
.admin-hero::before { width: 360px; height: 360px; inset-inline-end: -160px; inset-block-start: -215px; box-shadow: 0 0 0 55px rgba(255,255,255,.018); }
.admin-hero::after { width: 180px; height: 180px; inset-inline-start: -80px; inset-block-end: -130px; }
.admin-hero-compact { min-height: 150px; }
.admin-hero-copy { position: relative; z-index: 1; max-width: 840px; }
.admin-hero h1 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 1.95rem); font-weight: 800; letter-spacing: -.35px; }
.admin-hero p { margin: 9px 0 0; color: #d4ece6; font-size: .76rem; line-height: 1.8; }
.admin-hero-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.admin-hero-tags span { padding: 4px 8px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(255,255,255,.075); color: #e7f5f1; font-size: .57rem; direction: ltr; }
.admin-hero-action { position: relative; z-index: 1; min-width: 230px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 10px; padding: 12px; border: 1px solid rgba(255,255,255,.20); border-radius: 16px; background: rgba(255,255,255,.09); color: #fff; backdrop-filter: blur(5px); }
.admin-hero-action:hover { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: #fff; transform: translateY(-1px); }
.admin-hero-action-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.10); font-size: 1.15rem; }
.admin-hero-action strong, .admin-hero-action small { display: block; }
.admin-hero-action strong { font-size: .75rem; }
.admin-hero-action small { margin-top: 3px; color: #cfe9e2; font-size: .58rem; direction: ltr; }
.admin-hero-badge { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; background: rgba(255,255,255,.08); color: #e9f7f3; font-size: .65rem; direction: ltr; }
.admin-menu { margin: 14px 0 19px; display: flex; flex-wrap: wrap; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: var(--shadow-sm); }
.admin-menu a { min-height: 39px; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid transparent; border-radius: 10px; color: #60726e; font-size: .72rem; font-weight: 700; }
.admin-menu a span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: #edf4f1; color: #6e9188; font-size: .72rem; }
.admin-menu a:hover { color: var(--brand); background: var(--brand-softer); }
.admin-menu a.active { border-color: #c7dfd9; color: var(--brand-dark); background: #fff; box-shadow: 0 4px 12px rgba(20,55,48,.05); }
.admin-menu a.active span { background: var(--brand-soft); color: var(--brand); }
.admin-alert { margin: 0 0 14px; box-shadow: var(--shadow-xs); }
.admin-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 21px 2px 11px; }
.admin-section-heading h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.admin-section-heading p { margin: 0; color: var(--muted); font-size: .66rem; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; }
.stat-card { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.90); box-shadow: var(--shadow-sm); }
.stat-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 13px; color: var(--brand); background: var(--brand-soft); font-size: 1.05rem; font-weight: 800; }
.stat-card strong { display: block; color: #172925; font-size: 1.35rem; line-height: 1.1; }
.stat-card span:not(.stat-icon) { display: block; margin-top: 3px; color: #526762; font-size: .68rem; font-weight: 700; }
.stat-card small { display: block; margin-top: 2px; color: var(--muted-2); font-size: .51rem; direction: ltr; text-align: right; }
.stat-card-danger .stat-icon { color: var(--danger); background: var(--danger-soft); }
.stat-card-danger strong { color: var(--danger); }
.admin-card { margin-top: 13px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-sm); }
.admin-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.admin-card-header > div:first-child { display: flex; align-items: center; gap: 11px; min-width: 0; }
.admin-card-icon { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid #d4e6e1; border-radius: 12px; color: var(--brand); background: var(--brand-softer); font-size: .95rem; }
.admin-card h2 { margin: 0; color: #203631; font-size: .91rem; font-weight: 800; }
.admin-card-header p { margin: 3px 0 0; color: var(--muted); font-size: .62rem; line-height: 1.6; }
.admin-card-badge, .panel-step { padding: 4px 8px; border: 1px solid #d8e7e3; border-radius: 999px; background: #f6faf8; color: #758b85; font-size: .54rem; font-weight: 800; direction: ltr; }
.admin-card-header-actions { align-items: center; }
.admin-note { margin-bottom: 14px; padding: 11px 13px; border-radius: 12px; font-size: .70rem; line-height: 1.8; }
.admin-note-info { border: 1px solid #d9eaf5; background: var(--info-soft); color: #3c6682; }
.admin-inline-help { margin: -4px 0 12px; color: var(--muted); font-size: .61rem; }
.admin-table-wrap { overflow-x: auto; overflow-y: hidden; border: 1px solid #e1ebe8; border-radius: 14px; }
.admin-delete-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 150px; }
.admin-delete-actions form { margin: 0; }
.table { margin: 0; color: #324843; font-size: .70rem; vertical-align: middle; }
.table > :not(caption) > * > * { padding: 11px 12px; border-bottom-color: #e8efed; }
.table thead th { white-space: nowrap; color: #5f736e; background: #f7faf9; font-size: .61rem; font-weight: 800; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: #fbfdfc; }
.table code { white-space: nowrap; }
.table-primary-label { color: #253b36; font-weight: 800; }
.table-title-cell { min-width: 170px; font-weight: 700; }
.table-query-cell { min-width: 260px; max-width: 440px; line-height: 1.75; }
.table-link { color: var(--brand); font-weight: 700; white-space: nowrap; }
.table-link:hover { color: var(--brand-dark); text-decoration: underline; }
.nowrap { white-space: nowrap; }
.soft-badge, .dimension-badge, .version-badge, .tenant-pill, .count-pill, .status-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 23px; padding: 3px 7px; border-radius: 999px; white-space: nowrap; font-size: .59rem; font-weight: 700; }
.soft-badge { color: #5f746f; background: #f1f6f4; border: 1px solid #e0e9e7; }
.dimension-badge { color: #586c67; background: #f6f8f8; }
.version-badge { color: #6c4d8c; background: #f6f0fa; }
.tenant-pill { min-width: 28px; color: var(--brand); background: var(--brand-soft); }
.count-pill { min-width: 28px; color: #315f87; background: #edf5fb; }
.status-badge.success { color: var(--success); background: var(--success-soft); }
.status-badge.warning { color: var(--warning); background: var(--warning-soft); }
.status-badge.danger { color: var(--danger); background: var(--danger-soft); }
.status-badge.neutral { color: #61746f; background: #f0f4f3; }
.inline-error { max-width: 520px; color: var(--danger); font-size: .65rem; line-height: 1.7; overflow-wrap: anywhere; }
.table-details { margin-top: 5px; color: var(--warning); }
.table-details summary { cursor: pointer; font-size: .61rem; font-weight: 700; }
.table-details small { display: block; max-width: 560px; margin-top: 5px; color: #8a6b37; line-height: 1.7; overflow-wrap: anywhere; direction: ltr; text-align: left; }
.admin-empty-state { min-height: 130px; display: grid; place-items: center; align-content: center; gap: 6px; border: 1px dashed #ccdcd7; border-radius: 14px; background: #fbfdfc; color: var(--muted); text-align: center; }
.admin-empty-state > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 1rem; }
.admin-empty-state strong { color: #50635f; font-size: .72rem; }
.admin-empty-state p { margin: 0; font-size: .62rem; }
.admin-split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-form-panel { padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fbfdfc; }
.admin-form-panel-accent { border-color: #c9e1da; background: var(--brand-softer); }
.admin-form-panel h3 { margin: 8px 0 5px; font-size: .80rem; font-weight: 800; }
.admin-form-panel > p { min-height: 38px; margin: 0 0 13px; color: var(--muted); font-size: .65rem; line-height: 1.7; }

/* Admin ingestion forms */
.admin-form-card { padding: 24px; }
.form-section { padding: 2px 0 22px; }
.form-section + .form-section { padding-top: 21px; border-top: 1px solid #e5eeeb; }
.form-section-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.form-section-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; color: var(--brand); background: var(--brand-soft); font-size: .58rem; font-weight: 900; direction: ltr; }
.form-section-heading h3 { margin: 0; color: #263c37; font-size: .82rem; font-weight: 800; }
.form-section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .62rem; line-height: 1.65; }
.code-input { direction: ltr; text-align: left; font-family: Consolas, "Courier New", monospace; font-size: .72rem; }
.input-with-prefix { position: relative; }
.input-with-prefix > span { position: absolute; z-index: 2; inset-inline-start: 12px; inset-block-start: 50%; transform: translateY(-50%); color: #78a69a; font-size: .85rem; }
.input-with-prefix .form-control { padding-inline-start: 36px; direction: ltr; text-align: left; }
.input-with-prefix-lg > span { font-size: 1rem; }
.file-control { padding-block: 8px; }
.form-submit-bar { margin-top: 3px; padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid #d2e3de; border-radius: 15px; background: linear-gradient(90deg, #f7fbf9, #eef8f4); }
.form-submit-bar strong, .form-submit-bar span { display: block; }
.form-submit-bar strong { color: #2d443f; font-size: .74rem; }
.form-submit-bar span { margin-top: 3px; color: var(--muted); font-size: .61rem; }
.form-submit-bar .btn-lg { min-height: 46px; font-size: .75rem; }

/* Responsive */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-shell { grid-template-columns: 275px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .topbar { min-height: 64px; }
  .topbar-inner { width: min(100% - 20px, 100%); min-height: 64px; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 7px 0; }
  .topbar-nav { width: max-content; max-width: 100%; justify-self: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a { min-height: 35px; padding-inline: 10px; }
  .topbar-brand-copy small { display: none; }
  .app-main { min-height: calc(100vh - 64px); min-height: calc(100dvh - 64px); }
  .chat-page .app-main { height: calc(100vh - 64px); height: calc(100dvh - 64px); }

  .chat-shell { width: 100%; height: 100%; margin: 0; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none; }
  .conversation-panel { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto; align-items: center; gap: 10px; padding: 9px 13px; border-left: 0; border-bottom: 1px solid var(--line); overflow: hidden; }
  .conversation-panel-top { padding: 0; border: 0; }
  .brand-card { display: none; }
  .new-chat-button { width: auto; min-width: 142px; min-height: 42px; margin: 0; padding-inline: 11px; }
  .conversation-section-title { display: none; }
  .conversation-list { min-width: 0; display: flex; overflow-x: auto; overflow-y: hidden; gap: 6px; padding: 1px 0 3px; }
  .conversation-item { min-width: 170px; max-width: 220px; padding: 7px 10px; border-color: #e0e9e6; background: #fff; }
  .conversation-item small { display: none; }
  .conversation-panel-footer { display: none; }
  .chat-panel { min-height: 0; }
  .messages { min-height: 0; padding: 22px 14px; }
  .chat-header { min-height: 78px; padding: 13px 16px; }
  .chat-header p { display: none; }
  .status-pill { padding: 6px 9px; }
  .composer { margin: 0 12px 12px; }
  .suggestions { grid-template-columns: 1fr; }
  .empty-chat { margin-top: 32px; }

  .knowledge-search-shell, .knowledge-reader-shell { width: 100%; margin: 0 auto 42px; }
  .search-hero, .knowledge-reader-header { border-radius: 0; }
  .search-hero { display: block; padding: 26px 20px; }
  .search-back-link { margin-top: 20px; }
  .knowledge-search-workspace { margin: 12px; padding: 10px; border-radius: 18px; }
  .knowledge-search-form { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .knowledge-search-icon { width: 34px; }
  .knowledge-search-form button { min-width: 92px; }
  .search-help-row { display: none; }
  .knowledge-reader-nav { margin: 12px; }
  .knowledge-canonical-card { border-inline: 0; border-radius: 0; }
  .knowledge-reader-header { border-inline: 0; }

  .admin-wrap { width: 100%; margin: 0 auto 45px; }
  .admin-hero { min-height: auto; display: block; padding: 25px 20px; border-radius: 0; }
  .admin-hero-action, .admin-hero-badge { margin-top: 18px; }
  .admin-menu { margin: 10px 10px 16px; flex-wrap: nowrap; overflow-x: auto; border-radius: 14px; }
  .admin-menu a { flex: 0 0 auto; }
  .admin-section-heading { padding-inline: 12px; }
  .admin-section-heading p { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 10px; }
  .admin-card { margin: 12px 10px 0; padding: 16px; border-radius: 17px; }
  .admin-card-header-actions { align-items: flex-start; flex-direction: column; }
  .admin-split-grid { grid-template-columns: 1fr; }
  .form-submit-bar { align-items: stretch; flex-direction: column; }
  .form-submit-bar .btn { width: 100%; }
}

@media (max-width: 560px) {
  .topbar-inner { width: calc(100% - 12px); gap: 5px; }
  .topbar-brand { min-width: 35px; }
  .topbar-brand-mark { width: 35px; height: 35px; border-radius: 11px; }
  .topbar-brand-copy { display: none; }
  .topbar-nav { padding: 3px; }
  .topbar-nav a { min-height: 33px; padding-inline: 8px; font-size: .66rem; }
  .topbar-nav .nav-dot { display: none; }
  .account-link { min-height: 35px; padding: 4px; }
  .account-label, .account-register { display: none; }
  .account-icon { width: 27px; height: 27px; flex-basis: 27px; }
  .account-login { padding-inline: 8px; font-size: .67rem; }
  .conversation-panel { gap: 7px; padding: 8px; }
  .new-chat-button { min-width: 44px; width: 44px; padding: 0; }
  .new-chat-button > span:last-child { display: none; }
  .new-chat-icon { background: transparent; }
  .conversation-item { min-width: 145px; max-width: 185px; }
  .chat-header { gap: 8px; }
  .page-kicker { display: none; }
  .status-pill { font-size: .58rem; }
  .message { gap: 7px; }
  .message-avatar { width: 30px; height: 30px; flex-basis: 30px; border-radius: 10px; }
  .message-body { padding: 12px 13px; font-size: .80rem; }
  .composer { margin: 0 8px 8px; grid-template-columns: minmax(0, 1fr) 44px; }
  .composer > button { width: 42px; height: 42px; }
  .composer-hint span:nth-child(-n+2) { display: none; }
  .empty-icon { width: 62px; height: 62px; border-radius: 20px; }
  .empty-chat { margin-top: 18px; }
  .empty-chat > p { font-size: .72rem; }
  .suggestions { margin-top: 16px; gap: 7px; }
  .suggestions button { min-height: 44px; }

  .knowledge-search-form { grid-template-columns: 30px minmax(0, 1fr) 48px; padding: 6px; }
  .knowledge-search-form button { min-width: 48px; width: 48px; padding: 0; }
  .knowledge-search-form button span:first-child { display: none; }
  .semantic-result { grid-template-columns: 34px minmax(0,1fr); padding: 12px 10px; }
  .semantic-result-rank { width: 31px; height: 31px; }
  .knowledge-reader-heading-row { gap: 10px; }
  .knowledge-reader-icon { width: 40px; height: 40px; flex-basis: 40px; }
  .knowledge-content-label { align-items: flex-start; flex-direction: column; gap: 3px; }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 9px; }
  .stat-icon { width: 36px; height: 36px; flex-basis: 36px; border-radius: 11px; }
  .stat-card strong { font-size: 1.1rem; }
  .admin-card { margin-inline: 8px; padding: 14px; }
  .admin-card-header { align-items: flex-start; }
  .admin-card-icon { width: 34px; height: 34px; flex-basis: 34px; }
  .admin-card-badge { display: none; }
}

@media (max-height: 680px) {
  .chat-header { min-height: 64px; padding-block: 9px; }
  .chat-header p { display: none; }
  .messages { padding-block: 16px; }
  .empty-chat { margin-top: 10px; }
  .empty-icon { width: 52px; height: 52px; margin-bottom: 10px; border-radius: 17px; font-size: 1.35rem; }
  .suggestions { margin-top: 13px; }
  .composer-hint { display: none; }
}

.admin-json-payload {
  max-width: min(62vw, 64rem);
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.75rem;
  text-align: left;
}
