/* Clean Medical Bilingual Reader Stylesheet (No Emojis, Robust Mobile RWD) */
:root {
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --header-height: 58px;
  --sidebar-width: 280px;
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-code: "JetBrains Mono", Consolas, Monaco, monospace;
}

[data-theme="sepia"] {
  --primary: #92400e;
  --primary-hover: #78350f;
  --primary-light: #fef3c7;
  --text-main: #292524;
  --text-muted: #78716c;
  --bg-body: #fbf7ee;
  --bg-card: #f5eedc;
  --border-color: #e7dfcc;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --border-color: #334155;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  position: relative;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Visibility Helpers */
.desktop-only {
  display: flex !important;
}
.mobile-only {
  display: none !important;
}

/* App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.header-title-box {
  display: flex;
  flex-direction: column;
}

.header-main-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Site Selector Dropdown */
.site-dropdown-wrapper {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
}

.site-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.site-selector-btn:hover {
  border-color: var(--primary);
  background-color: var(--bg-card);
}

.dropdown-chevron {
  font-size: 0.65rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.site-dropdown-wrapper.open .dropdown-chevron {
  transform: rotate(180deg);
}

.site-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 310px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
  padding: 0.4rem;
  z-index: 200;
}

.site-dropdown-wrapper.open .site-dropdown-menu {
  display: block;
}

.menu-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem 0.25rem 0.6rem;
}

.site-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-main);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s;
}

.site-menu-item:hover {
  background-color: var(--bg-body);
}

.site-menu-item.active {
  background-color: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-weight: 700;
}

.site-item-icd {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-family: var(--font-code);
  margin-left: auto;
  margin-right: 0.5rem;
}

.site-item-badge {
  font-size: 0.675rem;
  padding: 2px 5px;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
}

.mobile-site-select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 160px;
}

/* Desktop Search */
.header-center {
  flex: 1;
  max-width: 440px;
  margin: 0 1rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-label {
  position: absolute;
  left: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-card);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}

/* Header Controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.65rem;
  font-size: 0.825rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background-color: var(--border-color);
}

.btn-menu {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.825rem;
}

.menu-icon-bars {
  display: inline-block;
  width: 14px;
  height: 2px;
  background-color: var(--text-main);
  position: relative;
}
.menu-icon-bars::before, .menu-icon-bars::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 2px;
  background-color: var(--text-main);
  left: 0;
}
.menu-icon-bars::before { top: -4px; }
.menu-icon-bars::after { top: 4px; }

.btn-action {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-icon-compact {
  padding: 0.35rem 0.55rem;
  font-size: 0.825rem;
  font-weight: 600;
}

/* Segmented Control (Desktop) */
.segmented-control {
  display: inline-flex;
  background-color: var(--bg-body);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.segment-btn {
  border: none;
  background: transparent;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.segment-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* Mobile Select in Header */
.mobile-select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.825rem;
  font-weight: 500;
  outline: none;
}

/* Mobile Sub-Toolbar */
.mobile-sub-toolbar {
  padding: 0.5rem 15px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.mobile-search-input {
  width: 100%;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 0.825rem;
}

/* Layout */
.app-container {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 1rem 0.75rem;
  flex-shrink: 0;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
}

.sidebar-header-box {
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-body);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}
.sidebar-manual-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}
.sidebar-manual-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}
.sidebar-chapter-name {
  font-size: 0.775rem;
  color: var(--text-main);
}

.sidebar-section-title {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin: 1.25rem 0 0.4rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background-color: var(--bg-body);
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  background-color: var(--border-color);
  color: var(--text-muted);
}
.nav-item.active .badge {
  background-color: var(--primary);
  color: white;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem 0.4rem;
}
.filter-tag {
  cursor: pointer;
}
.filter-tag:hover {
  background-color: var(--primary);
  color: white;
}

.sidebar-note {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.4rem;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 1.25rem 15px 4rem 15px;
  margin: 0;
  overflow-y: auto;
  min-width: 0;
  width: 100%;
}

/* Chapter Banner */
.chapter-hero {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
}

.chapter-hero-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.chapter-hero-meta {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.meta-pill {
  background: var(--bg-body);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-family: var(--font-code);
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* Section Header */
.section-heading {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.6rem;
  margin: 2rem 0 1rem 0;
}

.section-heading h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.section-subtext {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* Reading Modes */
.view-split .bilingual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.view-stacked .bilingual-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.view-zh-only .lang-col-en {
  display: none !important;
}
.view-en-only .lang-col-zh {
  display: none !important;
}

/* Rule Card */
.rule-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s;
}

.rule-card:hover {
  border-color: var(--primary);
}

.rule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.rule-badge {
  background-color: var(--primary);
  color: white;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.775rem;
  font-family: var(--font-code);
}

.rule-category-tag {
  font-size: 0.725rem;
  color: var(--text-muted);
  background-color: var(--bg-body);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.btn-copy {
  padding: 0.2rem 0.45rem;
  font-size: 0.725rem;
}

.lang-col {
  padding: 0.5rem 0.65rem;
  border-radius: 4px;
}

.lang-col-en {
  background-color: rgba(0,0,0,0.015);
  border-left: 3px solid #94a3b8;
}

.lang-col-zh {
  background-color: rgba(29, 78, 216, 0.02);
  border-left: 3px solid var(--primary);
}

.rule-title-en {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.35rem;
}

.rule-title-zh {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

.rule-text {
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.rule-notes {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px dotted var(--border-color);
  font-size: 0.825rem;
  color: var(--text-muted);
}
.rule-notes ul {
  padding-left: 1.25rem;
}
.rule-notes li {
  margin-bottom: 0.2rem;
}

.exam-tip-box {
  margin-top: 0.75rem;
  background-color: #fffbeb;
  border-left: 3px solid #d97706;
  padding: 0.5rem 0.75rem;
  border-radius: 0 4px 4px 0;
  font-size: 0.825rem;
  color: #92400e;
}
[data-theme="dark"] .exam-tip-box {
  background-color: #451a03;
  color: #fde68a;
  border-color: #f59e0b;
}

/* Diagram Gallery */
.diagram-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.diagram-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}

.diagram-img-wrap {
  position: relative;
  width: 100%;
  height: 200px;
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

.diagram-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.icon-inline {
  display: inline-block;
  vertical-align: -2px;
  stroke: currentColor;
}

.diagram-overlay-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background-color: rgba(15, 23, 42, 0.85);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}

.diagram-info {
  padding: 0.85rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.diagram-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.diagram-title-zh {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.diagram-title-en {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.diagram-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.65rem;
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* QR Modal */
.qr-modal-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}
.qr-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.qr-modal-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}
.qr-image-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 0.85rem;
}
.qr-image {
  width: 170px;
  height: 170px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  padding: 4px;
  background: white;
}
.qr-url-box {
  font-size: 0.775rem;
  font-family: var(--font-code);
  background: var(--bg-body);
  padding: 0.4rem;
  border-radius: 4px;
  word-break: break-all;
}

/* Viewer Modal - 滿版全螢幕設計 */
.viewer-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background-color: var(--bg-card);
  border-radius: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;
  box-sizing: border-box;
}

.viewer-header {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  background-color: var(--bg-card);
  flex-shrink: 0;
}

.viewer-title-group {
  min-width: 0;
  overflow: hidden;
  flex: 1;
}

.viewer-title-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-title-group p {
  font-size: 0.725rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-header > div:last-child {
  flex-shrink: 0;
}

.viewer-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.viewer-viewport {
  flex: 1;
  height: 100%;
  background-color: #0b1120;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}
.viewer-viewport:active {
  cursor: grabbing;
}

.viewer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  transition: transform 0.05s ease-out;
  display: block;
}

.viewer-canvas img {
  display: block;
  max-width: none;
}

/* Diagram Pin & Label Styles */
.diagram-num-pin {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #1d4ed8;
  color: #ffffff;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-code);
  cursor: pointer;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s, background-color 0.15s;
  z-index: 25;
}

.diagram-num-pin:hover, .diagram-num-pin.active {
  transform: translate(-50%, -50%) scale(1.2);
  background-color: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.4);
  z-index: 35;
}

/* Chinese Label Underneath English Text (Centered Horizontally with High Readability) */
.diagram-zh-label {
  position: absolute;
  transform: translate(-50%, 0);
  background-color: #ffffff;
  color: #1e3a8a;
  border: 2px solid #2563eb;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: all 0.15s ease-out;
  z-index: 20;
}

.diagram-zh-label:hover, .diagram-zh-label.active {
  background-color: #1d4ed8;
  color: #ffffff;
  border-color: #1e40af;
  transform: translate(-50%, 0) scale(1.08);
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.45);
  z-index: 30;
}

.diagram-zh-label.side-badge {
  transform: translate(0, -50%);
  font-size: 22px;
  padding: 2px 8px;
}

.diagram-zh-label.side-badge:hover, .diagram-zh-label.side-badge.active {
  transform: translate(0, -50%) scale(1.08);
}

/* Bottom Slide-up Annotation Drawer */
.annotation-drawer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 195px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.annotation-drawer.open {
  transform: translateY(0);
}

.drawer-header {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-body);
}

.drawer-title-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.drawer-num-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-title-zh {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.drawer-title-en {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.2;
  font-family: var(--font-code);
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawer-body {
  padding: 0.85rem 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.drawer-desc {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.55;
}

.viewer-controls-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 0.25rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 50;
}

.viewer-ctrl-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.viewer-ctrl-btn:hover {
  background-color: rgba(255,255,255,0.2);
}

.zoom-level-text {
  color: #e2e8f0;
  font-size: 0.725rem;
  font-family: var(--font-code);
  padding: 0 0.35rem;
  min-width: 44px;
  text-align: center;
}

.viewer-sidebar {
  width: 320px;
  background-color: var(--bg-card);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.legend-header {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.825rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.legend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
}

.legend-item {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.3rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.legend-item:hover, .legend-item.active {
  background-color: var(--bg-body);
  border-color: var(--primary);
}
.legend-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.15rem;
}
.legend-zh {
  font-size: 0.825rem;
  font-weight: 700;
}
.legend-code {
  font-family: var(--font-code);
  font-size: 0.7rem;
  padding: 0.05rem 0.3rem;
  background-color: var(--primary-light);
  color: var(--primary);
  border-radius: 3px;
  font-weight: 600;
}
.legend-en {
  font-size: 0.725rem;
  color: var(--text-muted);
}
.legend-note {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* =========================================
   Mobile Specific Styles (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: flex !important;
  }

  .app-header {
    height: 50px;
    padding: 0 0.5rem;
    overflow: hidden;
    max-width: 100vw;
  }

  .header-left {
    gap: 0.35rem;
    min-width: 0;
    flex-shrink: 1;
  }

  .btn-menu {
    padding: 0.25rem 0.45rem;
    font-size: 0.775rem;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .mobile-site-select {
    max-width: 130px;
    padding: 0.25rem 0.35rem;
    font-size: 0.775rem;
  }

  .header-right.mobile-only {
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .mobile-select {
    max-width: 90px;
    padding: 0.25rem 0.35rem;
    font-size: 0.775rem;
  }

  .btn-icon-compact {
    padding: 0.25rem 0.4rem;
    font-size: 0.775rem;
    min-width: 26px;
  }

  .header-subtitle {
    display: none;
  }

  .app-sidebar {
    position: fixed;
    top: 50px;
    left: -290px;
    width: 280px;
    height: calc(100vh - 50px);
    z-index: 300;
    transition: left 0.25s ease-in-out;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }

  .app-sidebar.mobile-open {
    left: 0;
  }

  .main-content,
  .ssf-content-container {
    padding: 0.75rem 15px 4rem 15px !important;
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Force stacked view on mobile */
  .view-split .bilingual-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .diagram-gallery {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .diagram-img-wrap {
    height: 180px;
  }

  .rule-card {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  .chapter-hero {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }
  .chapter-hero-title {
    font-size: 1.05rem;
  }
  .chapter-hero-meta {
    flex-direction: column;
    gap: 0.35rem;
  }

  .viewer-sidebar {
    display: none !important;
  }

  .viewer-controls-bar {
    bottom: 1.5rem;
  }

  .annotation-drawer {
    max-height: 42vh;
  }
}

/* ========================================================
   Multi-Manual Switcher & SSF Styling
   ======================================================== */

.manual-nav-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-hover);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-right: 0.75rem;
}

.manual-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
}

.manual-nav-btn:hover {
  color: var(--text-color);
  background-color: var(--bg-card);
}

.manual-nav-btn.active {
  background-color: var(--bg-card);
  color: var(--primary-color);
  border-color: var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.manual-nav-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 10px;
  background-color: #dbeafe;
  color: #1e40af;
  font-weight: 700;
}
[data-theme="dark"] .manual-nav-badge {
  background-color: #1e3a8a;
  color: #bfdbfe;
}

.mobile-manual-select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-color);
  font-size: 0.78rem;
  font-weight: 600;
  outline: none;
  max-width: 140px;
}

/* SSF Content Container */
.ssf-content-container {
  padding: 1.5rem 15px 4rem 15px;
  margin: 0;
  max-width: none;
  width: 100%;
}

.ssf-site-header {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

.ssf-site-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.ssf-site-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ssf-site-title-en {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: normal;
}

.ssf-cross-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.ssf-cross-link-btn:hover {
  background-color: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}
[data-theme="dark"] .ssf-cross-link-btn {
  background-color: #1e3a8a;
  border-color: #2563eb;
  color: #dbeafe;
}

.ssf-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ssf-chip {
  font-size: 0.775rem;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-family: var(--font-code);
}

/* Quick Jump Pill Navigation */
.ssf-quick-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
  padding-bottom: 0.5rem;
}

.ssf-jump-pill {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.15s ease-in-out;
}
.ssf-jump-pill:hover {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

/* SSF Factor Card */
.ssf-factor-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease-in-out;
}
.ssf-factor-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ssf-factor-header {
  padding: 1rem 1.25rem;
  background-color: var(--bg-hover);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.ssf-factor-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ssf-num-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background-color: #2563eb;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
}

.ssf-factor-name-zh {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-color);
}

.ssf-factor-name-en {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.ssf-factor-meta-badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.ssf-meta-badge {
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: var(--font-code);
}

.ssf-factor-body {
  padding: 1.25rem;
}

.ssf-section-block {
  margin-bottom: 1.25rem;
}

.ssf-block-label {
  font-size: 0.825rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: 0.4rem;
  letter-spacing: 0.5px;
}

.ssf-desc-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-color);
}

.ssf-guidelines-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.ssf-guideline-item {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.45rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-color);
}
.ssf-guideline-item::before {
  content: "•";
  position: absolute;
  left: 0.35rem;
  top: 0;
  color: var(--primary-color);
  font-weight: bold;
}

/* SSF Code Table */
.ssf-table-wrapper {
  margin-top: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto !important;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}

.ssf-table-filter-bar {
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-hover);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ssf-filter-input {
  width: 100%;
  max-width: 320px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.825rem;
  background-color: var(--bg-card);
  color: var(--text-color);
  outline: none;
}

.ssf-code-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

/* Strict column width control for factor code tables */
.ssf-factor-card .ssf-code-table:not(#hn-subsite-table) {
  table-layout: fixed;
  width: 100%;
}

.ssf-factor-card .ssf-code-table:not(#hn-subsite-table) th:first-child,
.ssf-factor-card .ssf-code-table:not(#hn-subsite-table) td:first-child {
  width: 85px;
  min-width: 75px;
  max-width: 95px;
  white-space: nowrap;
  vertical-align: top;
  padding: 0.55rem 0.5rem 0.55rem 0.75rem;
}

.ssf-factor-card .ssf-code-table:not(#hn-subsite-table) th:last-child,
.ssf-factor-card .ssf-code-table:not(#hn-subsite-table) td:last-child {
  width: auto;
  word-break: break-word;
  overflow-wrap: break-word;
  vertical-align: top;
  padding: 0.55rem 0.85rem 0.55rem 0.5rem;
  line-height: 1.5;
}

.ssf-code-table th {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.ssf-code-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  line-height: 1.5;
}

.ssf-code-table tr:last-child td {
  border-bottom: none;
}

.ssf-code-table tr:hover td {
  background-color: var(--bg-hover);
}

.ssf-code-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  font-weight: 700;
  font-family: var(--font-code);
  font-size: 0.825rem;
  white-space: nowrap;
}
[data-theme="dark"] .ssf-code-badge {
  background-color: #1e293b;
  color: #f8fafc;
  border-color: #475569;
}

.ssf-code-badge.special {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
[data-theme="dark"] .ssf-code-badge.special {
  background-color: #7f1d1d;
  color: #fecaca;
  border-color: #b91c1c;
}

.ssf-examples-box {
  margin-top: 1rem;
  background-color: #f8fafc;
  border-left: 3px solid #0284c7;
  padding: 0.75rem 1rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
}
[data-theme="dark"] .ssf-examples-box {
  background-color: #082f49;
  border-left-color: #38bdf8;
}

/* Mobile Manual & Site Select Wrap */
.mobile-site-select-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-manual-select {
  padding: 0.25rem 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: #0284c7;
  font-size: 0.75rem;
  font-weight: 700;
  max-width: 95px;
  flex-shrink: 0;
}
[data-theme="dark"] .mobile-manual-select {
  color: #38bdf8;
}

/* SSF Sidebar Styling */
.ssf-sidebar-section {
  margin-bottom: 1.25rem;
}

.ssf-sidebar-title {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.45rem;
  padding: 0 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ssf-sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  margin-bottom: 2px;
}

.ssf-sidebar-item:hover {
  background-color: var(--bg-hover);
  color: var(--primary-color);
}

.ssf-sidebar-item.active {
  background-color: rgba(14, 165, 233, 0.12);
  color: var(--primary-color);
  font-weight: 700;
  border-left: 3px solid var(--primary-color);
}

.ssf-sidebar-subitem {
  display: block;
  padding: 0.3rem 0.65rem 0.3rem 1.15rem;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.775rem;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.ssf-sidebar-subitem:hover {
  background-color: var(--bg-hover);
  color: var(--primary-color);
}

.ssf-sidebar-subitem.active {
  color: var(--primary-color);
  font-weight: 700;
}

/* SSF Subsite Matrix Styling */
#sec-subsite-matrix {
  overflow: visible !important;
  border-left: 4px solid #475569 !important;
  margin-bottom: 2rem;
}

.ssf-matrix-sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.15rem;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ssf-matrix-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ssf-matrix-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ssf-subsite-subtitle {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

.ssf-matrix-count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.ssf-matrix-filter-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.ssf-filter-label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.ssf-filter-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.ssf-filter-input-wrap .ssf-filter-input {
  width: 100%;
  max-width: none;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-body);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ssf-filter-input-wrap .ssf-filter-input:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.2);
}

.ssf-subsite-notice {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.55;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-hover);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.ssf-table-scroll-hint {
  display: none;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  padding: 3px 6px;
  font-style: italic;
}

@media (max-width: 900px) {
  .ssf-table-scroll-hint {
    display: block;
  }
}

#hn-subsite-table {
  min-width: 820px !important;
  width: 100%;
  border-collapse: collapse;
}

#hn-subsite-table th {
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

#hn-subsite-table td {
  padding: 0.55rem 0.75rem;
  font-size: 0.825rem;
  line-height: 1.4;
  vertical-align: top;
}

.ssf-subsite-code-badge {
  font-family: Consolas, monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-main);
  background-color: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
  border: 1px solid var(--border-color);
}

.ssf-subsite-code-list {
  font-size: 0.75rem;
  line-height: 1.35;
}

.ssf-subsite-code-row {
  margin-bottom: 3px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px;
}

.ssf-subsite-code-row .ssf-code-tag {
  font-family: Consolas, monospace;
  font-weight: 700;
  color: var(--text-main);
}

.ssf-subsite-code-row .ssf-code-en {
  color: var(--text-main);
}

.ssf-subsite-code-row .ssf-code-zh {
  color: var(--text-muted);
}

.ssf-matrix-btns-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ssf-matrix-tag-btn {
  display: inline-flex;
  align-items: center;
  margin: 2px 3px 2px 0;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--bg-hover);
  color: #881337;
  border: 1px solid #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ssf-matrix-tag-btn:hover {
  background-color: #881337;
  color: #ffffff;
  border-color: #881337;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(136, 19, 55, 0.25);
}

[data-theme="dark"] .ssf-matrix-tag-btn {
  background-color: #27272a;
  color: #fda4af;
  border-color: #3f3f46;
}

[data-theme="dark"] .ssf-matrix-tag-btn:hover {
  background-color: #881337;
  color: #ffffff;
}

.ssf-subsite-code-tooltip {
  display: inline-block;
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}



/* Mobile View Toolbar (Row 2) */
.mobile-view-toolbar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-view-toolbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 15px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 48px;
    z-index: 990;
    gap: 0.5rem;
  }

  .mobile-segmented-control {
    display: flex;
    flex: 1;
    min-width: 0;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
  }

  .mobile-segmented-control .segment-btn {
    flex: 1;
    text-align: center;
    padding: 0.32rem 0.2rem;
    font-size: 0.775rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
  }

  .mobile-segmented-control .segment-btn.active {
    background-color: var(--bg-card);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  }

  [data-theme="dark"] .mobile-segmented-control .segment-btn.active {
    background-color: #3f3f46;
    color: #38bdf8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }

  .mobile-tool-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .mobile-tool-actions .btn-icon-compact {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Make Top Header Row 1 expand and fill cleanly */
  .app-header {
    height: 48px;
    padding: 0 15px;
  }

  .header-left {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .mobile-site-select-wrap {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 0.35rem;
  }

  .mobile-manual-select {
    max-width: 135px;
    flex-shrink: 0;
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .mobile-site-select {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .app-sidebar {
    top: 48px;
    height: calc(100vh - 48px);
  }
}

@media (max-width: 380px) {
  .mobile-segmented-control .segment-btn {
    font-size: 0.72rem;
    padding: 0.28rem 0.1rem;
  }
}

.view-zh-only .ssf-subsite-code-row .ssf-code-en {
  display: none !important;
}

.view-en-only .ssf-subsite-code-row .ssf-code-zh {
  display: none !important;
}
