/* ===== CSS Variables ===== */
:root {
  /* Indigo accent — reads well on both light and dark surfaces */
  --primary: #3D5AC9;
  --primary-hover: #2F49AE;
  --primary-light: #ECEEFB;
  --accent: #0F7AB5;
  --success: #0E9F8A;
  --warning: #B7791F;
  --danger: #D92D20;

  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #ECEEF1;
  --border: #E4E6EA;
  --hairline: #ECEDF0;
  --text: #1A1C23;
  --text-secondary: #5A616E;
  --text-muted: #8A909C;

  --sidebar-width: 280px;
  --header-height: 60px;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(20,22,30,0.05), 0 1px 1px rgba(20,22,30,0.04);
  --shadow-md: 0 4px 12px rgba(20,22,30,0.07), 0 1px 3px rgba(20,22,30,0.05);
  --shadow-lg: 0 16px 40px rgba(20,22,30,0.12), 0 4px 12px rgba(20,22,30,0.07);

  --transition: 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --primary: #7C92FF;
  --primary-hover: #93A6FF;
  --primary-light: #232A4D;
  --accent: #4FB3E8;
  --success: #34C7B0;
  --warning: #E0A33E;
  --danger: #F1675C;

  --bg: #0E1014;
  --surface: #181B22;
  --surface-2: #21252F;
  --border: #2C313D;
  --text: #E9EBF0;
  --text-secondary: #A2A9B5;
  --text-muted: #6E7480;
  --hairline: #23272F;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.55);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', 'Segoe UI', sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* ===== Header ===== */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 1000;
  transition: background var(--transition), border-color var(--transition);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}
.header-logo svg { width: 32px; height: 32px; }
.header-logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.header-logo-text span { color: var(--primary); }

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* Search */
.search-wrapper {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}
#search-input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(61,90,201,0.18);
}
#search-input::placeholder { color: var(--text-muted); }

#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 2000;
}
#search-results.show { display: block; }
.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-light); }
.search-result-title { font-size: 14px; font-weight: 600; color: var(--text); }
.search-result-preview { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.search-result-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  margin-top: 4px;
}
.search-no-result { padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
mark { background: rgba(61,90,201,0.16); color: var(--primary); border-radius: 2px; padding: 0 1px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Theme toggle */
#theme-toggle {
  width: 36px; height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
#theme-toggle:hover { background: var(--primary-light); color: var(--primary); }

/* Sidebar toggle (mobile) */
#sidebar-toggle {
  display: none;
  width: 36px; height: 36px;
  border: none;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

/* ===== Layout ===== */
#layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
  transition: transform var(--transition), background var(--transition);
  z-index: 900;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section { margin-bottom: 4px; }
.sidebar-divider { height: 1px; background: var(--border); margin: 5px 12px; }

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  cursor: pointer;
  user-select: none;
  border-radius: 0;
  transition: background var(--transition);
}
.sidebar-section-header:hover { background: var(--surface-2); }
.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-section-header .chevron {
  transition: transform 0.2s;
  color: var(--text-muted);
}
.sidebar-section.open .chevron { transform: rotate(180deg); }

.sidebar-items {
  display: none;
}
.sidebar-section.open .sidebar-items { display: block; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 12px;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.sidebar-item:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.sidebar-item.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-light);
}
.sidebar-item svg { flex-shrink: 0; opacity: 0.65; }
.sidebar-item.active svg { opacity: 1; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 24px; }

/* ===== Main Content ===== */
#main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 52px 64px 80px;
  max-width: calc(100% - var(--sidebar-width));
}

/* ===== Content Page ===== */
.page { display: none; }
.page.active { display: block; }

.page-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.badge-blue { background: rgba(15,122,181,0.10); color: var(--accent); border-color: rgba(15,122,181,0.22); }
.badge-purple { background: var(--primary-light); color: var(--primary); border-color: rgba(61,90,201,0.22); }
.badge-green { background: rgba(14,159,138,0.10); color: var(--success); border-color: rgba(14,159,138,0.24); }
.badge-orange { background: rgba(183,121,31,0.10); color: var(--warning); border-color: rgba(183,121,31,0.26); }

.page-title {
  font-size: 33px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.15;
  text-wrap: balance;
}
.page-desc {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 70ch;
  text-wrap: pretty;
}

/* ===== Typography ===== */
h2 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 52px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-height) + 16px);
  text-wrap: balance;
}
h3 {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 26px 0 12px;
  scroll-margin-top: calc(var(--header-height) + 16px);
  text-wrap: balance;
}
p { margin-bottom: 14px; font-size: 14.5px; color: var(--text); max-width: 72ch; text-wrap: pretty; }
ul, ol { padding-left: 20px; margin-bottom: 14px; }
li { font-size: 14.5px; margin-bottom: 6px; }
strong { color: var(--text); font-weight: 650; }
code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--primary);
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: border-color var(--transition), background var(--transition);
}
.card:hover {
  border-color: var(--primary);
}
.card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 22px;
}
.card-icon-logo { width: auto; min-width: 64px; padding: 8px 12px; gap: 8px; }
.card-icon-logo-img { height: 28px; max-width: 80px; object-fit: contain; }
.card-icon-both .card-icon-logo-img { max-width: 56px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-secondary); }

/* Studio brand logo cards */
.studio-card { text-align: center; }
.studio-logo-wrap {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border-radius: 10px;
  padding: 6px 10px;
  background: transparent;
  transition: background 0.2s;
}
[data-theme="dark"] .studio-logo-wrap {
  background: rgba(255,255,255,0.92);
}
.studio-logo {
  max-height: 48px;
  max-width: 100%;
  object-fit: contain;
}

/* ===== Step List ===== */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 14px 18px 14px 58px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 14px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ===== Callout ===== */
.callout {
  position: relative;
  padding: 14px 16px 14px 18px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
/* Emoji icons were a tell; the colored title + accent carries the type now. */
.callout-icon { display: none; }
.callout-body { flex: 1; }
.callout-body + .callout-body { margin-top: 2px; }
.callout-title {
  font-weight: 650;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.callout-title::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.callout.tip { background: rgba(14,159,138,0.06); border-color: rgba(14,159,138,0.28); }
.callout.tip .callout-title { color: var(--success); }
.callout.info { background: rgba(15,122,181,0.06); border-color: rgba(15,122,181,0.28); }
.callout.info .callout-title { color: var(--accent); }
.callout.warning { background: rgba(183,121,31,0.06); border-color: rgba(183,121,31,0.30); }
.callout.warning .callout-title { color: var(--warning); }
.callout.danger { background: rgba(217,45,32,0.06); border-color: rgba(217,45,32,0.30); }
.callout.danger .callout-title { color: var(--danger); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; margin: 16px 0; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--surface-2); }
th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ===== Image ===== */
.screenshot-wrap {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.screenshot-caption {
  padding: 8px 16px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: center;
}
.screenshot-placeholder {
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
}
.screenshot-placeholder .ph-icon { font-size: 40px; }

/* ===== Keyboard ===== */
kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ===== Badge Pill ===== */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.pill-purple { background: var(--primary-light); color: var(--primary); }
.pill-green { background: rgba(0,191,165,0.12); color: var(--success); }
.pill-blue { background: rgba(0,176,255,0.12); color: var(--accent); }
.pill-orange { background: rgba(255,179,0,0.12); color: #E65100; }
.pill-red { background: rgba(255,82,82,0.12); color: var(--danger); }

/* ===== Home page ===== */
.home-hero {
  text-align: center;
  padding: 48px 0 40px;
}
.home-hero .hero-icon {
  width: 72px; height: 72px;
  margin: 0 auto 20px;
  background: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.hero-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 0 auto 28px;
}
.hero-logo-wrap {
  height: 52px;
  padding: 8px 16px;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
[data-theme="dark"] .hero-logo-wrap {
  background: rgba(255,255,255,0.92);
}
.hero-logo-img {
  max-height: 36px;
  max-width: 140px;
  object-fit: contain;
}
.home-hero h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 12px;
  text-wrap: balance;
}
.home-hero p {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
  text-wrap: pretty;
}

.home-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 36px 0;
}
.home-nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: left;
}
.home-nav-card:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-light) 35%, var(--surface));
}
.home-nav-card .card-num {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.home-nav-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  border: none;
  padding: 0;
}
.home-nav-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}
.home-nav-card .card-arrow {
  margin-top: 12px;
  font-size: 18px;
  color: var(--primary);
}

/* ===== Step mini cards (home) ===== */
.step-mini-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 0 0 28px; }
.step-mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  text-align: center;
}
.step-mini-card:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-light) 35%, var(--surface)); }
.smc-num { font-size: 10px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.05em; }
.smc-icon { font-size: 20px; display: block; margin-bottom: 5px; }
.smc-title { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3; }
.smc-role { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ===== Step field helpers ===== */
.req-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: rgba(255,82,82,0.12); color: #df2f4a; margin-left: 4px; vertical-align: middle; }
.step-field-hint { font-size: 13px; color: var(--text-secondary); margin-top: 4px; display: block; }
.step-route-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.srg-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.srg-desc { color: var(--text-secondary); line-height: 1.5; }
.route-tree { position: relative; margin-top: 10px; padding-left: 22px; }
.route-tree::before { content: ''; position: absolute; left: 6px; top: 16px; bottom: 16px; width: 2px; background: var(--border); }
.rt-item { position: relative; padding: 6px 0 6px 18px; font-size: 13px; line-height: 1.5; }
.rt-item::before { content: ''; position: absolute; left: -16px; top: 15px; width: 16px; height: 2px; background: var(--border); }
.rt-name { color: var(--text); }
.rt-desc { color: var(--text-secondary); }
.step-field-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 8px; }
.sfr-item { font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.sfr-desc { color: var(--text-secondary); }

/* ===== Role entry section (home) ===== */
.role-entry-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 28px; }
.role-entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.role-entry-card:hover { background: var(--surface-2); }
.re-bd    { border-top: 3px solid #6C5CE7; }
.re-am    { border-top: 3px solid #fdab3d; }
.re-legal { border-top: 3px solid #00BFA5; }
.re-tech  { border-top: 3px solid #00B0FF; }
.re-bd:hover    { border-color: #6C5CE7; }
.re-am:hover    { border-color: #fdab3d; }
.re-legal:hover { border-color: #00BFA5; }
.re-tech:hover  { border-color: #00B0FF; }
.re-role { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.re-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 10px; line-height: 1.4; }
.re-steps { display: flex; flex-direction: column; gap: 4px; }
.re-step { font-size: 11px; color: var(--text-muted); padding: 2px 0 2px 8px; border-left: 2px solid var(--border); line-height: 1.4; }
.re-cta { margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--primary); }

@media (max-width: 760px) {
  .step-mini-grid { grid-template-columns: repeat(3, 1fr); }
  .role-entry-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Swimlane Diagram ===== */
.swimlane-wrap {
  margin: 24px 0; border-radius: var(--radius-lg);
  border: 1px solid var(--border); overflow: hidden;
}
.sl-overflow { overflow-x: auto; }
.sl-table { width: 100%; min-width: 700px; border-collapse: collapse; }
.sl-col-h {
  padding: 8px 12px; text-align: center; background: var(--surface-2);
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  border: 1px solid var(--border); border-bottom: 2px solid var(--border);
}
.sl-corner { background: var(--surface-2); border: 1px solid var(--border); border-bottom: 2px solid var(--border); }
.sl-row-h {
  padding: 8px 6px; font-size: 11px; font-weight: 700; text-align: center;
  writing-mode: vertical-rl; min-width: 50px; max-width: 50px;
  border: 1px solid var(--border); white-space: nowrap;
}
.sl-row-h.sl-bdm   { background: rgba(108,92,231,0.09); color: #6C5CE7; border-right: 2px solid #6C5CE7; }
.sl-row-h.sl-sys   { background: rgba(100,100,100,0.05); color: var(--text-muted); }
.sl-row-h.sl-rose  { background: rgba(0,191,165,0.08); color: #00897B; border-right: 2px solid #00BFA5; }
.sl-row-h.sl-tech  { background: rgba(0,176,255,0.08); color: #0277BD; border-right: 2px solid #00B0FF; }
.sl-cell.sl-tech-bg { background: rgba(0,176,255,0.03); }
.sl-title.sl-t-tech { color: #0277BD; }

/* Overview swimlane — horizontal row labels, compact cells */
.ov-swimlane .sl-table { table-layout: fixed; }
.ov-swimlane .sl-row-h {
  writing-mode: horizontal-tb;
  width: 82px; min-width: 82px; max-width: 82px;
  font-size: 11px; line-height: 1.5;
  white-space: normal; padding: 8px;
  vertical-align: middle; text-align: center;
}
.ov-swimlane .sl-col-h {
  font-size: 10px; padding: 8px 6px;
  border-top: 3px solid transparent;
}
.ov-swimlane .sl-col-h.step1 { border-top-color: #6C5CE7; }
.ov-swimlane .sl-col-h.step2 { border-top-color: #00B894; }
.ov-swimlane .sl-col-h.step3 { border-top-color: #FDCB6E; }
.ov-swimlane .sl-col-h.step4 { border-top-color: #00BFA5; }
.ov-swimlane .sl-col-h.step5 { border-top-color: #00B0FF; }
.ov-swimlane .sl-col-h span { text-transform: none; font-size: 10.5px; display: block; margin-top: 2px; }
.ov-swimlane .sl-cell  { padding: 9px 10px; font-size: 12px; vertical-align: top; }
.ov-swimlane .sl-empty { background: var(--surface); opacity: 0.5; }
.ov-cell-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.ov-cell-title.c-legal { color: #00897B; }
.ov-cell-title.c-tech  { color: #0277BD; }
.ov-chips { display: flex; flex-wrap: nowrap; gap: 3px; margin-top: 4px; }
.ov-chips .sl-chip { font-size: 10px; padding: 2px 5px; }
.ov-steps { margin-top: 5px; }
.ov-step { font-size: 11.5px; color: var(--text); line-height: 1.5; }
.ov-step-arr { font-size: 10px; color: var(--text-muted); line-height: 1.4; padding: 1px 0; }
.ov-decision-box {
  display: inline-block;
  background: rgba(108,92,231,0.08);
  border: 1px solid rgba(108,92,231,0.25);
  border-radius: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 7px;
  margin: 2px 0;
  color: var(--primary);
}
.ov-outcomes { font-size: 11px; margin: 2px 0 2px 4px; line-height: 1.8; }
.ov-yes { color: #00B894; font-weight: 700; }
.ov-no  { color: #E17055; font-weight: 700; }
.ov-note {
  font-size: 10px; color: var(--text-muted);
  background: rgba(253,203,110,0.18);
  border-left: 2px solid #FDCB6E;
  padding: 3px 6px; margin-top: 7px;
  border-radius: 0 3px 3px 0;
}
.ov-final { font-weight: 700; color: var(--primary); }
.sl-cell { padding: 10px 12px; vertical-align: top; border: 1px solid var(--border); font-size: 12.5px; line-height: 1.6; }
.sl-cell.sl-bdm-bg  { background: rgba(108,92,231,0.03); }
.sl-cell.sl-sys-bg  { background: rgba(100,100,100,0.02); text-align: center; vertical-align: middle; }
.sl-cell.sl-rose-bg { background: rgba(0,191,165,0.03); }
.sl-cell.sl-empty   { background: var(--surface-2); }
.sl-title { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.sl-title.sl-t-legal { color: #00897B; }
.sl-title.sl-t-sys { color: var(--text-muted); }
.sl-chip {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 600; margin: 2px 2px 2px 0; white-space: nowrap;
}
.sl-chip-green { background: #00ca72; color: #fff; }
.sl-chip-blue  { background: #216edf; color: #fff; }
.sl-chip-gray  { background: var(--surface-2); color: var(--text-secondary); border: 1px dashed var(--border); }
.sl-chip-warn  { background: rgba(255,82,82,0.1); color: var(--danger); border: 1px solid rgba(255,82,82,0.3); }
.sl-chip-auto  { background: rgba(108,92,231,0.1); color: var(--primary); border: 1px dashed var(--primary); }
.sl-req { font-size: 10px; font-weight: 700; color: var(--danger); background: rgba(255,82,82,0.08); padding: 1px 5px; border-radius: 3px; }
.sl-arrow-v { font-size: 18px; color: var(--primary); opacity: 0.6; margin: 2px 0; }
.sl-muted { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== Board Mockup ===== */
.board-mock-wrap {
  margin: 24px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.board-mock-header {
  background: var(--surface-2);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.board-mock-header span { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.board-mock-scroll { overflow-x: auto; }
.board-mock-scroll::-webkit-scrollbar { height: 5px; }
.board-mock-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.board-mock table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 700px; }
.board-mock th {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  position: relative;
}
.board-mock td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
}
.board-mock tr:last-child td { border-bottom: none; }
.board-mock td:last-child, .board-mock th:last-child { border-right: none; }
.board-mock tr:hover td { background: var(--surface-2); }

/* Column zones */
.col-ro { background: rgba(255,82,82,0.05); }
.col-ed { background: rgba(108,92,231,0.04); }
.th-ro  { background: rgba(255,82,82,0.10) !important; color: #c0392b !important; }
.th-ed  { background: rgba(108,92,231,0.10) !important; color: #6C5CE7 !important; }
.th-yl  { background: rgba(255,193,7,0.12) !important; color: #856404 !important; }
.th-gn  { background: rgba(0,191,165,0.10) !important; color: #00695C !important; }
.th-bl  { background: rgba(0,176,255,0.10) !important; color: #0277BD !important; }

/* Status chips in board */
.bs { display:inline-flex;align-items:center;padding:2px 8px;border-radius:3px;font-size:11px;font-weight:600;white-space:nowrap; }
.bs-idg      { background:#fdab3d;color:#fff; }
.bs-vvd      { background:#00c875;color:#fff; }
.bs-direct   { background:#784bd1;color:#fff; }
.bs-via      { background:#bda8f9;color:#5e4a9e; }
.bs-reverse  { background:#e484bd;color:#7a2e5a; }
.bs-yes      { background:#784bd1;color:#fff; }
.bs-no       { background:#bda8f9;color:#5e4a9e; }
.bs-lead     { background:#66ccff;color:#004c7a; }
.bs-disc     { background:#579bfc;color:#fff; }
.bs-deal     { background:#216edf;color:#fff; }
.bs-onhold   { background:#df2f4a;color:#fff; }
.bs-high     { background:#ffcb00;color:#7a5c00; }
.bs-normal   { background:#00c875;color:#fff; }
.bs-process  { background:#216edf;color:#fff; }
.bs-notreq   { background:#6d4040;color:#f7d4d4; }
.bs-notstart { background:#e0e0e0;color:#555; }
.bs-nda      { background:#9d99b9;color:#fff; }
.bs-agr      { background:#9aadbd;color:#fff; }
.bs-ddwe     { background:#bca58a;color:#fff; }
.bs-ddcl     { background:#757575;color:#fff; }
.bs-initiate { background:#00ca72;color:#fff;cursor:pointer;border:none;border-radius:3px;padding:3px 10px;font-size:11px;font-weight:700; }

/* Avatar */
.av { width:22px;height:22px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:9px;font-weight:800;color:#fff; }
.av-ma { background:#9b59b6; }
.av-ac { background:#e67e22; }
.av-aa { background:#2ecc71; }

/* Board legend */
.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 4px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.board-legend-item { display:flex;align-items:center;gap:6px; }
.bl-dot { width:11px;height:11px;border-radius:2px;flex-shrink:0; }
.bl-ro { background:rgba(255,82,82,0.25);border:1px solid rgba(255,82,82,0.5); }
.bl-ed { background:rgba(108,92,231,0.2);border:1px solid rgba(108,92,231,0.4); }
.bl-yl { background:rgba(255,193,7,0.25);border:1px solid rgba(255,193,7,0.5); }
.bl-gn { background:rgba(0,191,165,0.2);border:1px solid rgba(0,191,165,0.4); }
.bl-bl { background:rgba(0,176,255,0.2);border:1px solid rgba(0,176,255,0.4); }

/* Sync annotation */
.sync-anno {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  margin-top: 2px;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  line-height: 1.3;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  #main { max-width: calc(100% - var(--sidebar-width)); }
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  #main {
    margin-left: 0;
    max-width: 100%;
    padding: 24px 20px;
  }
  #sidebar-toggle { display: flex; }
  .home-nav-grid { grid-template-columns: 1fr; }
  .search-wrapper { max-width: 200px; }
  .page-title { font-size: 22px; }
}

/* ===== Overlay (mobile) ===== */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 850;
}
#overlay.show { display: block; }

/* ===== Scroll to top ===== */
#back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px; height: 40px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 800;
}
#back-to-top.show { opacity: 1; pointer-events: auto; }
#back-to-top:hover { transform: translateY(-3px); }

/* ===== Progress bar ===== */
#progress-bar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  height: 2px;
  background: var(--primary);
  z-index: 999;
  transition: width 0.1s linear;
}

/* ===== Separator ===== */
.section-sep { margin: 40px 0; border: none; border-top: 1px solid var(--border); }

/* ===== Column layout ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* ===== Permission matrix ===== */
.perm-check { color: var(--success); font-weight: 700; }
.perm-cross { color: var(--danger); }
.perm-partial { color: var(--warning); }

/* ===== FAQ accordion ===== */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.faq-item[open] {
  border-color: var(--primary);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 15px 18px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: var(--primary); }
.faq-q-mark {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.faq-toggle {
  margin-left: auto;
  flex: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  transition: transform var(--transition);
}
.faq-item[open] .faq-toggle { transform: rotate(45deg); }
.faq-answer {
  padding: 0 18px 16px 52px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 14px;
}
.faq-answer strong { color: var(--text); }
@media (max-width: 640px) {
  .faq-answer { padding-left: 18px; }
}

/* ===== Cathay-style FAQ toolbar (search + category tabs + popular + count) ===== */
.faq-search-wrap { position: relative; margin: 24px 0 14px; }
.faq-search { width: 100%; padding: 12px 16px 12px 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; transition: border-color var(--transition), box-shadow var(--transition); }
.faq-search::placeholder { color: var(--text-muted); }
.faq-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(61,90,201,0.12); }
.faq-search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.faq-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.faq-cat { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 14px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text-secondary); font-size: 13.5px; cursor: pointer; font-family: inherit; transition: background var(--transition), color var(--transition), border-color var(--transition); }
.faq-cat:hover { border-color: var(--primary); color: var(--primary); }
.faq-cat.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.faq-cat-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); font-size: 11.5px; line-height: 1; font-weight: 700; }
.faq-cat:hover .faq-cat-count { background: var(--primary-light); color: var(--primary); }
.faq-cat.active .faq-cat-count { background: rgba(255,255,255,0.22); color: #fff; }
.faq-pop-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 18px; }
.faq-pop-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.faq-pop { padding: 5px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); color: var(--text-secondary); font-size: 12.5px; cursor: pointer; font-family: inherit; transition: color var(--transition), border-color var(--transition); }
.faq-pop:hover { color: var(--primary); border-color: var(--primary); }
.faq-count { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.faq-count b { color: var(--primary); font-weight: 700; }
.faq-empty { display: none; padding: 36px; text-align: center; color: var(--text-muted); font-size: 14px; border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.faq-list { counter-reset: faq; }
.faq-list > .faq-item { counter-increment: faq; }
.faq-q-mark::before { content: counter(faq); }

/* ===== Site footer (version info) ===== */
.site-footer {
  margin-top: 48px;
  padding: 20px 0 8px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Flow diagram (Client journey swimlane) ===== */
.flow-diagram {
  margin: 14px 0 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
/* Scale to fit the content width — whole diagram visible, no horizontal scroll */
.flow-diagram svg { width: 100%; max-width: 1480px; height: auto; display: block; margin: 0 auto; }
.flow-note { font-size: 12.5px; color: var(--text-muted); font-style: italic; margin: 0 0 14px; max-width: none; }

/* Let the diagram break out of #main's side padding so it renders larger (less cramped) */
body:has(#page-overview.active) .flow-diagram { margin-left: -52px; margin-right: -52px; }
@media (max-width: 900px) { body:has(#page-overview.active) .flow-diagram { margin-left: 0; margin-right: 0; } }

/* ===== Step prev / next nav ===== */
.page-nav { display: flex; justify-content: space-between; gap: 12px; margin: 40px 0 8px; padding-top: 22px; border-top: 1px solid var(--border); }
.pn-btn { display: flex; flex-direction: column; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 18px; cursor: pointer; transition: border-color var(--transition), background var(--transition); max-width: 49%; }
.pn-btn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary-light) 35%, var(--surface)); }
.pn-next { margin-left: auto; align-items: flex-end; text-align: right; }
.pn-prev { align-items: flex-start; text-align: left; }
.pn-dir { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pn-label { font-size: 14px; font-weight: 700; color: var(--primary); }

/* ===== Accessible focus ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}
.sidebar-item:focus-visible,
.home-nav-card:focus-visible,
.faq-item summary:focus-visible {
  outline-offset: -2px;
}
/* Don't show the ring on the search input (it has its own focus treatment) */
#search-input:focus-visible { outline: none; }

/* ===== Responsive polish ===== */
@media (max-width: 1024px) {
  #sidebar {
    transform: translateX(-100%);
    width: min(86vw, 320px);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  #sidebar-toggle { display: flex; }
  #main {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    padding: 36px 32px 72px;
  }
  #progress-bar { left: 0; }
  .home-nav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .step-mini-grid { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .role-entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid,
  .card-grid[style] {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)) !important;
  }
  .flow-diagram {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .flow-diagram svg {
    min-width: 1080px;
  }
}

@media (max-width: 760px) {
  .home-nav-grid { grid-template-columns: 1fr; }
  .role-entry-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --header-height: 104px; }
  #header {
    height: var(--header-height);
    flex-wrap: wrap;
    align-content: center;
    padding: 8px 12px;
    gap: 8px;
  }
  .header-logo {
    flex: 1 1 auto;
    min-width: 0;
  }
  .header-logo-text {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-divider { display: none; }
  .header-actions { gap: 6px; }
  .lang-toggle { margin-left: 0; gap: 4px; }
  .lang-btn {
    min-width: 44px;
    min-height: 34px;
    padding: 4px 9px;
  }
  #theme-toggle,
  #sidebar-toggle {
    width: 38px;
    height: 38px;
  }
  .search-wrapper {
    order: 10;
    flex-basis: 100%;
    max-width: none;
  }
  #search-results {
    position: fixed;
    top: calc(var(--header-height) - 2px);
    left: 12px;
    right: 12px;
    max-height: min(60vh, 420px);
  }
  #main { padding: 24px 18px 64px; }
  .home-hero { padding: 28px 0 24px; }
  .hero-logos {
    gap: 10px;
    margin-bottom: 20px;
  }
  .hero-logo-wrap {
    height: 46px;
    padding: 7px 10px;
  }
  .hero-logo-img { max-width: 118px; }
  .home-hero h1 {
    max-width: 14em;
    margin-left: auto;
    margin-right: auto;
    font-size: 24px;
    line-height: 1.25;
  }
  .home-hero p { font-size: 14.5px; }
  .page-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
  }
  .page-title { font-size: 25px; }
  h2 { margin-top: 38px; }
  p,
  li { font-size: 14px; }
  .step-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-mini-card,
  .role-entry-card,
  .home-nav-card,
  .card {
    padding: 16px;
  }
  .steps li {
    padding: 14px 14px 14px 52px;
  }
  .table-wrap,
  .board-mock-wrap,
  .flow-diagram {
    margin-left: -18px;
    margin-right: -18px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .table-wrap,
  .board-mock-scroll,
  .sl-overflow,
  .flow-wrap {
    -webkit-overflow-scrolling: touch;
  }
  th,
  td {
    padding: 10px 12px;
  }
  .flow-diagram { padding: 10px; }
  .flow-diagram svg { min-width: 940px; }
  .auto-card {
    flex-direction: column;
    gap: 6px;
  }
  .auto-card .ac-arrow {
    align-self: flex-start;
    transform: rotate(90deg);
  }
  .big-flow-row {
    flex-direction: column;
    align-items: stretch;
  }
  .big-flow-arrow {
    align-self: center;
    transform: rotate(90deg);
  }
  .page-nav {
    flex-direction: column;
  }
  .pn-btn {
    width: 100%;
    max-width: none;
  }
  .pn-next {
    align-items: flex-start;
    text-align: left;
  }
  #back-to-top {
    right: 16px;
    bottom: 16px;
  }
  .site-footer { line-height: 1.6; }
}

@media (max-width: 420px) {
  .header-logo-text > .zh-content,
  .header-logo-text > .en-content {
    display: none;
  }
  .header-logo-text { max-width: none; }
  .step-mini-grid { grid-template-columns: 1fr; }
  .faq-cat,
  .faq-pop {
    width: 100%;
    justify-content: space-between;
  }
  .faq-pop-row { align-items: stretch; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover, .home-nav-card:hover { transform: none; }
}
