:root {
  color-scheme: light;
  --ink: #102436;
  --muted: #465d70;
  --paper: #f3f7fa;
  --white: #fff;
  --line: #d6e1e8;
  --brand: #076160;
  --brand-dark: #0b353e;
  --focus: #bf6b15;
  --width: min(72rem, calc(100% - 3rem));
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.65; overflow-wrap: anywhere; }
a { color: var(--brand); text-underline-offset: .25em; }
a:hover { color: #023b3c; }
button, input, select { font: inherit; }
:focus-visible { outline: .16rem solid var(--focus); outline-offset: .15rem; }
h1, h2, h3, p { margin: 0; }
main { min-height: 65vh; }
.wrap { width: var(--width); margin-inline: auto; }
.skip { position: fixed; z-index: 3; left: 1rem; top: -4rem; padding: .6rem 1rem; background: var(--white); }
.skip:focus { top: 1rem; }

.topbar { background: #fff; border-bottom: 1px solid #e1e9ed; }
.topbar-inner { min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.brand { color: var(--ink); display: inline-flex; gap: .75rem; align-items: center; font-weight: 800; line-height: 1.2; text-decoration: none; }
.brand-mark { background: #0a343e; color: #e3f9e8; display: grid; width: 2.55rem; height: 2.55rem; place-items: center; border-radius: .55rem; }
.brand small { display: block; margin-top: .22rem; color: var(--muted); font-weight: 600; font-size: .875rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.topbar nav a { text-decoration: none; font-weight: 700; font-size: .9rem; }
.topbar nav a:hover { text-decoration: underline; }

.hero { position: relative; isolation: isolate; overflow: hidden; background: linear-gradient(120deg, #0d263b, #0a424b); color: #f7fcff; }
.hero::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  inset: 0 0 0 42%; background: radial-gradient(ellipse at 75% 44%, #4ed1b033 0, #4ed1b000 60%),
  repeating-linear-gradient(138deg, transparent 0 2.85rem, #d0ffff18 2.85rem 2.91rem);
  mask-image: linear-gradient(90deg, transparent, #000 30%);
}
.hero-content { padding: 2.9rem 0 4.7rem; }
.hero-label, .eyebrow { font-weight: 700; color: var(--muted); font-size: .875rem; }
.hero-label { color: #b6f0dc; letter-spacing: .09em; margin-bottom: .8rem; }
.hero h1 { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: -.018em; font-size: clamp(2.45rem, 6vw, 4.4rem); line-height: 1.19; font-weight: 700; }
.hero-text { color: #e1eef3; margin: 1rem 0 1.5rem; }
.metrics { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem 1.4rem; }
.metrics > div { display: flex; align-items: baseline; gap: .5rem; border-right: 1px solid #ffffff43; padding-right: 1.4rem; }
.metrics > div:last-child { border-right: 0; }
.metrics strong { font-size: 1.85rem; line-height: 1.2; color: #c9f5e6; font-variant-numeric: tabular-nums; }
.metrics span { color: #edf9f8; font-size: .875rem; }

.workspace { position: relative; margin-top: -2.35rem; }
.search-panel { background: var(--white); border: 1px solid var(--line); padding: 1.35rem; border-radius: 1rem; box-shadow: 0 .5rem 1.6rem #142d3f0f; }
.search-row > label, .filters label { display: block; font-weight: 750; font-size: .875rem; }
.search-row > label { margin-bottom: .4rem; }
.search-input { display: flex; gap: .6rem; align-items: center; border: 1px solid #a7bdca; border-radius: .55rem; padding: .3rem; }
.search-input > span { margin-left: .52rem; color: var(--brand); font-size: 1.6rem; line-height: 1; }
.search-input input { width: 100%; min-width: 0; border: 0; padding: .45rem .15rem; background: transparent; color: var(--ink); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.55rem; border: 1px solid transparent; border-radius: .5rem; padding: .42rem .9rem; font-weight: 750; white-space: nowrap; cursor: pointer; text-decoration: none; font-size: .9rem; }
.button.primary { color: #fff; background: var(--brand); }
.button.primary:hover { color: #fff; background: #073f41; }
.button.outline, .button.subtle { color: var(--brand-dark); background: #fff; border-color: #aec4d0; }
.button.outline:hover, .button.subtle:hover { background: #edf6f5; }
.subject-tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1rem 0; }
.subject-tabs button { min-height: 2.3rem; padding: .25rem .85rem; border-radius: 8rem; border: 1px solid var(--line); background: #f7fafc; color: var(--ink); cursor: pointer; font-weight: 750; font-size: .9rem; }
.subject-tabs button[aria-pressed="true"] { color: #fff; background: var(--brand-dark); border-color: var(--brand-dark); }
.filters { display: grid; grid-template-columns: 1fr 1.1fr 1fr .7fr auto; align-items: end; gap: .75rem; }
.filter-help { margin-top: .7rem; color: var(--muted); font-size: .9rem; }
.filters select {
  width: 100%; padding: .43rem 2rem .43rem .55rem; min-height: 2.55rem; margin-top: .3rem;
  border: 1px solid #aec4d0; border-radius: .45rem; appearance: none; background-color: #fff; color: var(--ink);
  background-image: linear-gradient(45deg, transparent 50%, #496273 50%), linear-gradient(135deg, #496273 50%, transparent 50%);
  background-position: calc(100% - 1rem) 52%, calc(100% - .65rem) 52%; background-size: .35rem .35rem; background-repeat: no-repeat;
}

.results { padding: 1.6rem 0 2.6rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .65rem 1rem; margin: 0 0 .8rem; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
.section-head p, .section-head > span { color: var(--muted); font-size: .9rem; }
.text-link { font-size: .9rem; font-weight: 750; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.card { --subject: #255779; --tint: #e6f3fa; display: flex; flex-direction: column; position: relative; background: #fff; border: 1px solid var(--line); border-radius: .7rem; padding: 1rem; min-width: 0; }
.subject-japanese { --subject: #77513e; --tint: #f8ece3; }
.subject-math { --subject: #155a87; --tint: #e4f2fc; }
.subject-english { --subject: #5b4184; --tint: #f0eafa; }
.subject-science { --subject: #23603b; --tint: #e8f4e9; }
.subject-social { --subject: #82473a; --tint: #f9eee9; }
.card:hover { border-color: #85aab3; box-shadow: 0 .25rem 1rem #18384912; }
.card-head, .card-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-head { margin-bottom: .85rem; flex-wrap: wrap; }
.card-foot { color: var(--muted); margin-top: auto; padding-top: .95rem; font-size: .8125rem; }
.subject-label, .pill { display: inline-flex; border-radius: .3rem; padding: .12rem .5rem; font-weight: 750; font-size: .875rem; line-height: 1.55; }
.subject-label { color: var(--subject); background: var(--tint); }
.pill { color: #39505d; background: #edf2f5; }
.pill.download { color: #075448; background: #dff4e9; }
.pill.direct { color: #214e73; background: #e7f2fb; }
.pill.reference { color: #71430e; background: #fff3d9; }
.levels { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .48rem; }
.levels:empty { display: none; }
.level { display: inline-flex; font-size: .8125rem; font-weight: 750; padding: .12rem .45rem; border: 1px solid currentColor; border-radius: .3rem; line-height: 1.45; }
.level.basic { color: #1d6246; background: #edf7f0; }
.level.school { color: #1c5380; background: #edf5fb; }
.level.entrance { color: #774925; background: #fcf1e7; }
.card h3 { font-size: 1.2rem; line-height: 1.35; margin-top: .18rem; }
.card h3 a { text-decoration: none; color: var(--ink); }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: .7rem; }
.card h3 a:focus-visible::after { outline: .15rem solid var(--focus); outline-offset: .15rem; }
.card h3 a:hover { text-decoration: underline; }
.pagination { display: flex; align-items: center; justify-content: center; gap: .65rem; margin-top: 1.55rem; }
.pagination:empty { display: none; }
.pagination button:disabled { color: #526a7a; border-color: var(--line); cursor: default; }
.empty { background: #fff; padding: 1rem; border: 1px dashed #9eb7c6; border-radius: .55rem; color: var(--muted); }
.grid .empty { grid-column: 1 / -1; }

.detail { padding-bottom: 2.8rem; }
.crumbs { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: .35rem .8rem; padding: 0; list-style: none; }
.crumbs li + li::before { content: "/"; color: #618494; margin-right: .8rem; }
.detail-head { background: #fff; border: 1px solid var(--line); border-radius: .8rem; border-left: .33rem solid var(--subject, var(--brand)); padding: 1.5rem; margin: .8rem 0 1.4rem; }
.detail-head h1 { margin: .35rem 0; line-height: 1.28; font-size: clamp(1.75rem, 5vw, 2.65rem); }
.detail-head p { color: var(--muted); }
.detail-section { margin-top: 1.8rem; }
.detail-section .section-head { border-bottom: 1px solid var(--line); padding-bottom: .55rem; }
.detail-meta, .jump { display: flex; gap: .65rem 1.2rem; flex-wrap: wrap; margin-top: 1.5rem; }
.muted { color: var(--muted); margin: 0 0 .7rem; }
.materials { display: grid; gap: .75rem; padding: 0; list-style: none; }
.material { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .65rem; background: #fff; }
.material h3 { font-size: 1.04rem; margin-top: .35rem; }
.material p { color: var(--muted); font-size: .9rem; }
.material-actions { max-width: 27rem; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.material-actions details { flex-basis: 100%; text-align: right; }
.material-actions summary { cursor: pointer; color: var(--brand); font-weight: 700; padding: .18rem 0; }
.link-group { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; padding-bottom: .25rem; }
.theme-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem 1rem; padding: 0; list-style: none; }
.theme-list li { padding: .5rem .65rem; background: #fff; border-bottom: 1px solid var(--line); }
.theme-list a { display: block; font-weight: 750; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.reading { max-width: 54rem; }
.reading h2 { margin-top: 1.2rem; font-size: 1.3rem; }
.reading p, .reading li { margin-bottom: .4rem; }
.source-registry { padding-left: 1.4rem; }
.source-registry li { padding: .45rem 0; }
.source-registry li p { color: var(--muted); }
.source-area { margin: .65rem 0; padding: .65rem 1rem; border: 1px solid #dbe6ed; border-radius: .55rem; background: #fff; }
.source-area summary { cursor: pointer; font-weight: 700; }
.steps { padding-left: 1.6rem; }
blockquote { margin: .7rem 0; border-left: .2rem solid #6aa79c; background: #eaf5f1; padding: .7rem 1rem; }
footer { background: #e8f0f4; border-top: 1px solid var(--line); color: var(--muted); padding: 1.35rem 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem; font-size: .875rem; }

@media (max-width: 55rem) {
  .grid, .theme-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filters .subtle { justify-self: start; }
}

@media (max-width: 37rem) {
  :root { --width: calc(100% - 1.7rem); }
  .topbar-inner { min-height: 4.1rem; gap: .6rem; }
  .brand { gap: .38rem; font-size: .875rem; }
  .brand-mark { width: 1.9rem; height: 1.9rem; }
  .brand small { font-size: .75rem; }
  .topbar nav { gap: .45rem .65rem; justify-content: flex-end; }
  .topbar nav a { font-size: .8125rem; }
  .hero-content { padding-top: 2rem; padding-bottom: 3.85rem; }
  .hero h1 { font-size: clamp(2rem, 9vw, 3rem); }
  .metrics { gap: .65rem .7rem; }
  .metrics > div { padding-right: .65rem; gap: .25rem; }
  .metrics strong { font-size: 1.5rem; }
  .search-panel { padding: .8rem; }
  .search-input { gap: .25rem; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: .85rem; }
  .theme-list { grid-template-columns: repeat(2,minmax(0,1fr)); font-size: .9rem; }
  .material { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .material-actions { justify-content: flex-start; }
  .material-actions details { text-align: left; }
  .link-group { justify-content: flex-start; }
}
.question-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
