/* ClassroomSearch - Material Design (M2) inspired styles. No external fonts or frameworks. */

/* ---------- Tokens ---------- */
:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --on-primary: #ffffff;
  --primary-tint: rgba(21, 101, 192, 0.10);
  --secondary: #00796b;
  --secondary-tint: rgba(0, 121, 107, 0.10);
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-variant: #f1f3f4;
  --text: rgba(0, 0, 0, 0.87);
  --text-medium: rgba(0, 0, 0, 0.62);
  --text-low: rgba(0, 0, 0, 0.56);   /* 4.9:1 on white, 4.8:1 on --surface-variant (WCAG 1.4.3) */
  --divider: rgba(0, 0, 0, 0.12);
  --outline: rgba(0, 0, 0, 0.44);    /* 3.2:1: borders of inputs and controls (WCAG 1.4.11) */
  --link: #1a4fb0;
  --link-visited: #6a2bb0;
  --state: #000000;
  --support-bg: #fff8e1;
  --support-border: #ffcc80;
  --scrim: rgba(0, 0, 0, 0.40);

  --e1: 0 2px 1px -1px rgba(0,0,0,.20), 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 3px 0 rgba(0,0,0,.12);
  --e2: 0 3px 1px -2px rgba(0,0,0,.20), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
  --e4: 0 2px 4px -1px rgba(0,0,0,.20), 0 4px 5px 0 rgba(0,0,0,.14), 0 1px 10px 0 rgba(0,0,0,.12);
  --e8: 0 5px 5px -3px rgba(0,0,0,.20), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12);
  --e24: 0 11px 15px -7px rgba(0,0,0,.20), 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12);

  --font: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --radius: 4px;
  --gutter: 16px;
  --rail: 0px;
  --content-w: 680px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
img { max-width: 100%; }
h1, h2, h3 { font-weight: 400; }
code { font-size: 0.92em; background: var(--surface-variant); padding: 1px 4px; border-radius: 3px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--primary); color: var(--on-primary); padding: 8px 16px; border-radius: var(--radius);
  text-decoration: none; transition: top .15s var(--ease);
}
.skip-link:focus { top: 8px; }

.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }
.icon--sm { width: 18px; height: 18px; }

.overline {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-medium);
}

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand__mark { width: 36px; height: 36px; flex: none; }
.brand__mark--lg { width: 104px; height: 104px; overflow: visible; }
/* Pip pops up out of the book on the home page, blinks now and then, and wiggles its tassel on hover. */
.brand__mark--lg .pip { animation: pip-peek .9s var(--ease) .15s both; }
/* Pip blinks twice, then stops: all motion ends within 5 seconds of load (WCAG 2.2.2). */
.brand__mark--lg .pip__eyes { transform-box: fill-box; transform-origin: center; animation: pip-blink 1.2s 1.6s 2; }
.brand__mark--lg .pip__tassel { transform-box: view-box; transform-origin: 40.5px 10.5px; }
.home__brand:hover .pip__tassel { animation: pip-tassel .8s ease-in-out; }
@keyframes pip-peek { 0% { transform: translateY(16px); opacity: 0; } 55% { transform: translateY(-3px); opacity: 1; } 75% { transform: translateY(1px); } 100% { transform: none; } }
@keyframes pip-blink { 0%, 75%, 100% { transform: scaleY(1); } 87.5% { transform: scaleY(.1); } }
@keyframes pip-tassel { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(18deg); } 60% { transform: rotate(-12deg); } }
.brand__name { font-size: 20px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- State layer + ripple (M2 interaction states) ---------- */
.btn, .icon-btn, .chip, .tab, .segmented__btn, .pager__num { position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.btn::before, .icon-btn::before, .chip::before, .tab::before, .segmented__btn::before, .pager__num::before {
  content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0; transition: opacity .15s var(--ease); pointer-events: none;
}
.btn:hover::before, .icon-btn:hover::before, .chip:hover::before, .tab:hover::before, .segmented__btn:hover::before, .pager__num:hover::before { opacity: .06; }
.btn:focus-visible::before, .icon-btn:focus-visible::before, .chip:focus-visible::before, .tab:focus-visible::before { opacity: .12; }
.ripple {
  position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0);
  animation: ripple .45s var(--ease) forwards; pointer-events: none;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 64px; height: 36px; padding: 0 16px;
  border: 0; border-radius: var(--radius); background: transparent;
  font: 500 14px/1 var(--font); letter-spacing: 0.0892em; text-transform: uppercase; text-decoration: none;
  color: var(--primary); cursor: pointer; white-space: nowrap;
  transition: box-shadow .2s var(--ease), background-color .2s var(--ease);
}
.btn--contained { background: var(--primary); color: var(--on-primary); box-shadow: var(--e2); padding: 0 20px; }
.btn--contained:hover { box-shadow: var(--e4); }
.btn--contained:active { box-shadow: var(--e8); }
.btn--outlined { border: 1px solid var(--outline); padding: 0 15px; }
.btn--text { padding: 0 8px; }
.btn__icon { width: 18px; height: 18px; margin-left: -4px; }
.btn__icon--end { margin-left: 0; margin-right: -4px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-medium); cursor: pointer;
}
.icon-btn[hidden] { display: none; }

/* ---------- Search box ---------- */
.searchbox {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  height: 48px; padding: 0 4px 0 14px;
  background: var(--surface-raised);
  border: 1px solid var(--outline); border-radius: 24px;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.searchbox:hover { box-shadow: var(--e1); }
.searchbox:focus-within { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary), var(--e2); }
.searchbox__lead { display: inline-flex; color: var(--text-low); }
.searchbox--bar .searchbox__lead { display: none; }
.searchbox__input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; color: var(--text);
  font: 400 16px/1.25 var(--font); padding: 0 6px;
}
.searchbox__input::placeholder { color: var(--text-low); }
.searchbox__input::-webkit-search-cancel-button { display: none; }
.searchbox__submit { color: var(--primary); }
.searchbox--home { height: 56px; border-radius: 28px; padding-left: 18px; box-shadow: var(--e1); }
.searchbox--home:hover { box-shadow: var(--e4); }

/* ---------- App bar ---------- */
.appbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "brand" "search" "tabs";
  row-gap: 8px;
  padding: 12px var(--gutter) 0;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--divider);
  z-index: 20;
}
.appbar > .brand { grid-area: brand; }
.appbar > .searchbox { grid-area: search; }
.appbar > .tabs { grid-area: tabs; }
.layout-bar .appbar:not(:has(.tabs)) { padding-bottom: 12px; }
.appbar.is-raised { box-shadow: var(--e4); border-bottom-color: transparent; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0; margin: 0 calc(var(--gutter) * -1); padding: 0 calc(var(--gutter) - 4px); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 48px; padding: 0 16px; min-width: 90px; justify-content: center;
  font: 500 14px/1 var(--font); letter-spacing: 0.0892em; text-transform: uppercase;
  color: var(--text-medium); text-decoration: none;
}
.tab__icon { width: 20px; height: 20px; }
/* Inset focus ring: .tabs scrolls sideways, which would clip an outline drawn outside the tab. */
.tab:focus-visible { outline-offset: -2px; }
.tab.is-active { color: var(--primary); }
.tab.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--primary);
}

/* ---------- Page layout ---------- */
.page {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 40px;
  align-items: start;
  width: 100%;
  padding: 16px var(--gutter) 32px;
}
.content { min-width: 0; max-width: var(--content-w); }
.page--images .content { max-width: none; }
.sidebar { display: none; }
.sidebar__sticky { position: sticky; top: 132px; }

/* ---------- Web results ---------- */
.results { list-style: none; margin: 0; padding: 0; }
.result { padding: 10px 0 18px; }
.result__source { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; min-width: 0; }
.result__favicon {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--surface-variant); display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
}
.result__favicon img { width: 18px; height: 18px; }
.result__origin { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.result__name, .result__line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.result__line { gap: 0; }
.result__site, .result__url { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result__site { font-size: 14px; color: var(--text); }
.result__url { font-size: 12px; color: var(--text-medium); }
.result__main { display: flex; gap: 16px; align-items: flex-start; }
.result__text { flex: 1; min-width: 0; }
.result__title { margin: 0 0 4px; font-size: 20px; line-height: 1.3; font-weight: 400; overflow-wrap: anywhere; }
.result__title a { color: var(--link); text-decoration: none; }
.result__title a:hover { text-decoration: underline; }
.result__title a:visited { color: var(--link-visited); }
.result__snippet { margin: 0; color: var(--text-medium); line-height: 1.58; overflow-wrap: anywhere; }
.result__snippet strong { color: var(--text); font-weight: 500; }
.result__age { color: var(--text-low); }
/* Cite sits at the end of the URL line, after a middle dot. The dot is part of the button so it
   only shows once JS un-hides the button. Padding + negative margin give a bigger tap target. */
.result__cite {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  margin: -6px -6px -6px 0; padding: 6px; border: 0; border-radius: var(--radius); background: none;
  font: 500 12px/1.3 var(--font); color: var(--link); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.result__cite::before { content: "\00B7"; display: inline-block; margin-right: 6px; color: var(--text-low); font-weight: 400; }
.result__cite[hidden] { display: none; }
.result__cite-icon { width: 14px; height: 14px; }
.result__cite:hover .result__cite-label { text-decoration: underline; }
.result__cite:focus-visible { outline-offset: -2px; }
.result__thumb { width: 92px; height: 92px; flex: none; object-fit: cover; border-radius: 8px; background: var(--surface-variant); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none; margin-left: auto;
  height: 24px; padding: 0 10px 0 6px; border-radius: 12px;
  background: var(--secondary-tint); color: var(--secondary);
  font-size: 12px; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap;
}
.badge__icon { width: 16px; height: 16px; }
.badge--sm { height: 20px; padding: 0 8px 0 4px; border-radius: 10px; font-size: 11px; margin-left: 0; }
.badge--sm .badge__icon { width: 14px; height: 14px; }

.notice { margin: 4px 0 12px; color: var(--text-medium); }
.notice a { color: var(--link); }
.filtered-note { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--text-medium); }

/* ---------- Ads ---------- */
.ad { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; max-width: 100%; overflow: hidden; }
.ad__label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-low); margin-bottom: 4px; }
.ad__size { font-size: 13px; color: var(--text-low); }
.ad--placeholder { border: 1px dashed var(--outline); border-radius: var(--radius); background: var(--surface-variant); }
.ad--skyscraper.ad--w160 { width: 160px; min-height: 600px; }
.ad--skyscraper.ad--w300 { width: 300px; min-height: 600px; }
.ad--banner { width: 100%; min-height: 100px; }
.ad--banner.ad--placeholder { max-width: 728px; min-height: 90px; }
.ad-row { list-style: none; margin: 8px 0 20px; padding: 12px 0; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); display: flex; justify-content: center; }
.ad-row--grid { flex: 1 0 100%; margin: 4px 0; }

/* ---------- Image grid (justified rows) ---------- */
.imggrid { --row-h: 120px; display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.imggrid::after { content: ""; flex-grow: 1000000; }
.imgcell {
  display: flex; min-width: 0;
  width: calc(var(--ar) * var(--row-h));
  flex-grow: calc(var(--ar) * 100);
  max-width: 100%;
}
.imgcard {
  display: flex; flex-direction: column; min-width: 0; width: 100%;
  color: inherit; text-decoration: none; border-radius: var(--radius);
}
.imgcard__frame {
  position: relative; display: block; width: 100%; padding-bottom: calc(100% / var(--ar));
  background: var(--surface-variant); border-radius: var(--radius); overflow: hidden;
  transition: box-shadow .2s var(--ease);
}
.imgcard__frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.imgcard:hover .imgcard__frame, .imgcard:focus-visible .imgcard__frame { box-shadow: var(--e4); }
.imgcard:focus-visible { outline-offset: 3px; }
.imgcard__meta { display: grid; padding: 4px 2px 2px; line-height: 1.35; }
.imgcard__title, .imgcard__host { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.imgcard__title { color: var(--text); }
.imgcard__host { color: var(--text-medium); }
.is-broken { display: none !important; }

/* ---------- Dialog ---------- */
.dialog {
  width: calc(100% - 32px); max-width: 600px; max-height: calc(100% - 32px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface-raised); color: var(--text); box-shadow: var(--e24);
}
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in .15s var(--ease); }
.dialog::backdrop { background: var(--scrim); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.dialog__media { display: flex; align-items: center; justify-content: center; background: var(--surface-variant); min-height: 160px; max-height: 48vh; flex: none; }
.dialog__media img { max-width: 100%; max-height: 48vh; object-fit: contain; display: block; }
.dialog__body { padding: 20px 24px 4px; overflow-y: auto; }
.dialog__title { margin: 0 0 4px; font-size: 20px; font-weight: 500; line-height: 1.35; letter-spacing: 0.0075em; overflow-wrap: anywhere; }
.dialog__meta { margin: 0 0 16px; color: var(--text-medium); }
.dialog__dot { margin: 0 6px; }
.cite { background: var(--surface-variant); border-radius: var(--radius); padding: 12px 14px; }
.cite__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cite__head .overline { margin: 0; }
.cite__styles { background: var(--surface-raised); }
.cite__text { margin: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; user-select: all; padding-left: 2em; text-indent: -2em; }
.dialog--cite { max-width: 560px; }
.dialog__hint { margin: 12px 0 8px; font-size: 12px; color: var(--text-medium); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 8px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border-radius: 16px; background: var(--surface-variant); color: var(--text);
  font-size: 14px; text-decoration: none; white-space: nowrap;
}
.chip--outlined { background: transparent; border: 1px solid var(--outline); padding: 0 13px 0 9px; }
.chip__icon { width: 18px; height: 18px; color: var(--text-medium); }

/* ---------- Segmented (M2 toggle button group) ---------- */
.segmented { display: inline-flex; margin: 0; padding: 0; border: 1px solid var(--outline); border-radius: var(--radius); overflow: hidden; }
.segmented__input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; cursor: pointer;
  font: 500 14px/1 var(--font); letter-spacing: 0.0892em; text-transform: uppercase; color: var(--text-medium);
}
.segmented__btn + .segmented__input + .segmented__btn { border-left: 1px solid var(--outline); }
.segmented__icon { width: 18px; height: 18px; }
.segmented--sm .segmented__btn { height: 30px; padding: 0 12px; font-size: 13px; }
/* Selected option is filled, not just tinted, so it doesn't rely on a subtle color change (WCAG 1.4.1, 1.4.11). */
.segmented__input:checked + .segmented__btn { background: var(--primary); color: var(--on-primary); }
/* Blue ring with a white ring inside it: visible on both the filled and the plain options. */
.segmented__input:focus-visible + .segmented__btn { outline: 2px solid var(--primary); outline-offset: -2px; box-shadow: inset 0 0 0 4px var(--on-primary); }

/* ---------- Home ---------- */
.home {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 680px; margin: 0 auto; padding: 10vh var(--gutter) 48px;
}
.home__brand { text-align: center; margin-bottom: 28px; }
.home__title { margin: 12px 0 4px; font-size: 34px; line-height: 1.2; letter-spacing: 0.0073em; }
.home__tagline { margin: 0; font-size: 16px; color: var(--text-medium); letter-spacing: 0.009em; }
.home__form { width: 100%; }
.home__actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px; margin-top: 24px; }
.home__topics { margin-top: 44px; text-align: center; width: 100%; }
.home__topics .chips { justify-content: center; }
.home__privacy { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 40px 0 0; color: var(--text-medium); font-size: 13px; text-align: center; }

/* ---------- Cards / messages ---------- */
.card { background: var(--surface-raised); border: 1px solid var(--divider); border-radius: var(--radius); }
.message { padding: 32px 24px 16px; margin-top: 16px; }
.message__icon {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--primary-tint); color: var(--primary); margin-bottom: 16px;
}
.message__icon .icon { width: 28px; height: 28px; }
.message__title { margin: 0 0 8px; font-size: 24px; line-height: 1.3; }
.message__text { margin: 0 0 20px; font-size: 16px; color: var(--text-medium); line-height: 1.55; }
.message__suggest { margin: 4px 0 20px; }
.message__actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin: 8px -8px 0; padding-top: 8px; border-top: 1px solid var(--divider); }
.support { background: var(--support-bg); border: 1px solid var(--support-border); border-radius: var(--radius); padding: 16px; margin: 0 0 20px; }
.support p { margin: 0 0 10px; line-height: 1.55; }
.support__head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 16px; }
.support__icon { color: #c62828; }

/* ---------- Browser check ---------- */
.checking { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 0; color: var(--text-medium); }
.checking p { margin: 0; }

/* ---------- Loader: spinning ring with Pip popping out of his book (View::loader) ---------- */
.loader { position: relative; display: block; width: 112px; height: 112px; flex: none; }
.loader__ring { position: absolute; inset: 0; width: 100%; height: 100%; animation: loader-turn 1.6s linear infinite; }
.loader__track, .loader__arc { fill: none; stroke-width: 5; }
.loader__track { stroke: var(--primary-tint); }
.loader__arc {
  stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 190 289;
  transform-origin: 50px 50px; transform: rotate(-90deg);
  animation: loader-arc 1.4s ease-in-out infinite;
}
.loader__mark { position: absolute; left: 20px; top: 16px; width: 72px; height: 72px; overflow: visible; }
.loader__mark .pip { animation: loader-pop 2.6s var(--ease) infinite; }
.loader__mark .pip__eyes { animation: loader-look 2.6s ease-in-out infinite; }
.loader__mark .pip__tassel { transform-box: view-box; transform-origin: 40.5px 10.5px; animation: loader-tassel 2.6s ease-in-out infinite; }
@keyframes loader-turn { to { transform: rotate(360deg); } }
@keyframes loader-arc {
  0% { stroke-dasharray: 1 289; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 190 289; stroke-dashoffset: -40; }
  100% { stroke-dasharray: 190 289; stroke-dashoffset: -288; }
}
/* Down in the book, pop up, look left and right, then duck back in. */
@keyframes loader-pop {
  0%, 8% { transform: translateY(46px); }
  24% { transform: translateY(-4px); }
  30% { transform: translateY(1px); }
  34%, 76% { transform: none; }
  92%, 100% { transform: translateY(46px); }
}
@keyframes loader-look {
  0%, 38% { transform: none; }
  44%, 54% { transform: translateX(-1.6px); }
  60%, 70% { transform: translateX(1.6px); }
  76%, 100% { transform: none; }
}
@keyframes loader-tassel {
  0%, 22% { transform: rotate(0); }
  28% { transform: rotate(22deg); }
  36% { transform: rotate(-14deg); }
  44%, 100% { transform: rotate(0); }
}

/* ---------- Searching indicator (see app.js) ---------- */
/* Hidden with display:none rather than paused animations: Safari (macOS and iOS)
   doesn't reliably resume a paused animation, so the loader's animations start
   fresh each time the overlay appears. */
.search-progress {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  display: none; align-items: center; justify-content: center; padding: var(--gutter);
}
.search-progress__card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 24px 32px 20px; border-radius: 24px; background: var(--surface-raised); box-shadow: var(--e8);
}
.search-progress__label { font-size: 16px; font-weight: 500; color: var(--text-medium); }
/* Short delay so a fast search doesn't flash the overlay. */
.is-searching .search-progress { display: flex; animation: search-progress-in .2s var(--ease) .15s both; }
.is-searching .search-progress__card { animation: search-progress-card .25s var(--ease) .15s both; }
@keyframes search-progress-in { from { opacity: 0; } }
@keyframes search-progress-card { from { transform: scale(.85); } }
.is-searching .content, .is-searching .home__topics { opacity: .55; transition: opacity .2s var(--ease) .15s; }

/* ---------- Empty / pager ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--text-medium); }
.empty__icon { width: 48px; height: 48px; color: var(--text-low); }
.empty__title { margin: 8px 0; font-size: 20px; color: var(--text); }
.empty__text { margin: 0 auto; max-width: 420px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 28px 0 8px; max-width: var(--content-w); }
.page--images .pager { max-width: none; }
.pager__spacer { width: 1px; }
.pager__label { color: var(--text-medium); }
.pager__pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.pager__num {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.pager__num.is-current { background: var(--primary); color: var(--on-primary); }

/* ---------- Prose (about, blog, privacy and terms pages) ---------- */
.prose { max-width: 720px; line-height: 1.65; font-size: 15px; }
.prose h1 { font-size: 30px; line-height: 1.25; margin: 16px 0 12px; }
.prose h2 { font-size: 20px; font-weight: 500; margin: 32px 0 8px; }
.prose .lead { font-size: 17px; color: var(--text-medium); }
.prose li { margin-bottom: 10px; }
.prose .updated { margin-top: 0; font-size: 13px; color: var(--text-medium); }
.prose .muted { color: var(--text-medium); }
/* Boxed sections: "The short version", "Our promise to you", donations */
.prose .summary { margin: 24px 0; padding: 4px 20px 8px; background: var(--surface-variant); border-color: transparent; }
.prose .summary h2 { margin-top: 16px; }
.prose .summary ul { padding-left: 20px; }
.prose h3 { font-size: 16px; font-weight: 500; margin: 24px 0 4px; }
.prose ol { padding-left: 24px; }
.prose pre.codebox { font-size: 13px; line-height: 1.5; user-select: text; }
.prose pre.codebox code { background: none; padding: 0; }
.prose .table-wrap { margin: 8px 0 16px; border: 1px solid var(--divider); border-radius: var(--radius); }
.prose .table { font-size: 14px; }
.prose .table th, .prose .table td { padding: 8px 12px; vertical-align: top; }
.prose .table tbody tr:last-child > * { border-bottom: 0; }
.prose .table tbody tr:hover { background: none; }
.prose .table th[scope="row"] { font-size: 14px; color: var(--text); }
.prose .table code { overflow-wrap: anywhere; }
.about__signoff { margin-top: 32px; font-style: italic; color: var(--text-medium); }

/* ---------- Blog ---------- */
.blog-post + .blog-post { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--divider); }
.blog-post__title { margin-bottom: 0; }
.blog-post__title a { color: var(--text); text-decoration: none; }
.blog-post__title a:hover, .blog-post__title a:focus-visible { color: var(--link); text-decoration: underline; }
.prose .blog-post__date { margin: 4px 0 12px; font-size: 13px; color: var(--text-medium); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--divider); background: var(--surface-variant); color: var(--text-medium); font-size: 13px; }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 14px var(--gutter); }
.footer__links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer a { color: var(--text-medium); text-decoration: none; }
.footer a:hover { color: var(--text); text-decoration: underline; }
/* Above the network footer: the same dark band, so the page has one footer.
   Colors match the --nf-* defaults in network-footer.css. */
.footer--joined { padding: 0 16px; border-top: 0; background: #263238; color: rgba(255, 255, 255, 0.78); font-size: 14px; }
.footer--joined .footer__inner,
.layout-bar .footer--joined .footer__inner {
  justify-content: center; max-width: 1040px; margin: 0 auto;
  padding: 24px 0 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.24);
}
.footer--joined .footer__links { justify-content: center; gap: 8px 28px; }
.footer--joined a { color: #ffffff; }
.footer--joined a:hover { color: #ffd54f; }
.footer--joined a:focus-visible { outline: 3px solid #ffd54f; outline-offset: 2px; border-radius: 2px; }
.footer--joined + .network-footer { padding-top: 28px; }

/* ---------- Tablet and up (600px+) ---------- */
@media (min-width: 600px) {
  :root { --gutter: 24px; --rail: 40px; }
  .appbar {
    grid-template-columns: var(--rail) minmax(0, 1fr);
    grid-template-areas: "brand search" ". tabs";
    column-gap: 16px; row-gap: 4px;
    padding-top: 14px;
  }
  .appbar > .brand .brand__name { display: none; }
  .appbar > .searchbox { max-width: 690px; }
  .tabs { margin: 0; padding: 0; }
  .layout-bar .page, .layout-bar .footer__inner { padding-left: calc(var(--gutter) + var(--rail) + 16px); }
  .imggrid { --row-h: 160px; gap: 10px; }
  .message { padding: 36px 32px 16px; }
}

/* ---------- Sidebar ads (1024px+) ---------- */
@media (min-width: 1024px) {
  .page--sidebar { grid-template-columns: minmax(0, var(--content-w)) auto; }
  .page--sidebar.page--images { grid-template-columns: minmax(0, 1fr) auto; }
  .sidebar { display: block; }
  .appbar { position: sticky; top: 0; }
  .imggrid { --row-h: 150px; }
}
@media (min-width: 1440px) {
  .imggrid { --row-h: 180px; }
}

/* ---------- Wide (1180px+): show the name in the app bar ---------- */
@media (min-width: 1180px) {
  /* Wide enough for the mark + "ClassroomSearch.com" at 18px in any system font. */
  :root { --rail: 248px; }
  /* Never clip the name: the column grows if a font or custom site name needs more room. */
  .appbar { grid-template-columns: minmax(var(--rail), max-content) minmax(0, 1fr); }
  .appbar > .brand .brand__name { display: inline; font-size: 18px; overflow: visible; text-overflow: clip; }
}

/* Small phones */
@media (max-width: 380px) {
  .result__thumb { width: 64px; height: 64px; }
  /* Shield only; the label stays for screen readers. */
  .badge--sm { padding: 0 3px; }
  .badge--sm .badge__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .home__title { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* Without motion the ring shows a still arc and Pip sits up out of his book. */
}

/* Windows High Contrast and other forced-color modes drop background colors, so mark
   selected options with the system highlight colors instead. */
@media (forced-colors: active) {
  .segmented__input:checked + .segmented__btn, .chip--selected, .pager__num.is-current {
    forced-color-adjust: none; background: Highlight; color: HighlightText;
  }
  .tab.is-active::after { background: Highlight; }
}

@media print {
  .appbar, .sidebar, .ad-row, .footer, .pager { display: none !important; }
}

/* ---------- Admin (stats.php) ---------- */
.appbar--simple { display: flex; align-items: center; gap: 16px; padding: 12px var(--gutter); }
.appbar--simple .brand__name { display: inline !important; font-size: 18px; }
.appbar__title { font-size: 18px; font-weight: 500; color: var(--text-medium); padding-left: 16px; border-left: 1px solid var(--divider); }
.layout-admin .page { padding-left: var(--gutter) !important; }
.layout-admin .footer__inner { padding-left: var(--gutter) !important; }
.content--wide { max-width: 1200px; width: 100%; }
.admin__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--divider); margin-bottom: 20px; }
.tabs--admin { margin: 0; padding: 0; }
.admin__meta { color: var(--text-medium); font-size: 13px; margin: 12px 0; }
.panel { padding: 20px 24px; margin-bottom: 20px; }
.panel--narrow { max-width: 420px; margin: 40px auto; }
.panel__title { margin: 0 0 12px; font-size: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat__label { font-size: 12px; color: var(--text-medium); letter-spacing: 0.03em; }
.stat__value { font-size: 28px; line-height: 1.1; }
.stat__value small { font-size: 14px; color: var(--text-low); }
.table-card { margin-bottom: 16px; overflow: hidden; }
.table-card__title { margin: 0; padding: 16px 16px 8px; font-size: 18px; font-weight: 500; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-medium); padding: 12px 16px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table tbody tr:hover { background: var(--primary-tint); }
.table tr.is-selected { background: var(--secondary-tint); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table__query { overflow-wrap: anywhere; min-width: 180px; }
.table__empty { text-align: center; color: var(--text-medium); padding: 24px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chip--selected { background: var(--primary); color: var(--on-primary); font-weight: 500; }
.chips--summary { margin-bottom: 12px; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 12px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.field--grow { flex: 1; }
.field__label { font-size: 12px; color: var(--text-medium); }
.field__input {
  height: 40px; padding: 0 12px; border: 1px solid var(--outline); border-radius: var(--radius);
  background: var(--surface-raised); color: var(--text); font: 400 15px var(--font);
}
.field__input:focus { outline: 0; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.form-error { color: #c62828; font-weight: 500; }
.codebox { background: var(--surface-variant); padding: 12px; border-radius: var(--radius); overflow-x: auto; user-select: all; }
.checklist { padding-left: 20px; }
.debug-call { border-top: 1px solid var(--divider); padding: 12px 0; }
.debug-call summary { cursor: pointer; font-size: 14px; overflow-wrap: anywhere; }
.debug-call__h { font-size: 13px; font-weight: 500; color: var(--text-medium); margin: 16px 0 6px; }
.debug-call__pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow-y: auto; font-size: 12px; user-select: text; margin: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; min-height: 40px; font-size: 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.btn--danger { background: #c62828; color: #fff; }
.flash { padding: 12px 16px; border-radius: var(--radius); border: 1px solid; margin: 0 0 16px; }
.flash--ok { border-color: #66bb6a; background: #e8f5e9; color: #1b5e20; }
.flash--error { border-color: #ef5350; background: #ffebee; color: #b71c1c; }
.table__actions { white-space: nowrap; text-align: right; }
.table__actions form { display: inline; }
.ok { color: #2e7d32; font-weight: 500; }
.bad { color: #c62828; font-weight: 500; }
.verdict { margin-top: 20px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--divider); }
.verdict p { margin: 4px 0; }
.verdict__status { font-size: 20px; }
.verdict--allow { border-color: #66bb6a; }
.verdict--block { border-color: #ef5350; }
.verdict--unavailable { border-color: #ffa726; }
