:root {
  --navy: #0b2344;
  --navy-2: #163d6b;
  --blue: #1267d9;
  --blue-soft: #e9f3ff;
  --text: #15243b;
  --muted: #667791;
  --line: #dce6f1;
  --surface: #ffffff;
  --canvas: #f3f7fb;
  --shadow: 0 10px 28px rgba(21, 50, 85, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: inherit; }

button,
input { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 78px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 42px;
  background: #b8c5d5;
}

.brand-copy { min-width: 0; }

.brand-copy strong {
  display: block;
  color: var(--navy);
  font-size: 22px;
  line-height: 1.1;
}

.brand-copy span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.user-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border: 1px solid #d7e2ef;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-fallback {
  display: grid;
  place-items: center;
  background: #eaf2fb;
  color: #24466f;
  font-size: 18px;
}

.user-copy { min-width: 0; }

.user-copy strong,
.user-copy span {
  display: block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong { font-size: 14px; }
.user-copy span { color: var(--muted); font-size: 12px; }

.app-layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 78px;
  height: calc(100vh - 78px);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fff;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-link {
  min-height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  color: #38506e;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.side-link i {
  width: 22px;
  color: #24466f;
  font-size: 17px;
  text-align: center;
}

.side-link:hover,
.side-link.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.side-link:hover i,
.side-link.active i { color: var(--blue); }

.side-link.portal-link {
  margin-top: auto;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.main-content {
  min-width: 0;
  padding: 22px;
}

.content-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.hero {
  position: relative;
  min-height: 310px;
  padding: 34px 42px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #173d68 url("/assets/policy-hero.png") center / cover no-repeat;
  box-shadow: var(--shadow);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(5, 31, 61, .48);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(780px, 100%);
  color: #fff;
}

.hero-ai-button {
  width: fit-content;
  min-height: 38px;
  margin-bottom: 14px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.hero-ai-button:hover { background: #fff; color: var(--blue); }

.hero h1 {
  margin: 0;
  font-size: 44px;
  line-height: 1.18;
}

.hero-lead {
  margin: 8px 0 22px;
  color: #eef5ff;
  font-size: 17px;
}

.policy-search {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 5px 5px 5px 18px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(0, 22, 54, .22);
}

.policy-search > i {
  color: #2f527d;
  font-size: 20px;
}

.policy-search input {
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 16px;
}

.policy-search button {
  height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.quick-search {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quick-search > span {
  margin-right: 3px;
  color: #e7f1ff;
  font-size: 13px;
}

.quick-tag {
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 18px;
  background: rgba(255, 255, 255, .9);
  color: #183b66;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.section-block {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(35, 66, 105, .05);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-count {
  padding: 5px 10px;
  border-radius: 8px;
  background: #eef5ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.category-card {
  min-width: 0;
  min-height: 114px;
  padding: 14px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: #9ec0e8;
  box-shadow: 0 10px 22px rgba(24, 70, 121, .1);
}

.category-icon {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--tone-bg, #eaf2ff);
  color: var(--tone, #276cd2);
  font-size: 19px;
}

.category-copy { min-width: 0; }

.category-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.42;
}

.category-copy span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.category-card > i {
  color: #7990aa;
  font-size: 12px;
}

.tone-blue { --tone: #1768d6; --tone-bg: #e8f2ff; }
.tone-cyan { --tone: #078eb5; --tone-bg: #e5f8fd; }
.tone-green { --tone: #13995b; --tone-bg: #e6f8ee; }
.tone-orange { --tone: #e87815; --tone-bg: #fff1e4; }
.tone-purple { --tone: #7c4bd8; --tone-bg: #f0eafe; }
.tone-teal { --tone: #078c82; --tone-bg: #e4f7f5; }
.tone-red { --tone: #d94b57; --tone-bg: #fdebed; }
.tone-slate { --tone: #526a86; --tone-bg: #edf2f7; }

.dashboard-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr);
  gap: 16px;
}

.chapter-rows {
  display: grid;
}

.chapter-row {
  min-width: 0;
  min-height: 62px;
  padding: 9px 4px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e7edf4;
  text-decoration: none;
}

.chapter-row:last-child { border-bottom: 0; }

.chapter-row:hover .chapter-row-title { color: var(--blue); }

.chapter-row-number {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.chapter-row-copy { min-width: 0; }

.chapter-row-title {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
}

.chapter-row-copy small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-row-page {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chapter-row > i { color: #8ba0b8; font-size: 11px; }

.document-overview {
  display: grid;
  gap: 12px;
}

.document-badge {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #e8f2ff;
  color: var(--blue);
  font-size: 21px;
}

.document-overview h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
}

.document-overview > p {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.document-stats {
  display: grid;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.document-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.document-stat span { color: var(--muted); }

.search-empty {
  display: none;
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed #b9c9da;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.search-empty.show { display: block; }

/* Policy dashboard */
.policy-dashboard {
  background: #f3f5f7;
  color: #172338;
  font-family: "Leelawadee UI", "Noto Sans Thai", Tahoma, "Segoe UI", sans-serif;
}

.policy-dashboard .topbar {
  border-bottom-color: #dce3eb;
  background: rgba(255, 255, 255, .98);
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.language-switch {
  width: 78px;
  height: 36px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #cfd9e4;
  border-radius: 8px;
  background: #f1f4f7;
}

.language-switch button {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #64758a;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.language-switch button.active {
  background: #1767a8;
  color: #fff;
  box-shadow: 0 2px 6px rgba(17, 72, 117, .18);
}

.language-switch button:disabled {
  cursor: wait;
  opacity: .58;
}

.policy-dashboard .brand-copy strong { color: #102b4b; font-weight: 800; }
.policy-dashboard .brand-copy span { color: #68788b; }
.policy-dashboard .sidebar { border-right-color: #dce3eb; background: #fbfcfd; }
.policy-dashboard .side-link { color: #455a71; font-weight: 700; }
.policy-dashboard .side-link:hover,
.policy-dashboard .side-link.active { background: #eaf2fa; color: #115e9f; }
.policy-dashboard .side-link:hover i,
.policy-dashboard .side-link.active i { color: #115e9f; }

.policy-dashboard .main-content {
  padding: 18px 22px 28px;
  background: #f3f5f7;
}

.policy-dashboard .content-shell { width: min(1240px, 100%); }

.policy-dashboard .hero {
  min-height: 248px;
  padding: 26px 32px;
  align-items: center;
  background-position: center 48%;
  box-shadow: 0 8px 24px rgba(16, 43, 75, .1);
}

.policy-dashboard .hero::before { background: rgba(7, 29, 51, .54); }

.policy-dashboard .hero-content { width: min(860px, 100%); }

.policy-dashboard .hero-kicker {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.policy-dashboard .hero-kicker > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #e8eef5;
  font-size: 12px;
  font-weight: 800;
}

.policy-dashboard .hero-ai-button {
  min-height: 36px;
  margin: 0;
  padding: 0 13px;
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, .35);
  background: #f3b45a;
  color: #172d45;
  box-shadow: 0 4px 12px rgba(38, 27, 11, .16);
}

.policy-dashboard .hero-ai-button:hover { background: #ffc66f; color: #10263f; }

.policy-dashboard .hero h1 {
  color: #fff;
  font-size: 35px;
  font-weight: 800;
  line-height: 1.26;
  text-shadow: 0 2px 12px rgba(0, 16, 34, .2);
}

.policy-dashboard .hero-lead {
  margin: 5px 0 16px;
  color: #edf2f7;
  font-size: 15px;
  font-weight: 400;
}

.policy-dashboard .policy-search {
  min-height: 54px;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  border-color: rgba(255, 255, 255, .6);
  box-shadow: 0 8px 20px rgba(0, 22, 54, .16);
}

.policy-dashboard .policy-search > i { color: #60758d; }
.policy-dashboard .policy-search input { height: 42px; color: #1b2a3d; font-size: 15px; }
.policy-dashboard .policy-search input::placeholder { color: #8492a3; opacity: 1; }
.policy-dashboard .policy-search button { height: 42px; background: #1767a8; font-weight: 700; }
.policy-dashboard .policy-search button:hover { background: #0f568f; }
.policy-dashboard .quick-search { margin-top: 11px; }
.policy-dashboard .quick-search > span { color: #dde7f1; }
.policy-dashboard .quick-tag {
  min-height: 30px;
  border-color: rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .94);
  color: #27435f;
  font-weight: 700;
}

.policy-dashboard .section-block {
  margin-top: 12px;
  padding: 16px;
  border-color: #dde4eb;
  box-shadow: 0 4px 16px rgba(35, 66, 105, .04);
}

.policy-dashboard .section-heading { margin-bottom: 11px; }
.policy-dashboard .section-heading h2 { color: #172a40; font-size: 18px; font-weight: 800; }
.policy-dashboard .section-heading p { color: #6b7b8d; }
.policy-dashboard .section-count { background: #edf3f8; color: #315c82; }
.policy-dashboard .category-grid { gap: 8px; }

.policy-dashboard .category-card {
  min-height: 98px;
  padding: 12px;
  grid-template-columns: 42px minmax(0, 1fr) 14px;
  gap: 10px;
  border-color: #dfe6ed;
  background: #fff;
  box-shadow: none;
}

.policy-dashboard .category-card:hover {
  transform: none;
  border-color: #9fb6ca;
  background: #fbfcfe;
  box-shadow: 0 4px 12px rgba(32, 58, 83, .06);
}

.policy-dashboard .category-icon {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.policy-dashboard .category-copy strong { color: #1a2b40; font-size: 13px; font-weight: 800; }
.policy-dashboard .category-copy span { color: #6b7b8d; }
.policy-dashboard .dashboard-lower { gap: 12px; }
.policy-dashboard .chapter-row { min-height: 58px; }
.policy-dashboard .chapter-row:hover { background: #f7fafc; }
.policy-dashboard .chapter-row-title { color: #26394e; }
.policy-dashboard .document-overview { gap: 10px; }
.policy-dashboard .document-language-note {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid #d8a04d;
  background: #fff8eb;
  color: #795a2b;
  font-size: 11px;
  line-height: 1.5;
}
.policy-dashboard .document-badge {
  width: 44px;
  height: 44px;
  background: #fff2df;
  color: #bb6e15;
}

/* HR policy assistant */
.assistant-main {
  min-width: 0;
  height: calc(100vh - 78px);
  height: calc(100dvh - 78px);
  padding: 18px 22px;
  overflow: hidden;
  background: #f5f8fc;
}

.assistant-shell {
  width: min(1160px, 100%);
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.assistant-intro {
  flex: 0 0 auto;
  padding: 15px 18px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(21, 50, 85, .05);
}

.assistant-mark {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #1768d6;
  color: #fff;
  font-size: 19px;
}

.assistant-eyebrow {
  display: block;
  margin-bottom: 2px;
  color: #58718e;
  font-size: 10px;
  font-weight: 900;
}

.assistant-intro h1 {
  margin: 0;
  color: var(--navy);
  font-size: 23px;
  line-height: 1.25;
}

.assistant-intro p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.assistant-status {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #bde8d1;
  border-radius: 8px;
  background: #eaf9f1;
  color: #087946;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.assistant-layout {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 12px;
  align-items: stretch;
}

.chat-panel,
.answer-guide {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(35, 66, 105, .04);
}

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

.chat-messages {
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  background: #f8fafc;
  scrollbar-color: #c2d1e1 transparent;
  scrollbar-width: thin;
}

.chat-message {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-message.is-user { justify-content: flex-end; }

.message-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1768d6;
  color: #fff;
  font-size: 14px;
}

.message-bubble {
  max-width: min(720px, 86%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(31, 65, 103, .04);
}

.is-user .message-bubble {
  border-color: var(--blue);
  background: #1768d6;
  color: #fff;
}

.message-bubble strong { display: block; font-size: 14px; }

.message-bubble p {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.75;
}

.message-bubble .answer-text {
  margin-top: 0;
  white-space: pre-wrap;
}

.source-title {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: #536b86;
  font-size: 12px !important;
}

.answer-sources {
  margin-top: 8px;
  display: grid;
  gap: 7px;
}

.answer-sources a {
  min-width: 0;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 10px;
  border: 1px solid #d8e7f8;
  border-radius: 7px;
  background: #f4f9ff;
  color: var(--blue);
  text-decoration: none;
}

.answer-sources a span { font-size: 12px; font-weight: 900; }
.answer-sources a small { grid-column: 1; color: #536b86; font-size: 11px; }
.answer-sources a i { grid-column: 2; grid-row: 1 / 3; font-size: 11px; }
.answer-sources a:hover { border-color: #98bfea; background: #eef6ff; }

.answer-warning {
  margin-top: 10px;
  display: block;
  color: #876214;
  font-size: 11px;
  line-height: 1.5;
}

.suggested-questions {
  padding: 10px 16px 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.suggested-questions > span {
  margin-right: 2px;
  color: #6a7e95;
  font-size: 11px;
  font-weight: 800;
}

.suggested-questions button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #cfe0f3;
  border-radius: 18px;
  background: #f7faff;
  color: #315477;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.suggested-questions button:hover { border-color: #8bb7ea; color: var(--blue); }

.chat-composer {
  padding: 10px 16px 7px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.chat-composer textarea {
  width: 100%;
  min-height: 52px;
  max-height: 140px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid #c9d8e8;
  border-radius: 8px;
  outline: 0;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.chat-composer textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 103, 217, .12);
}

.chat-composer button {
  min-height: 54px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: #1768d6;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.chat-composer button:disabled { opacity: .55; cursor: wait; }

.composer-note {
  margin: 0;
  padding: 0 16px 12px;
  color: #7a8ca1;
  font-size: 11px;
}

.answer-guide {
  padding: 18px;
  align-self: start;
  box-shadow: none;
}

.answer-guide h2 {
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--navy);
  font-size: 16px;
}

.answer-guide h2 i { color: #15945b; }

.answer-guide ul {
  margin: 0;
  padding-left: 22px;
  color: #405873;
  font-size: 13px;
  line-height: 1.85;
}

.guide-warning {
  margin-top: 16px;
  padding: 13px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  border: 1px solid #f1d99f;
  border-radius: 8px;
  background: #fffbef;
  color: #775714;
}

.guide-warning > i { margin-top: 2px; font-size: 19px; text-align: center; }
.guide-warning strong,
.guide-warning span { display: block; }
.guide-warning strong { font-size: 13px; }
.guide-warning span { margin-top: 3px; font-size: 11px; line-height: 1.55; }

.is-loading .message-bubble { display: flex; gap: 5px; }

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7891ad;
  animation: typing-pulse 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typing-pulse {
  0%, 70%, 100% { opacity: .3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reader */
.reader-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}

.reader-sidebar {
  position: sticky;
  top: 78px;
  height: calc(100vh - 78px);
  padding: 16px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fff;
}

.reader-back {
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #34506f;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.reader-ai-link {
  min-height: 42px;
  margin-top: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #bcd7f7;
  border-radius: 8px;
  background: #edf6ff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.reader-ai-link:hover { border-color: #7eafe8; background: #e4f1ff; }

.toc-label {
  margin: 18px 8px 8px;
  color: #7a8da5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.toc-list {
  display: grid;
  gap: 5px;
}

.toc-link {
  min-height: 48px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border-radius: 8px;
  color: #405873;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.toc-link:hover,
.toc-link.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.toc-number {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #edf3f9;
  font-weight: 800;
}

.toc-link.active .toc-number {
  background: var(--blue);
  color: #fff;
}

.reader-main {
  min-width: 0;
  padding: 22px;
}

.reader-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.breadcrumb {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb a { color: var(--blue); text-decoration: none; }

.reader-hero {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.reader-chapter-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #e8f2ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.reader-hero h1 {
  margin: 8px 0 0;
  font-size: 32px;
  line-height: 1.28;
}

.reader-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.reader-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bdccdc;
  border-radius: 8px;
  background: #fff;
  color: #26496f;
  text-decoration: none;
  cursor: pointer;
}

.icon-button:hover { border-color: var(--blue); color: var(--blue); }
.icon-button.disabled { opacity: .35; pointer-events: none; }
.icon-button:disabled { opacity: .38; cursor: not-allowed; }
.icon-button.text-reset { font-size: 17px; font-weight: 900; }

.reader-toolbar {
  position: sticky;
  top: 88px;
  z-index: 20;
  margin-top: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 20px rgba(21, 50, 85, .08);
}

.toolbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.toolbar-title i { color: var(--blue); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ocr-notice {
  margin-top: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid #b9d8f7;
  border-radius: 8px;
  background: #eef7ff;
  color: #264d73;
}

.ocr-notice > i {
  margin-top: 3px;
  color: var(--blue);
}

.ocr-notice strong,
.ocr-notice span { display: block; }

.ocr-notice strong {
  color: #173d66;
  font-size: 13px;
}

.ocr-notice span {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.55;
}

.reader-pages {
  --reader-font-size: 17px;
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

.policy-text-page {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(21, 50, 85, .06);
}

.policy-text-page-header {
  min-height: 50px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #f7faff;
}

.policy-text-page-header div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.policy-text-page-header span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.policy-text-page-header strong {
  color: var(--navy);
  font-size: 15px;
}

.policy-text-page-header > a {
  color: #7a91ab;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.policy-clauses { padding: 0 18px; }

.policy-clause {
  padding: 17px 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 17px;
  border-bottom: 1px solid #e7edf4;
}

.policy-clause:last-child { border-bottom: 0; }

.clause-number {
  min-height: 36px;
  padding: 7px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #e9f3ff;
  color: #145fbf;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.clause-number.is-empty {
  width: 38px;
  color: #6b7890;
  background: #eef2f6;
}

.clause-content {
  min-width: 0;
  color: #263951;
  font-size: var(--reader-font-size);
  line-height: 1.82;
}

.clause-content p {
  margin: 0 0 9px;
  overflow-wrap: anywhere;
}

.clause-content p:last-child { margin-bottom: 0; }

.clause-content .clause-lead {
  color: #142844;
  font-weight: 700;
}

.policy-clause.kind-notice,
.policy-clause.kind-signature { background: #fffdf6; }

.policy-clause.kind-notice .clause-content .clause-lead,
.policy-clause.kind-signature .clause-content .clause-lead { color: #6c4a10; }

.policy-empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.source-check {
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.source-check summary {
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #365472;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.source-check summary::-webkit-details-marker { display: none; }
.source-check summary span { display: inline-flex; align-items: center; gap: 8px; }
.source-check summary span i { color: var(--blue); }
.source-check .summary-chevron { color: #7890aa; transition: transform .18s ease; }
.source-check[open] .summary-chevron { transform: rotate(180deg); }

.source-image-wrap {
  max-height: 82vh;
  padding: 14px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #e9eef5;
}

.source-image-wrap img {
  width: min(920px, 100%);
  height: auto;
  margin: 0 auto;
  display: block;
  background: #fff;
  box-shadow: 0 8px 22px rgba(17, 40, 68, .14);
}

.reader-footer-nav {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chapter-nav-card {
  min-height: 72px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}

.chapter-nav-card.next { justify-content: flex-end; text-align: right; }
.chapter-nav-card.disabled { visibility: hidden; }

.chapter-nav-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.chapter-nav-card strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 1100px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-lower { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: 1fr; }
  .answer-guide { display: none; }
}

@media (max-width: 900px) {
  .topbar { min-height: 70px; padding: 8px 14px; }
  .brand-logo { width: 46px; height: 46px; }
  .brand-divider { display: none; }
  .brand-copy strong { font-size: 18px; }
  .brand-copy span { display: none; }
  .user-copy { display: none; }

  .app-layout,
  .reader-layout { grid-template-columns: 1fr; }

  .sidebar,
  .reader-sidebar {
    position: sticky;
    top: 70px;
    z-index: 40;
    height: auto;
    padding: 8px 12px;
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav,
  .toc-list {
    width: max-content;
    display: flex;
    gap: 6px;
  }

  .side-link {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
  }

  .side-link.portal-link { margin-top: 0; }
  .reader-back,
  .reader-ai-link { display: none; }
  .toc-label { display: none; }

  .toc-link {
    min-height: 40px;
    padding: 5px 9px;
    grid-template-columns: 26px auto;
    border: 1px solid var(--line);
    white-space: nowrap;
  }

  .toc-number { width: 26px; height: 26px; }
  .main-content,
  .reader-main,
  .assistant-main { padding: 14px; }
  .assistant-main {
    height: calc(100vh - 122px);
    height: calc(100dvh - 122px);
  }
  .reader-toolbar { top: 122px; }
  .policy-clause { grid-template-columns: 78px minmax(0, 1fr); gap: 13px; }
}

@media (max-width: 640px) {
  .brand-copy strong { font-size: 16px; }
  .user-avatar { width: 38px; height: 38px; }
  .main-content,
  .reader-main,
  .assistant-main { padding: 10px; }
  .hero { min-height: 360px; padding: 24px 18px; background-position: 68% center; }
  .hero::before { background: rgba(5, 31, 61, .6); }
  .hero h1 { font-size: 29px; }
  .hero-lead { font-size: 15px; }
  .policy-search { grid-template-columns: 24px minmax(0, 1fr); padding-right: 10px; }
  .policy-search button { grid-column: 1 / -1; width: 100%; }
  .category-grid { grid-template-columns: 1fr; }
  .category-card { min-height: 92px; }
  .section-block { padding: 14px; }
  .chapter-row { grid-template-columns: 32px minmax(0, 1fr) 14px; }
  .chapter-row-page { display: none; }
  .reader-hero { grid-template-columns: 1fr; }
  .reader-hero h1 { font-size: 26px; }
  .reader-navigation { justify-content: flex-end; }
  .reader-toolbar { top: 118px; }
  .toolbar-title span { display: none; }
  .reader-pages { gap: 10px; }
  .policy-clauses { padding: 0 13px; }
  .policy-clause {
    padding: 14px 0;
    grid-template-columns: 1fr;
    gap: 9px;
  }
  .clause-number { width: fit-content; min-width: 66px; }
  .clause-content { line-height: 1.72; }
  .policy-text-page-header { padding: 8px 13px; }
  .source-image-wrap { padding: 8px; }
  .reader-footer-nav { grid-template-columns: 1fr; }
  .assistant-intro { grid-template-columns: 42px minmax(0, 1fr); padding: 12px; }
  .assistant-mark { width: 42px; height: 42px; }
  .assistant-intro h1 { font-size: 20px; }
  .assistant-intro p { font-size: 12px; }
  .assistant-status { grid-column: 1 / -1; width: fit-content; }
  .assistant-layout { margin-top: 8px; }
  .chat-messages { min-height: 0; height: auto; padding: 14px; }
  .message-bubble { max-width: 91%; }
  .suggested-questions { padding: 9px 12px 3px; flex-wrap: nowrap; overflow-x: auto; }
  .suggested-questions > span { flex: 0 0 auto; }
  .suggested-questions button { flex: 0 0 auto; }
  .chat-composer { padding: 10px 12px 6px; grid-template-columns: minmax(0, 1fr) 52px; }
  .chat-composer button { width: 52px; padding: 0; justify-content: center; }
  .chat-composer button span { display: none; }
  .composer-note { padding: 0 12px 12px; }
}

@media (max-width: 900px) {
  .policy-dashboard .main-content { padding: 14px; }
  .policy-dashboard .hero { min-height: 232px; padding: 24px; }
  .policy-dashboard .hero h1 { font-size: 32px; }
}

@media (max-width: 640px) {
  .topbar-actions { gap: 8px; }
  .topbar-actions .user-block { display: none; }
  .language-switch { width: 74px; }
  .language-switch button { width: 32px; }
  .policy-dashboard .main-content { padding: 10px; }
  .policy-dashboard .hero {
    min-height: 300px;
    padding: 20px 16px;
    background-position: 64% center;
  }
  .policy-dashboard .hero::before { background: rgba(7, 33, 62, .64); }
  .policy-dashboard .hero-kicker { align-items: flex-start; }
  .policy-dashboard .hero-kicker > span { padding-top: 8px; }
  .policy-dashboard .hero-ai-button { min-height: 34px; padding: 0 11px; }
  .policy-dashboard .hero h1 { font-size: 27px; }
  .policy-dashboard .hero-lead { font-size: 14px; }
  .policy-dashboard .policy-search { grid-template-columns: 24px minmax(0, 1fr); }
  .policy-dashboard .section-block { padding: 13px; }
  .policy-dashboard .category-card { min-height: 88px; }
}

@media print {
  .topbar,
  .reader-sidebar,
  .breadcrumb,
  .reader-hero,
  .reader-toolbar,
  .reader-footer-nav { display: none !important; }

  .reader-layout { display: block; }
  .reader-main { padding: 0; }
  .ocr-notice { display: none; }
  .reader-pages { display: block; }
  .policy-text-page { border: 0; border-radius: 0; box-shadow: none; break-after: page; }
  .policy-text-page-header { padding-left: 0; padding-right: 0; background: #fff; }
  .policy-clauses { padding: 0; }
  .source-check { display: none; }
}

