/* iPad Manual Minimal Frame Edition (Link Portal) */
:root {
  --bg-sidebar: #f8fafc;
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --bg-inset: #f8fafc;
  --bg-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --accent: #0066cc;
  --accent-hover: #004fb3;
  --accent-subtle: #eff6ff;
  --accent-border: #bfdbfe;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang TC", "Noto Sans TC", "Hiragino Sans", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--bg-sidebar);
  -webkit-font-smoothing: antialiased;
}

/* App Container - Desktop Frame */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: 320px;
  min-width: 300px;
  max-width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-sidebar);
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.app-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.manual-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.manual-switch:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* Chapter List */
.chapter-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.chapter-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-nav-item a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.chapter-nav-item a:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.chapter-nav-item.active a {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.chapter-nav-item .nav-id {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
  display: block;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
  display: none;
}

/* Main Content Pane */
.content-pane {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  background: var(--bg-main);
  padding: 40px 52px 80px;
}

.content-inner {
  max-width: 880px;
  margin: 0 auto;
}

/* Chapter Pane Section */
.chapter-pane {
  display: none;
}

.chapter-pane.active {
  display: block;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Chapter Header */
.chapter-header {
  margin-bottom: 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
}

.chapter-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.chapter-desc {
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Section Container */
.section-block {
  background: var(--bg-inset);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-sm);
}

.section-block-header {
  margin-bottom: 14px;
}

.section-uid {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.section-purpose {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--bg-card);
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 8px 0 14px;
}

/* Callout Alerts */
.callout-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.callout-badge.internal {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

.callout-badge.pending {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

/* Link Cards List */
.source-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-section-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  transition: all 0.15s ease;
  text-decoration: none;
  gap: 16px;
}

.source-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
  background: #ffffff;
}

.source-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.source-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

.source-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-lang-badge {
  font-size: 11px;
  background: var(--bg-inset);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.source-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.source-card:hover .source-btn {
  background: var(--accent-hover);
  transform: translateX(2px);
}

/* Cross References */
.xref-box {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-muted);
}

.xref-box strong {
  color: var(--text-main);
  display: block;
  margin-bottom: 4px;
}

.xref-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  margin: 2px 4px 2px 0;
  padding: 2px 6px;
  background: var(--accent-subtle);
  border-radius: 4px;
}

.xref-link:hover {
  text-decoration: underline;
}

/* Footer */
footer.manual-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  font-size: 12.5px;
  color: var(--text-light);
  text-align: center;
}

/* Responsive - Mobile & Tablet */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    display: none;
  }

  .mobile-header {
    display: block;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
  }

  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .mobile-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
  }

  .chapter-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
  }

  .content-pane {
    height: auto;
    overflow: visible;
    padding: 20px 16px 60px;
  }

  .chapter-header h1 {
    font-size: 22px;
  }

  .section-block {
    padding: 16px 14px;
  }

  .source-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .source-btn {
    width: 100%;
    justify-content: center;
    padding: 9px 12px;
  }
}
