:root {
  color-scheme: light;
  --ink: #25292c;
  --muted: #69747b;
  --canvas: #f5f7f8;
  --surface: #ffffff;
  --line: #d9dee1;
  --line-strong: #c3cbd0;
  --wedo-blue: #08a9e0;
  --wedo-blue-dark: #007aa7;
  --wedo-blue-soft: #e5f7fd;
  --green: #20765d;
  --green-soft: #e1f0ea;
  --yellow: #ffd84d;
  --shadow: 0 18px 48px rgb(37 41 44 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--wedo-blue-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.library-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(470px, 1fr) auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line-strong);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 2px 12px rgb(37 41 44 / 7%);
  backdrop-filter: blur(14px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1.2rem;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--wedo-blue);
  color: white;
  font-size: 1.4rem;
  font-weight: 900;
}

.product-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.15;
}

.content-nav {
  display: flex;
  min-width: 0;
  align-items: stretch;
}

.content-nav-button {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.1rem 0.6rem;
  min-width: 150px;
  align-content: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  padding: 0.65rem 1rem;
  color: var(--muted);
  text-align: left;
}

.content-nav-button:last-child {
  border-right: 1px solid var(--line);
}

.content-nav-button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 4px;
  background: transparent;
  content: "";
}

.content-nav-button:hover {
  background: var(--canvas);
  color: var(--ink);
}

.content-nav-button.is-active {
  background: var(--surface);
  color: var(--wedo-blue-dark);
}

.content-nav-button.is-active::after {
  background: var(--wedo-blue);
}

.nav-symbol {
  grid-row: 1 / 3;
  align-self: center;
  color: currentColor;
  font-size: 1.6rem;
  line-height: 1;
}

.content-nav-button > span:not(.nav-symbol) {
  align-self: end;
  color: currentColor;
  font-size: 0.86rem;
  font-weight: 800;
}

.content-nav-button small {
  align-self: start;
  color: var(--muted);
  font-size: 0.68rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1rem;
}

.header-actions button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  color: var(--ink);
  font-size: 0.75rem;
  white-space: nowrap;
}

.header-actions button:hover {
  border-color: var(--wedo-blue);
  color: var(--wedo-blue-dark);
}

main {
  width: min(1840px, 100%);
  margin: 0 auto;
  padding: 2.2rem clamp(1.2rem, 2.4vw, 3.2rem) 6rem;
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 620px);
  align-items: end;
  gap: 1rem 3rem;
  margin-bottom: 1.7rem;
}

.page-heading .eyebrow {
  grid-column: 1;
  margin-bottom: -0.55rem;
}

.page-heading h1 {
  grid-column: 1;
  margin-bottom: 0;
  font-size: clamp(2.1rem, 3.5vw, 3.6rem);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.page-heading > p:last-child {
  grid-column: 2;
  grid-row: 1 / 3;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.75;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgb(245 247 248 / 92%);
  padding: 0.8rem 0;
  backdrop-filter: blur(14px);
}

.toolbar label {
  display: grid;
  width: min(520px, 100%);
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.toolbar input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.6rem 0.8rem;
  color: var(--ink);
}

.toolbar input:focus {
  border-color: var(--wedo-blue);
  outline: 3px solid rgb(8 169 224 / 18%);
}

.result-count {
  margin: 0;
  padding: 0.65rem 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.notice {
  margin: 1rem 0;
  border: 1px solid #b96f61;
  border-radius: 10px;
  background: #fff0ec;
  padding: 1rem;
}

.library-section {
  padding: 2rem 0 2.6rem;
  border-bottom: 1px solid var(--line);
}

.library-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.45rem, 2vw, 2.15rem);
  font-weight: 450;
  letter-spacing: -0.025em;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.section-count {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.8rem, 1.4vw, 1.5rem);
}

.project-card {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0;
  color: inherit;
  text-align: left;
  box-shadow: 0 2px 8px rgb(37 41 44 / 4%);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.project-card:hover {
  z-index: 1;
  transform: translateY(-3px);
  border-color: var(--wedo-blue);
  box-shadow: var(--shadow);
}

.project-card:focus-visible {
  border-color: var(--wedo-blue);
  outline: 4px solid rgb(8 169 224 / 22%);
  outline-offset: 2px;
}

.thumbnail-wrap {
  display: grid;
  width: 100%;
  height: 100%;
  overflow: hidden;
  place-items: center;
  background: #eef2f3;
}

.thumbnail-wrap.empty::after {
  content: "WeDo";
  color: rgb(0 122 167 / 35%);
  font-size: 2rem;
  font-weight: 900;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 250ms ease;
}

.project-card:hover .thumbnail {
  transform: scale(1.025);
}

.project-card--introduction .thumbnail,
.project-card--model .thumbnail,
.project-card--program .thumbnail {
  object-fit: contain;
  padding: 0.9rem;
}

.project-card--model .thumbnail-wrap {
  background: #fafbfb;
}

.project-card--program .thumbnail-wrap {
  background: var(--wedo-blue-soft);
}

.card-title {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  min-height: 64px;
  background: rgb(255 255 255 / 78%);
  padding: 1rem 1.15rem;
  color: #202427;
  font-size: clamp(0.88rem, 1.1vw, 1.08rem);
  font-weight: 500;
  line-height: 1.4;
  backdrop-filter: blur(7px);
}

.empty-results {
  margin: 3rem 0;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

dialog {
  width: min(1400px, calc(100vw - 2rem));
  max-width: none;
  height: min(92vh, 1000px);
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 18px;
  background: var(--canvas);
  padding: 0;
  color: var(--ink);
  box-shadow: 0 30px 100px rgb(0 0 0 / 28%);
}

dialog::backdrop {
  background: rgb(19 28 32 / 70%);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem 1.4rem;
}

.dialog-header h2 {
  margin: 0;
}

.close-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.42fr);
  height: calc(100% - 92px);
}

.dialog-layout > article,
.research-panel {
  overflow: auto;
  padding: 1.5rem;
}

.project-overview {
  margin-bottom: 2rem;
  border-left: 5px solid var(--yellow);
  background: var(--surface);
  padding: 1.25rem;
  line-height: 1.8;
}

.project-overview:empty {
  display: none;
}

.pages {
  display: grid;
  gap: 1rem;
}

.source-page {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
}

.page-label {
  color: var(--wedo-blue-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.source-text {
  line-height: 1.85;
}

.source-page > img,
.source-page > video {
  display: block;
  max-width: 100%;
  max-height: 580px;
  margin: 0.8rem auto;
  border-radius: 8px;
}

.slideshow {
  display: grid;
  grid-auto-columns: minmax(240px, 70%);
  grid-auto-flow: column;
  gap: 0.7rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.slideshow figure {
  margin: 0;
  scroll-snap-align: start;
}

.slideshow img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.slideshow figcaption {
  padding: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.research-panel {
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.research-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.research-heading h3 {
  margin-bottom: 0;
}

#save-status {
  border-radius: 999px;
  background: var(--green-soft);
  padding: 0.35rem 0.65rem;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.research-guidance {
  margin: 1rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.75;
}

.research-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1.2rem;
}

.research-field strong {
  font-size: 0.9rem;
}

.research-field span {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.research-field textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  padding: 0.7rem;
  color: var(--ink);
  line-height: 1.65;
}

@media (max-width: 1320px) {
  .library-header {
    grid-template-columns: auto minmax(420px, 1fr);
  }

  .header-actions {
    display: none;
  }

  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .library-header {
    display: block;
  }

  .brand-block {
    display: none;
  }

  .content-nav {
    overflow-x: auto;
  }

  .content-nav-button {
    min-width: 150px;
    flex: 1 0 auto;
  }

  .page-heading {
    display: block;
  }

  .page-heading .eyebrow {
    margin-bottom: 0.35rem;
  }

  .page-heading h1 {
    margin-bottom: 0.65rem;
  }

  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-layout {
    display: block;
    overflow: auto;
  }

  .dialog-layout > article,
  .research-panel {
    overflow: visible;
  }

  .research-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  main {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .content-nav-button {
    min-width: 138px;
    padding: 0.6rem 0.75rem;
  }

  .toolbar {
    display: grid;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    aspect-ratio: 4 / 3;
  }

  dialog {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}
