/* SheetLab — document / IDE spreadsheet feel */
:root {
  --bg: #FAFBFC;
  --sidebar: #EEF1F5;
  --ink: #202124;
  --muted: #5F6368;
  --docs-blue: #1A73E8;
  --docs-blue-soft: #E8F0FE;
  --code-bg: #1E1E1E;
  --code-fg: #D4D4D4;
  --grid-line: #DADCE0;
  --zebra: #F8F9FA;
  --wrong-bg: #FCE8E6;
  --wrong-border: #EA4335;
  --right-bg: #E6F4EA;
  --right-border: #34A853;
  --paper: #FFFFFF;
  --radius: 4px;
  --shell: min(1140px, calc(100% - 2rem));
  --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--docs-blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: #1557B0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.wrap {
  width: var(--shell);
  margin-inline: auto;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.84em;
  letter-spacing: 0.01em;
}

/* Header */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--grid-line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  background: var(--docs-blue-soft);
  color: var(--docs-blue);
  border: 1px solid #C2D7F7;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: lowercase;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
}

.nav a {
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--docs-blue);
}

/* Hero */
.hero {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--grid-line);
  background: linear-gradient(180deg, var(--paper) 0%, var(--bg) 100%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: start;
}

.eyebrow {
  color: var(--docs-blue);
  font-weight: 500;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.brand-hero {
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.hero-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  max-width: 36ch;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--docs-blue);
  color: #fff;
}

.btn-primary:hover {
  background: #1557B0;
  color: #fff;
}

.btn-ghost {
  background: var(--paper);
  border-color: var(--grid-line);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--docs-blue);
  color: var(--docs-blue);
}

.hero-panel {
  background: var(--paper);
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(32, 33, 36, 0.08);
}

.panel-foot {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  border-top: 1px solid var(--grid-line);
  background: var(--bg);
}

/* Formula bar */
.formula-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: var(--paper);
  border-bottom: 1px solid var(--grid-line);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.formula-bar .fx {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
  flex-shrink: 0;
}

.formula-bar .formula-input {
  flex: 1;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mini grid (homepage) */
.mini-grid {
  display: grid;
  grid-template-columns: 2rem repeat(4, 1fr);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.mg-head,
.mg-row,
.mg-cell {
  padding: 0.35rem 0.45rem;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
}

.mg-head {
  background: var(--sidebar);
  color: var(--muted);
  text-align: center;
  font-weight: 500;
}

.mg-head:first-child {
  background: var(--sidebar);
}

.mg-row {
  background: var(--sidebar);
  color: var(--muted);
  text-align: center;
  font-weight: 500;
}

.mg-cell {
  background: var(--paper);
}

.mini-grid .mg-cell:nth-child(8n+6),
.mini-grid .mg-cell:nth-child(8n+8) {
  background: var(--zebra);
}

.mg-cell.active {
  outline: 2px solid var(--docs-blue);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}

/* Sections */
.section {
  padding: 2rem 0;
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.feature-item {
  background: var(--paper);
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.feature-lead {
  grid-column: 1 / -1;
  border-left: 3px solid var(--docs-blue);
}

.feature-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
}

.feature-item h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  line-height: 1.35;
}

.feature-item h3 a {
  text-decoration: none;
  color: var(--ink);
}

.feature-item h3 a:hover {
  color: var(--docs-blue);
}

.feature-item p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.topic-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.topic-row a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--sidebar);
  border: 1px solid var(--grid-line);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--ink);
}

.topic-row a:hover {
  border-color: var(--docs-blue);
  color: var(--docs-blue);
}

.topic-row .mono {
  color: var(--muted);
}

.tutorial-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tutorial-list li {
  border-bottom: 1px solid var(--grid-line);
  padding: 0.85rem 0;
}

.tutorial-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  text-decoration: none;
  color: var(--ink);
}

.tutorial-list a:hover .tutorial-list-title {
  color: var(--docs-blue);
}

.tutorial-list-title {
  font-weight: 600;
}

.tutorial-list-meta {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.tutorial-list-desc {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.cat-block + .cat-block {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--grid-line);
}

.cat-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

/* Page hero */
.page-hero {
  padding: 2rem 0 1rem;
}

.page-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 52ch;
}

/* Doc article layout */
.doc-hero {
  padding: 1.75rem 0 1rem;
}

.breadcrumb {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.breadcrumb a {
  text-decoration: none;
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--docs-blue);
}

.doc-hero h1 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.65rem, 3.2vw, 2.35rem);
  line-height: 1.2;
}

.article-meta {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 160px;
  gap: 2rem;
  align-items: start;
  padding: 1.5rem 0 3rem;
}

.doc-toc {
  position: sticky;
  top: 4.5rem;
  background: var(--sidebar);
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.toc-label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 0.28rem 0.45rem;
  border-left: 2px solid transparent;
  text-decoration: none;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.35;
}

.toc-l3 a {
  padding-left: 1rem;
  font-size: 0.82rem;
}

.toc-list a:hover {
  color: var(--docs-blue);
}

.toc-list a.is-active {
  color: var(--docs-blue);
  border-left-color: var(--docs-blue);
  background: var(--docs-blue-soft);
  font-weight: 500;
}

.doc-main {
  min-width: 0;
}

.doc-rail {
  position: sticky;
  top: 4.5rem;
}

/* Prose */
.prose {
  font-size: 1.02rem;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.35rem;
  scroll-margin-top: 5rem;
}

.prose h3 {
  margin: 1.5rem 0 0.55rem;
  font-size: 1.1rem;
  scroll-margin-top: 5rem;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--grid-line);
  margin: 2rem 0;
}

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--docs-blue);
  background: var(--docs-blue-soft);
  color: var(--ink);
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--sidebar);
  padding: 0.12em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--grid-line);
}

/* Zebra spreadsheet tables */
.sheet-prose .table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  background: var(--paper);
}

.sheet-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-family: var(--font-mono);
}

.sheet-prose th,
.sheet-prose td {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--grid-line);
  text-align: left;
}

.sheet-prose th {
  background: var(--sidebar);
  font-weight: 600;
  color: var(--ink);
}

.sheet-prose tr:nth-child(even) td {
  background: var(--zebra);
}

/* Wrong vs Right comparison */
.compare-table th:first-child {
  background: var(--wrong-bg);
  color: var(--wrong-border);
  border-bottom: 2px solid var(--wrong-border);
}

.compare-table th:last-child {
  background: var(--right-bg);
  color: var(--right-border);
  border-bottom: 2px solid var(--right-border);
}

.compare-table td:first-child {
  background: color-mix(in srgb, var(--wrong-bg) 55%, white);
}

.compare-table td:last-child {
  background: color-mix(in srgb, var(--right-bg) 55%, white);
}

/* Code + formula block */
.formula-block {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid #333;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.formula-block .formula-bar {
  background: #2D2D2D;
  border-bottom: 1px solid #444;
}

.formula-block .formula-bar .fx {
  color: #888;
}

.formula-block .formula-bar .formula-input {
  color: #9CDCFE;
}

.formula-block pre {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  overflow-x: auto;
}

.formula-block code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.5rem;
}

.tag {
  padding: 0.2rem 0.55rem;
  background: var(--sidebar);
  border: 1px solid var(--grid-line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}

.related-block {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--grid-line);
}

.related-block h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

/* Ads */
.ads-slot {
  min-height: 90px;
  margin: 1rem 0;
  background: repeating-linear-gradient(
    -45deg,
    var(--sidebar),
    var(--sidebar) 8px,
    var(--bg) 8px,
    var(--bg) 16px
  );
  border: 1px dashed var(--grid-line);
  border-radius: var(--radius);
}

.ads-slot-side {
  min-height: 250px;
}

.ads-slot-inline {
  margin-top: 2rem;
}

/* Contact */
.contact-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--sidebar);
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
}

.contact-box label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.contact-box input,
.contact-box textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--grid-line);
  border-radius: var(--radius);
  font: inherit;
  background: var(--paper);
}

.contact-box button {
  margin-top: 1rem;
}

.page-body {
  padding-bottom: 3rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--grid-line);
  background: var(--paper);
  padding: 2rem 0 1.25rem;
  margin-top: 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.footer-brand {
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.footer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 42ch;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-content: start;
}

.footer-links a {
  text-decoration: none;
  font-weight: 500;
}

.footer-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--grid-line);
  font-size: 0.88rem;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .feature-lead {
    grid-column: auto;
  }

  .doc-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .doc-toc {
    position: static;
    max-height: none;
    margin-bottom: 1.25rem;
  }

  .doc-rail {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .tutorial-list a {
    flex-direction: column;
    gap: 0.25rem;
  }

  .footer-meta {
    flex-direction: column;
  }

  body.has-doc-toc .doc-toc {
    border-radius: 0;
    margin-inline: -1rem;
    border-left: 0;
    border-right: 0;
  }
}


/* === Shared responsive & brand enhancements === */
.brand-logo,.footer-logo{display:block;height:auto;max-width:100%}
.brand .brand-logo{width:min(180px,52vw)}
.footer-logo{width:min(160px,45vw);margin-bottom:.75rem;opacity:.95}
.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
html{-webkit-text-size-adjust:100%;overflow-x:hidden}
body{overflow-x:hidden}
img,svg,video{max-width:100%;height:auto}
.nav a,.menu-toggle,.btn,.footer-nav a,.nav-links a{min-height:44px;display:inline-flex;align-items:center}
@media(max-width:680px){.menu-toggle{display:inline-flex}.nav.is-open,.nav-links.is-open{display:flex!important;flex-direction:column;width:100%}}
@media(max-width:480px){body{font-size:1rem}h1{font-size:clamp(1.65rem,6vw,2.35rem)}}

/* Network & cross-links */
.network-footer{padding:2rem 0;border-top:1px solid var(--line,rgba(0,0,0,.08));margin-top:0}
.network-title{font-size:.85rem;text-transform:uppercase;letter-spacing:.06em;margin:0 0 .75rem;opacity:.75;font-weight:600}
.network-links{list-style:none!important;margin:0;padding:0;display:grid;gap:.65rem;grid-template-columns:repeat(auto-fill,minmax(200px,1fr))}
.network-links li{list-style:none;margin:0;padding:0}
.network-links a{display:flex;flex-direction:column;gap:.15rem;padding:.65rem .75rem;border-radius:6px;text-decoration:none;border:1px solid var(--line,rgba(0,0,0,.08))}
.network-links strong{font-size:.95rem}
.network-links span{font-size:.8rem;opacity:.75}
.feature-thumb{display:block;margin:-1.15rem -1.2rem 1rem;aspect-ratio:16/9;overflow:hidden}
.feature-thumb img{width:100%;height:100%;object-fit:cover}
.index-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(16rem,1fr));gap:1rem}
.index-card a{display:flex;flex-direction:column;height:100%;text-decoration:none;color:inherit;border:1px solid var(--grid,var(--line,#ddd));border-radius:8px;overflow:hidden;background:var(--paper,var(--white,#fff))}
.index-card-thumb{aspect-ratio:16/10;overflow:hidden;background:var(--cream-deep,#eee)}
.index-card-thumb img,.index-card-thumb .thumb-label{display:block}
.index-card-thumb img{width:100%;height:100%;object-fit:cover}
.index-card-body{padding:1rem 1.1rem 1.2rem}
.index-card-body h3{margin:0 0 .35rem;font-size:1.05rem}
.index-card-body p{margin:0 0 .35rem}
.cross-links{margin:1.5rem 0;padding:1rem 1.1rem;border-left:3px solid var(--steel,var(--accent,#2F5D8C));background:rgba(0,0,0,.03);font-size:.95rem}
.cross-links a{font-weight:600}
.article-hero-img{margin:1rem 0 1.25rem;border-radius:8px;overflow:hidden;aspect-ratio:16/9;background:var(--bg-ink,#eee)}
.article-hero-img img{width:100%;height:100%;object-fit:cover}
