:root {
  --keyboard-bg: #eff6ff;
  --keyboard-header: #2563eb;
  --slash-bg: #f5f3ff;
  --slash-header: #7c3aed;
  --skills-bg: #ecfdf5;
  --skills-header: #059669;
  --memory-bg: #fffbeb;
  --memory-header: #d97706;
  --config-bg: #fff7ed;
  --config-header: #c2410c;
  --workflows-bg: #fef2f2;
  --workflows-header: #dc2626;
  --mcp-bg: #ecfeff;
  --mcp-header: #0891b2;
  --cli-bg: #f9fafb;
  --cli-header: #4b5563;
  --footer-bg: #1f2937;
  --footer-text: #f9fafb;
  --font-sans: "Inter", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", "Fira Code", "Consolas", "Liberation Mono", monospace;
}

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

html {
  font-size: 11.5px;
}

body {
  font-family: var(--font-sans);
  font-size: 0.87rem;
  line-height: 1.12;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.07), transparent 22%),
    radial-gradient(circle at top right, rgba(217, 119, 6, 0.06), transparent 20%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: #1f2937;
  padding: 4.5mm;
}

@page {
  size: a4 landscape;
  margin: 8mm;
}

.page {
  width: 100%;
  max-width: 326mm;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  padding: 3mm;
  backdrop-filter: blur(10px);
}

.toolbar-shell {
  width: 100%;
  max-width: 326mm;
  margin: 0 auto 1.5mm;
}

.header {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5mm;
  padding-bottom: 0.8mm;
  border-bottom: 1px solid #e5e7eb;
  gap: 1.2mm;
}

.header h1 {
  font-size: 1.32rem;
  font-weight: 700;
  color: #111827;
}

.header-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2mm;
  flex-wrap: wrap;
}

.title-stack {
  min-width: 0;
}

.header-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3mm;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 1.5mm;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75mm;
  padding: 0.65mm;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  max-width: 100%;
}

.mode-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.48rem 0.72rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.mode-btn:hover:not(.active) {
  background: rgba(226, 232, 240, 0.8);
  color: #0f172a;
}

.mode-btn.active {
  background: #111827;
  color: #fff;
}

.product-switch .mode-btn {
  min-width: 0;
  white-space: nowrap;
}

.product-switch {
  flex: 1 1 210mm;
}

.lang-switch .mode-btn {
  min-width: 50px;
}

.header-meta {
  font-size: 0.72rem;
  color: #6b7280;
  text-align: right;
}

.header-meta .version-info {
  display: block;
  font-weight: 600;
  color: #374151;
}

.header-meta .last-updated {
  display: block;
  font-size: 0.67rem;
  color: #9ca3af;
}

.changelog {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 1.2mm 2.6mm;
  margin-bottom: 1.5mm;
  font-size: 0.69rem;
}

.changelog-header {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.35mm;
  display: flex;
  align-items: center;
  gap: 1mm;
  cursor: pointer;
  user-select: none;
}

.changelog-header a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed #92400e;
}

.changelog-dismiss {
  margin-left: auto;
  font-size: 0.85rem;
  color: #92400e;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
}

.changelog-dismiss:hover {
  opacity: 1;
}

.changelog-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75mm 3.2mm;
  color: #78350f;
  list-style: none;
}

.changelog-list li {
  display: flex;
  align-items: center;
  gap: 1mm;
}

.changelog-list li::before {
  content: "•";
  color: #f59e0b;
  font-weight: 700;
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 1fr;
  gap: 1.5mm;
  align-items: stretch;
}

.section {
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.section-keyboard-mcp > .section:last-child,
.section-slash-memory > .section:last-child,
.section-workflows-config > .section:last-child,
.section-skills-cli > .section:last-child {
  flex: 1;
}

.section-header {
  padding: 1mm 1.8mm;
  color: #fff;
  font-weight: 700;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  display: flex;
  align-items: center;
  gap: 1mm;
}

.section-content {
  padding: 1.2mm 2.1mm;
  flex: 1;
}

.sub-header {
  font-weight: 700;
  font-style: italic;
  font-size: 0.72rem;
  color: #374151;
  margin-top: 0.95mm;
  margin-bottom: 0.3mm;
  padding-bottom: 0.2mm;
  border-bottom: 1px dotted rgba(0, 0, 0, 0.15);
}

.sub-header:first-child {
  margin-top: 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  column-gap: 1.35mm;
  align-items: start;
  padding: 0.26mm 0;
  line-height: 1.18;
}

.row--key-only,
.row--desc-only,
.row--compact {
  grid-template-columns: 1fr;
}

.row--compact {
  row-gap: 0.3mm;
}

.row code,
.changelog code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row code,
.desc code,
.footer-item code {
  background: rgba(255, 255, 255, 0.75);
  border-radius: 4px;
  padding: 0.08rem 0.24rem;
}

.key {
  font-family: var(--font-mono);
  font-size: 0.77rem;
  font-weight: 600;
  color: #1f2937;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
}

.desc {
  font-size: 0.76rem;
  color: #4b5563;
  min-width: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.row--compact .desc {
  color: #5b6474;
}

.keycap {
  display: inline-block;
  background: linear-gradient(180deg, #fafafa 0%, #e5e7eb 100%);
  border: 1px solid #d1d5db;
  border-radius: 2px;
  padding: 0.12mm 1mm;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  margin-right: 0.3mm;
}

.badge-new {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 0.52rem;
  font-weight: 700;
  padding: 0.15mm 0.9mm;
  border-radius: 2px;
  margin-left: 1mm;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.section-keyboard {
  background: var(--keyboard-bg);
}

.section-keyboard .section-header {
  background: var(--keyboard-header);
}

.section-slash {
  background: var(--slash-bg);
}

.section-slash .section-header {
  background: var(--slash-header);
}

.section-skills {
  background: var(--skills-bg);
}

.section-skills .section-header {
  background: var(--skills-header);
}

.section-memory {
  background: var(--memory-bg);
}

.section-memory .section-header {
  background: var(--memory-header);
}

.section-workflows {
  background: var(--workflows-bg);
}

.section-workflows .section-header {
  background: var(--workflows-header);
}

.section-mcp {
  background: var(--mcp-bg);
}

.section-mcp .section-header {
  background: var(--mcp-header);
}

.section-cli {
  background: var(--cli-bg);
}

.section-cli .section-header {
  background: var(--cli-header);
}

.section-config {
  background: var(--config-bg);
}

.section-config .section-header {
  background: var(--config-header);
}

.section-keyboard-mcp,
.section-slash-memory,
.section-workflows-config,
.section-skills-cli {
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.section-keyboard-mcp {
  grid-column: 1;
  grid-row: 1;
}

.section-slash-memory {
  grid-column: 2;
  grid-row: 1;
}

.section-workflows-config {
  grid-column: 3;
  grid-row: 1;
}

.section-skills-cli {
  grid-column: 4;
  grid-row: 1;
}

.footer {
  margin-top: 1.5mm;
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 1.2mm 2.1mm;
  border-radius: 3px;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.4mm;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5mm;
  align-items: center;
}

.footer-label {
  font-weight: 700;
  color: #9ca3af;
  margin-right: 1mm;
}

.footer-item {
  display: inline-flex;
  align-items: center;
  gap: 0.75mm;
}

.footer-item code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.22mm 0.85mm;
  border-radius: 2px;
}

.footer-sep {
  color: #6b7280;
}

.os-toggle {
  display: flex;
  border: 1px solid #9ca3af;
  border-radius: 5px;
  overflow: hidden;
  background: #f3f4f6;
}

.os-btn {
  background: #fff;
  border: none;
  padding: 3px 7px;
  font-size: 0.76rem;
  cursor: pointer;
  line-height: 1;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.os-btn + .os-btn {
  border-left: 1px solid #9ca3af;
}

.os-btn.active {
  background: #111827;
  color: #fff;
}

.os-btn:hover:not(.active) {
  background: #f3f4f6;
}

@media print {
  html {
    font-size: 8.2px !important;
  }

  body {
    padding: 0;
    background: #fff;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .page {
    max-width: none;
    width: 100%;
    height: 100vh;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .main-grid {
    gap: 1.2mm;
  }

  .section-keyboard-mcp,
  .section-slash-memory,
  .section-workflows-config,
  .section-skills-cli {
    gap: 1.2mm;
  }

  .section {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
  }

  .section-content {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .sub-header {
    break-after: avoid;
    page-break-after: avoid;
  }

  .sub-header + .row,
  .sub-header + .two-col,
  .sub-header + .three-col {
    break-before: avoid;
    page-break-before: avoid;
  }

  .key,
  .keycap,
  code,
  .footer-item code {
    font-family: "Courier New", "Courier", monospace !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .section-header {
    padding: 0.7mm 1.8mm;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .section-content {
    padding: 0.85mm 1.7mm;
  }

  .row {
    padding: 0.08mm 0;
  }

  .sub-header {
    margin-top: 0.65mm;
  }

  .keycap {
    background: #f3f4f6 !important;
    box-shadow: none;
    border: 1px solid #9ca3af;
  }

  .footer {
    margin-top: 1mm;
    padding: 0.85mm 1.7mm;
    background: #374151 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .toolbar-shell,
  .os-toggle {
    display: none !important;
  }

  .footer form,
  .footer form + span {
    display: none !important;
  }

  .header {
    margin-bottom: 1mm;
  }

  .changelog {
    display: none !important;
  }
}

@media screen and (max-width: 1100px) {
  html {
    font-size: 10px;
  }

  .main-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    align-items: start;
  }

  .section-keyboard-mcp {
    grid-column: 1;
    grid-row: 1;
  }

  .section-slash-memory {
    grid-column: 2;
    grid-row: 1;
  }

  .section-workflows-config {
    grid-column: 1;
    grid-row: 2;
  }

  .section-skills-cli {
    grid-column: 2;
    grid-row: 2;
  }
}

@media screen and (max-width: 600px) {
  html {
    font-size: 11px;
  }

  body {
    padding: 3mm;
  }

  .toolbar-shell {
    margin-bottom: 1mm;
  }

  .header {
    gap: 4px;
  }

  .header-toolbar,
  .header-body,
  .toolbar-actions {
    width: 100%;
  }

  .header-toolbar {
    flex-wrap: wrap;
  }

  .header-body {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.5mm;
  }

  .toolbar-actions {
    justify-content: space-between;
  }

  .header h1 {
    font-size: 1.2rem;
    white-space: normal;
  }

  .product-switch {
    width: 100%;
  }

  .product-switch .mode-btn {
    flex: 1;
    min-width: 0;
  }

  .lang-switch .mode-btn {
    min-width: 44px;
  }

  .header-meta {
    width: 100%;
    text-align: left;
  }

  .os-btn {
    padding: 2px 6px;
  }

  .os-btn svg {
    width: 11px;
    height: 11px;
  }

  .main-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .row {
    grid-template-columns: 1fr;
    row-gap: 1px;
  }

  .section-keyboard-mcp,
  .section-slash-memory,
  .section-workflows-config,
  .section-skills-cli {
    grid-column: 1;
    grid-row: auto;
  }

  .footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .changelog-list {
    flex-direction: column;
    gap: 1mm;
  }
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 4mm;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 3mm;
}

@media screen and (max-width: 500px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}
