:root{
  --bg:#f8f9fa; --panel:#ffffff; --text:#1a1a1a; --muted:#555; --accent:#3366cc
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><rect width="8" height="8" fill="%23f8f9fa"/><circle cx="1" cy="1" r="0.5" fill="%23e2e3e5"/></svg>') repeat;color:var(--text);font-family:system-ui,-apple-system,Segoe UI,Roboto,Inter,Helvetica,Arial,sans-serif;line-height:1.6}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
.header{position:sticky;top:0;background:#fff;border-bottom:1px solid #ddd;box-shadow:0 2px 4px rgba(0,0,0,.04)}
.container{max-width:1100px;margin:0 auto;padding:16px}
.brand{font-weight:700;font-size:1.2em}
.hero{padding:32px 16px;border-bottom:1px solid #ddd;background:#fff}
.hero h1{margin:0 0 8px;font-size:clamp(24px,4vw,40px)}
.hero p{margin:6px 0;color:var(--muted);max-width:80ch}
.grid{display:grid;grid-template-columns:320px 1fr;gap:16px;padding:16px}

.panel{background:var(--panel);border:1px solid #ddd;border-radius:12px;padding:14px;box-shadow:0 1px 3px rgba(0,0,0,.05)}
.tool-list{display:flex;flex-direction:column;gap:4px}
.tool-item{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-radius:8px;border:1px solid #ddd;background:#fdfdfd}
.tool-item:hover{background:#f7f9fc}
.tool-name{margin:0;font-size:.95em;font-weight:600;flex:1;min-width:0}
.btns{display:flex;gap:6px;align-items:center;flex-shrink:0}
.btn{display:inline-block;padding:6px 12px;border:1px solid #bbb;border-radius:7px;font-size:.88em;text-decoration:none;white-space:nowrap}
.btn.primary{background:var(--accent);color:#fff;border-color:var(--accent)}
.viewer{flex-grow:1;min-width:0;border-radius:12px;overflow:hidden;border:1px solid #ddd;background:#fff;box-shadow:inset 0 0 10px rgba(0,0,0,.03)}
.viewer iframe{width:100%;height:85vh;border:0;display:block;background:#fff}
.small{font-size:.92em;color:var(--muted)}
footer{border-top:1px solid #ddd;color:#666;margin-top:16px;padding:16px;background:#fff;text-align:center}

.sticky{position:sticky;top:16px;align-self:start}
.nav-heading{margin:0 0 10px;font-size:.8em;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--muted)}
.btn.icon-btn{padding:5px 8px;font-size:1em;line-height:1;border-radius:7px;color:var(--muted);text-decoration:none;border-color:#ddd}
.btn.icon-btn:hover{background:#f0f0f0;border-color:#bbb}

/* Sticky sidebar */
.sidebar{position:sticky;top:16px;align-self:flex-start;width:300px;flex-shrink:0}

/* Back to top button */
#backTop{position:fixed;right:24px;bottom:24px;padding:10px 12px;border-radius:999px;border:1px solid #bbb;background:var(--accent);color:#fff;
box-shadow:0 2px 6px rgba(0,0,0,.15);cursor:pointer;display:none;font-weight:700}
#backTop.show{display:inline-block}

/* Make viewer fill the available viewport height (reduced need to scroll) */
.hero{padding:20px 16px;border-bottom:1px solid #ddd;background:#fff}
.viewer{min-height:auto;height:calc(100vh - 160px);} /* approximate header+hero */
.viewer iframe{height:calc(100vh - 160px);}

/* === Tool viewer sizing & scroll (Aug 2025) ===
   Increase the space for embedded practice tools and enable scrolling
   in the viewer if content is still too large.
*/
.viewer{
  /* Give more space and allow scrolling inside the viewer */
  height: calc(100vh - 100px);
  min-height: 720px;
  overflow: auto; /* key: show a scrollbar in this area if needed */
}

.viewer iframe{
  /* Larger initial canvas for tools */
  width: 100%;
  height: auto;    /* let content grow; min-height provides base space */
  min-height: 1100px;
  border: 0;
  display: block;
  background: #fff;
}

/* Responsive tweaks */
@media (max-width: 900px){
  .viewer{
    height: calc(100vh - 80px);
    min-height: 600px;
  }
  .viewer iframe{
    min-height: 900px;
  }
}

/* === Layout width & sidebar position (Aug 2025) ===
   Make the main content wider, nudge the Practice Tools panel further left,
   and give the viewer more horizontal space.
*/
.container{
  max-width: 1400px; /* wider page */
  padding: 12px;     /* slightly tighter padding to bring content closer to edges */
}

@media (min-width: 1500px){
  .container{ max-width: 1600px; }
}

.grid{
  grid-template-columns: 260px 1fr; /* narrower sidebar, more room for viewer */
  gap: 12px;                        /* slightly reduced gap */
}

/* On very wide screens, make sidebar a touch smaller */
@media (min-width: 1400px){
  .grid{ grid-template-columns: 240px 1fr; gap: 12px; }
}

/* Ensure the viewer uses the gained width fully */
.viewer{ width: 100%; }

/* Optional: make cards + buttons adapt to narrower sidebar */
.panel .tool-name{font-size:.95em;flex:1;min-width:0}
.panel .btns .btn{ padding: 8px 10px; }

/* === Hero side-by-side layout with logo (Aug 2025) === */
.hero-inner {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}

.hero-content {
  flex: 1 1 60%;
}

.hero-logo img {
  max-width: 280px;
  height: auto;
}

@media (max-width: 720px) {
  .hero-inner {
    flex-direction: column;
    text-align: center;
  }
  .hero-logo img {
    max-width: 200px;
    margin-top: 16px;
  }
}

/* Ensure hero content and logo align side by side */
.hero-inner {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: nowrap;
}

.hero-content {
  flex: 1 1 60%;
}

.hero-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo img {
  max-width: 280px;
  height: auto;
}

@media (max-width: 720px) {
  .hero-inner {
    flex-direction: column;
    text-align: center;
  }
  .hero-logo img {
    max-width: 200px;
    margin-top: 16px;
  }
}

/* === Ensure hero content and logo sit side by side even with .hero-flex wrapper === */
.hero-flex{
  display:flex;
  gap:24px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:nowrap;
}
.hero-flex > .container{ flex:1 1 60%; }
.hero-logo img{ max-width:280px; height:auto; }
/* Mobile stack */
@media (max-width:720px){
  .hero-flex{ flex-direction:column; text-align:center; }
  .hero-logo img{ max-width:200px; margin-top:16px; }
}

/* === Tighter hero logo spacing (Aug 2025) === */
.hero-flex {
  display: flex;
  gap: 12px; /* reduced gap */
  align-items: center;
  justify-content: flex-start;
}
.hero-flex > .container {
  flex: 0 1 68%; /* give text more width, bring logo closer */
}
.hero-logo img {
  max-width: 280px; /* keep current size */
}

/* === Final hero alignment: top on desktop, center on medium, stack on mobile === */
.hero-flex {
  display: flex;
  gap: 0;
  align-items: flex-start; /* top alignment by default */
}
.hero-flex > .container {
  margin-right: 8px;
  flex: 1;
}
.hero-logo img {
  max-width: 280px;
  height: auto;
}

/* On medium screens, center vertically */
@media (max-width: 1100px) {
  .hero-flex {
    align-items: center;
  }
}

/* Mobile stacking */
@media (max-width: 720px) {
  .hero-flex {
    flex-direction: column;
    text-align: center;
  }
  .hero-logo img {
    max-width: 200px;
    margin-top: 16px;
  }
}

/* === Hero alignment & zero-gap (Aug 2025) === */
.hero-flex {
  display: flex;
  gap: 0;               /* remove space between text and logo */
  align-items: flex-start; /* top-align on wide screens */
  justify-content: flex-start;
}
.hero-flex > .container {
  margin-right: 8px;    /* tiny buffer */
  flex: 1;              /* allow natural shrink/wrap */
}
.hero-logo img {
  max-width: 280px;     /* keep current size */
  height: auto;
}

/* Medium screens: drift toward vertical centre alignment */
@media (max-width: 1100px) {
  .hero-flex { align-items: center; }
}

/* Mobile: stack vertically */
@media (max-width: 720px) {
  .hero-flex {
    flex-direction: column;
    text-align: center;
  }
  .hero-logo img {
    max-width: 200px;
    margin-top: 16px;
  }
}

/* === Hero: headline full-width; paragraphs + logo side-by-side (Aug 2025) === */
.hero-row{
  display:flex;
  gap:0;                 /* no space between text and logo */
  align-items:flex-start;/* logo starts under the headline, aligned to top of text */
  justify-content:flex-start;
}
.hero-copy{
  flex:1;                /* text takes remaining width */
  margin:0;              /* ensure no extra right margin */
}
.hero-logo img{
  max-width:280px;       /* keep size you liked */
  height:auto;
  display:block;
}
@media (max-width: 720px){
  .hero-row{flex-direction:column; text-align:center;}
  .hero-logo img{max-width:200px; margin-top:16px;}
}


/* ===== UI Enhancements (Aug 2025) — visual polish without layout changes ===== */
:root { --bg:#f8fafc; --panel:#ffffff; --text:#111827; --muted:#6b7280; --accent:#10b981; --border:#e5e7eb; --ring:rgba(16,185,129,.35); }
:root[data-theme="dark"] { --bg:#0b1220; --panel:#0f172a; --text:#e5e7eb; --muted:#94a3b8; --accent:#34d399; --border:#1f2937; --ring:rgba(52,211,153,.35); }
body{background:var(--bg); color:var(--text)}
a{color:var(--accent)}
.header,.hero,.panel,.viewer,footer{background:var(--panel); border-color:var(--border)}
.small,.hero p{color:var(--muted)}
.btn{transition:background-color .2s ease, border-color .2s ease, transform .06s ease}
.btn:active{transform:translateY(1px)}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#fff}
.tool-item{border-color:var(--border); background:color-mix(in oklab, var(--panel), white 4%)}
.tool-item:hover{border-color:var(--accent); box-shadow:0 4px 16px rgba(0,0,0,.06)}
.viewer{box-shadow:0 8px 30px rgba(0,0,0,.06) inset, 0 12px 30px rgba(0,0,0,.06); position:relative}
.viewer.loading::after{content:"Loading…"; position:absolute; inset:0; display:grid; place-items:center; background:linear-gradient(180deg,transparent,rgba(0,0,0,.04),transparent); color:var(--muted); font-weight:600; pointer-events:none}
:where(button,a,input,select,textarea):focus-visible{outline:3px solid var(--ring); outline-offset:2px; border-radius:10px}
html{scroll-behavior:smooth}
*::-webkit-scrollbar{height:10px;width:10px}
*::-webkit-scrollbar-thumb{background:var(--border); border-radius:999px}
*::-webkit-scrollbar-thumb:hover{background:color-mix(in oklab, var(--border), black 10%)}
*::-webkit-scrollbar-track{background:transparent}
.header{backdrop-filter:saturate(140%) blur(4px)}
.reveal{opacity:0; transform:translateY(6px); transition:opacity .35s ease, transform .35s ease}
.reveal.reveal-in{opacity:1; transform:translateY(0)}
@media (prefers-reduced-motion: reduce){ .reveal{opacity:1!important; transform:none!important} }
#themeToggle{position:fixed; right:16px; bottom:76px; border:1px solid var(--border); background:var(--panel); color:var(--text); border-radius:999px; padding:10px 12px; font-weight:700; box-shadow:0 2px 8px rgba(0,0,0,.15); cursor:pointer; z-index:9999}
#shortcutsHelp[hidden]{display:none}
#shortcutsHelp{position:fixed; inset:0; background:rgba(0,0,0,.45); display:grid; place-items:center; z-index:9999}
#shortcutsHelp .box{background:var(--panel); color:var(--text); border:1px solid var(--border); border-radius:12px; padding:16px; width:min(520px,92vw); box-shadow:0 20px 50px rgba(0,0,0,.35)}
#shortcutsHelp kbd{background:color-mix(in oklab, var(--panel), black 10%); border:1px solid var(--border); border-radius:6px; padding:2px 6px; font-weight:700}


/* ===== Subtle page texture (fixed, no layout impact) ===== */
body::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(circle at 25% 20%, rgba(0,0,0,.015), transparent 60%),
    radial-gradient(circle at 80% 0%, rgba(0,0,0,.02), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(0,0,0,.015), transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.035'/></svg>");
  background-size: auto, auto, auto, 120px 120px;
  background-repeat: repeat;
}
:root[data-theme="dark"] body::before{
  background-image:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,.02), transparent 60%),
    radial-gradient(circle at 80% 0%, rgba(255,255,255,.025), transparent 55%),
    radial-gradient(circle at 0% 100%, rgba(255,255,255,.02), transparent 50%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.055'/></svg>");
}


/* ===== Themed Back-to-Top button (auto dark-mode, gentle fade) ===== */
#backToTop{
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  transition: opacity .25s ease, transform .20s ease, background-color .20s ease, border-color .20s ease, box-shadow .20s ease;
  opacity: 0;
  transform: translateY(6px);
}
body.loaded #backToTop{ opacity: 1; transform: translateY(0); }
#backToTop:hover{ border-color: var(--accent) !important; box-shadow: 0 8px 22px rgba(0,0,0,.14); transform: translateY(-1px); }
#backToTop:focus-visible{ outline: 3px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce){
  #backToTop{ transition: none; opacity: 1; transform: none; }
}


/* ===== Print-friendly handout styles ===== */
@media print{
  @page{ margin: 12mm; }
  body{ background: #ffffff !important; color: #000 !important; }
  body::before{ display: none !important; } /* remove texture */
  .header{ position: static !important; box-shadow: none !important; }
  .btn, button, #themeToggle, #backToTop{ display: none !important; }
  .viewer{ box-shadow: none !important; border: 1px solid #ccc !important; }
  *{ box-shadow: none !important; text-shadow: none !important; }
  a{ color: #000 !important; text-decoration: underline; }
  a[href^="http"]::after{ content: " (" attr(href) ")"; font-size: 10px; color: #444; }
  h1, h2, h3{ break-after: avoid; }
  p, ul, ol{ break-inside: avoid; }
}


/* ===== Dark mode focus readability tweaks ===== */
:root[data-theme="dark"] :where(button, input, select, textarea):focus-visible{
  /* softer, higher-contrast edge without glowing over text */
  outline: 2px solid color-mix(in oklab, var(--accent), var(--panel) 75%);
  outline-offset: 3px;
}
:root[data-theme="dark"] a:focus-visible{
  /* For inline links, switch to clear underline instead of a thick outline to keep text legible */
  outline: none;
  text-decoration: underline;
  text-decoration-thickness: 0.14em;
  text-underline-offset: 3px;
  box-shadow: none;
}
:root[data-theme="dark"] #backToTop:focus-visible{
  outline: 2px solid color-mix(in oklab, var(--accent), var(--panel) 85%);
  outline-offset: 2px;
}


/* ===== Dark mode: make Practice Tools box text green (accent) ===== */
:root[data-theme="dark"] .panel.sticky,
:root[data-theme="dark"] .panel.sticky h2,
:root[data-theme="dark"] .panel.sticky .tool-name,
:root[data-theme="dark"] .panel.sticky .small{
  color: var(--accent) !important;
}
