:root {
  --system-bg: #f2f2f7;
  --system-surface: rgba(255, 255, 255, 0.7);
  --system-surface-solid: #ffffff;
  --system-text: #1c1c1e;
  --system-muted: #8e8e93;
  --system-accent: #007aff;
  --system-accent-gradient: linear-gradient(180deg, #007aff 0%, #0056b3 100%);
  --system-line: rgba(60, 60, 67, 0.12);
  --system-radius: 12px;
  --system-radius-lg: 20px;
  --system-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
  --system-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--system-font);
  background-color: var(--system-bg);
  color: var(--system-text);
  overflow: hidden;
  height: 100vh;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: rgba(242, 242, 247, 0.8);
  backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid var(--system-line);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  z-index: 100;
}

.sidebar-header {
  padding: 0 8px 24px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-icon {
  width: 40px;
  height: 40px;
  background: var(--system-accent-gradient);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 20px;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--system-muted);
  text-transform: uppercase;
  padding: 0 12px 8px 12px;
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--system-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.nav-item.active {
  background-color: var(--system-accent);
  color: white;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: white;
  position: relative;
  overflow: hidden;
}

.content-header {
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--system-line);
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 90;
}

.content-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 40px 60px;
  scroll-behavior: smooth;
}

.content-container {
  max-width: 800px;
  margin: 0 auto;
}

/* Typography & Prose */
h1 { font-size: 34px; font-weight: 800; letter-spacing: -1px; margin-bottom: 24px; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin: 32px 0 16px 0; border-bottom: 1px solid var(--system-line); padding-bottom: 8px; }
h3 { font-size: 19px; font-weight: 600; margin: 24px 0 12px 0; }
p { font-size: 16px; line-height: 1.6; color: #3a3a3c; margin-bottom: 16px; }

/* Cards & Components */
.apple-card {
  background: var(--system-surface-solid);
  border-radius: var(--system-radius-lg);
  padding: 24px;
  border: 1px solid var(--system-line);
  box-shadow: var(--system-shadow);
  margin-bottom: 24px;
  transition: transform 0.2s ease;
}

.apple-card:hover {
  transform: translateY(-2px);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

.feature-item {
  background: #fbfbfd;
  padding: 20px;
  border-radius: var(--system-radius);
  border: 1px solid var(--system-line);
}

.feature-item h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--system-accent);
}

.feature-item p {
  margin: 0;
  font-size: 14px;
  color: var(--system-muted);
}

/* Table Styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--system-line);
}

th {
  background: #f5f5f7;
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--system-muted);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--system-line);
}

tr:last-child td { border-bottom: none; }

/* Gallery Tile */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 40px;
}

.gallery-tile {
  background: white;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--system-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  cursor: zoom-in;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-tile:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

.gallery-tile img {
  width: 100%;
  height: auto;
  display: block;
  border-bottom: 1px solid var(--system-line);
  background-color: #fbfbfd;
}

.gallery-tile-info {
  padding: 20px 24px;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-tile-info::after {
  content: "点击查看大图";
  font-size: 13px;
  font-weight: 500;
  color: var(--system-accent);
  background: rgba(0, 113, 227, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

/* Lightbox Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(242, 242, 247, 0.9);
  backdrop-filter: blur(40px) saturate(200%);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}

.modal.open {
  display: flex;
  animation: modalIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 30px 90px rgba(0,0,0,0.2);
  border-radius: 16px;
  background: white;
  border: 1px solid rgba(0,0,0,0.1);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: rgba(0,0,0,0.05);
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Buttons */
.apple-button {
  background: var(--system-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.apple-button:hover { opacity: 0.8; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Flow Selector Buttons */
.flow-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  padding: 4px;
  background: rgba(0,0,0,0.05);
  border-radius: 12px;
  width: fit-content;
}

.flow-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--system-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.flow-tab:hover {
  color: var(--system-text);
}

.flow-tab.active {
  background: white;
  color: var(--system-accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Functional Flowcharts (HTML-based) */
.flow-container {
  margin-top: 0;
}

.flow-section {
  background: white;
  border-radius: var(--system-radius-lg);
  padding: 32px;
  border: 1px solid var(--system-line);
  box-shadow: var(--system-shadow);
  animation: fadeIn 0.4s ease;
}

.flow-section h3 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
}

.flow-steps {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 24px;
  margin-top: 24px;
}

.flow-steps::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--system-line);
}

.flow-step {
  position: relative;
  padding-bottom: 32px;
}

.flow-step:last-child {
  padding-bottom: 0;
}

.flow-step::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--system-accent);
  z-index: 1;
}

.flow-step-icon {
  position: absolute;
  left: -32px;
  top: 0;
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid var(--system-line);
  z-index: 2;
}

.flow-step-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  padding-left: 16px;
}

.flow-step-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--system-text);
}

.flow-step-tech {
  font-family: monospace;
  font-size: 11px;
  background: #f2f2f7;
  padding: 4px 10px;
  border-radius: 6px;
  color: #5856d6;
  border: 1px solid rgba(88, 86, 214, 0.1);
}

.flow-step-desc {
  font-size: 14px;
  color: var(--system-muted);
  line-height: 1.5;
  padding-left: 16px;
}

.flow-step-details {
  margin-top: 12px;
  margin-left: 16px;
  background: #fbfbfd;
  border-radius: 10px;
  padding: 12px 16px;
  border: 1px solid var(--system-line);
}

.flow-visual-indicator {
  height: 4px;
  width: 40px;
  border-radius: 2px;
  margin-bottom: 12px;
  background: var(--system-accent);
}

.stage-input { border-left: 4px solid #007aff; }
.stage-ai { border-left: 4px solid #5856d6; background: rgba(88, 86, 214, 0.02); }
.stage-output { border-left: 4px solid #34c759; }

.flow-steps::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: linear-gradient(to bottom, #007aff, #5856d6, #34c759);
}

.flow-step::before { display: none; } /* Hide the old dot */

.flow-step-details ul {
  margin: 0;
  padding-left: 18px;
}

.flow-step-details li {
  font-size: 13px;
  color: #48484a;
  margin-bottom: 4px;
}

.flow-step-details li:last-child {
  margin-bottom: 0;
}

.flow-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 6px;
}

.badge-blue { background: #e1f0ff; color: #007aff; }
.badge-purple { background: #f2f2ff; color: #5856d6; }
.badge-green { background: #e2f9e1; color: #34c759; }
.badge-orange { background: #fff2e0; color: #ff9500; }

/* Responsive */
@media (max-width: 850px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    top: 0;
    bottom: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: white;
    box-shadow: 20px 0 40px rgba(0,0,0,0.1);
  }

  .sidebar.open {
    transform: translateX(var(--sidebar-width));
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 95;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  .menu-toggle {
    display: flex;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: white;
    border: 1px solid var(--system-line);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    z-index: 110;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
  }

  .main-content {
    width: 100vw;
  }

  .content-header {
    padding-left: 64px; /* Space for menu toggle */
  }

  .scroll-area {
    padding: 24px 16px;
  }

  .apple-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .apple-card[style*="padding: 40px"] {
    padding: 24px !important;
  }

  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .flow-selector {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .flow-tab {
    flex-shrink: 0;
  }

  .flow-section {
    padding: 20px;
  }

  .flow-step-header {
    flex-direction: column;
    gap: 4px;
  }

  .flow-step-tech {
    align-self: flex-start;
  }

  .header-actions {
    display: none; /* Hide print button on mobile */
  }
}

@media (min-width: 851px) {
  .menu-toggle, .sidebar-overlay {
    display: none;
  }
}
