:root {
  color-scheme: light;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: #24324a;
  background: #f4f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at top left, rgba(76, 111, 255, 0.1), transparent 30rem), #f4f7fb;
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.board-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  width: min(100% - 3rem, 1600px);
  margin: 0 auto;
  padding: 2rem 0 1.25rem;
}

.board-header__intro { max-width: 46rem; }

.board-header__eyebrow,
.preview-panel__label {
  margin: 0 0 0.35rem;
  color: #4c6fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.board-header h1 {
  margin: 0;
  color: #17223b;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.25;
}

.board-header__intro > p:last-child {
  margin: 0.65rem 0 0;
  color: #637089;
  font-size: 0.94rem;
  line-height: 1.7;
}

.board-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

.board-actions__warning {
  flex-basis: 100%;
  margin: 0;
  color: #6d7890;
  font-size: 0.7rem;
  line-height: 1.5;
  text-align: right;
}

.board-button {
  min-height: 2.75rem;
  border: 1px solid #3f5fe1;
  border-radius: 0.7rem;
  padding: 0.65rem 1rem;
  color: #fff;
  background: #4c6fff;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.board-button:hover {
  border-color: #2f4ecb;
  background: #3f5fe1;
  transform: translateY(-1px);
}

.board-button:focus-visible,
.code-editor:focus-visible {
  outline: 3px solid rgba(76, 111, 255, 0.28);
  outline-offset: 2px;
}

.board-button--secondary {
  border-color: #cdd5e4;
  color: #3a4760;
  background: #fff;
}

.board-button--secondary:hover {
  border-color: #aeb9cc;
  background: #f8faff;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr);
  gap: 1rem;
  width: min(100% - 3rem, 1600px);
  margin: 0 auto;
  padding-bottom: 2rem;
}

.editor-column {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.editor-panel,
.preview-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dce2ed;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 10px 35px rgba(32, 46, 77, 0.08);
}

.editor-panel {
  display: flex;
  min-height: 18.5rem;
  flex-direction: column;
}

.editor-panel__heading,
.preview-panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid #e2e7f0;
  padding: 0.85rem 1rem;
}

.editor-panel__heading label { color: #17223b; font-weight: 800; }
.editor-panel__heading span { color: #7c879c; font-size: 0.75rem; }

.code-editor {
  width: 100%;
  min-height: 0;
  flex: 1;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 1rem;
  color: #d9e2f2;
  background: #17223b;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  tab-size: 2;
}

.code-editor:focus { outline: none; }

.editor-panel__help {
  margin: 0;
  border-top: 1px solid #e2e7f0;
  padding: 0.6rem 1rem;
  color: #6d7890;
  background: #fbfcfe;
  font-size: 0.75rem;
  line-height: 1.5;
}

.preview-panel {
  display: flex;
  min-height: 38rem;
  flex-direction: column;
}

.preview-panel__heading h2 { margin: 0; color: #17223b; font-size: 1rem; }

.preview-panel__status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #3d7455;
  font-size: 0.75rem;
  font-weight: 700;
}

.preview-panel__status::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #55b77b;
  content: "";
}

#preview-frame {
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 0;
  background: #fff;
}

.board-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  max-width: min(24rem, calc(100% - 2rem));
  margin: 0;
  border-radius: 0.7rem;
  padding: 0;
  color: #fff;
  background: #17223b;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(23, 34, 59, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition: opacity 160ms ease, padding 160ms ease, transform 160ms ease;
}

.board-message.is-visible {
  padding: 0.75rem 1rem;
  opacity: 1;
  transform: translateY(0);
}

.html-reference {
  width: min(100% - 3rem, 1600px);
  margin: 0 auto;
  border-top: 1px solid #dce2ed;
  padding: 2.5rem 0 3rem;
}

.html-reference__header {
  margin-bottom: 2rem;
}

.html-reference__eyebrow {
  margin: 0 0 0.35rem;
  color: #4c6fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.html-reference__header h2 {
  margin: 0;
  color: #17223b;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  line-height: 1.3;
}

.html-reference__header > p:last-child {
  margin: 0.55rem 0 0;
  color: #637089;
  font-size: 0.94rem;
  line-height: 1.7;
}

.html-reference__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: start;
  gap: 0.75rem;
}

.html-ref-card {
  min-width: 0;
  border: 1px solid #dce2ed;
  border-radius: 0.8rem;
  padding: 0.9rem;
  background: #fff;
  box-shadow: 0 5px 18px rgba(32, 46, 77, 0.05);
}

.html-ref-card h3 {
  margin: 0;
  color: #33415c;
  font-size: 0.86rem;
  line-height: 1.5;
}

.html-ref-card > p:not(.html-ref-card__note) {
  min-height: 2.8em;
  margin: 0.35rem 0 0.6rem;
  color: #6d7890;
  font-size: 0.73rem;
  line-height: 1.4;
}

.html-ref-card pre {
  margin: 0;
  overflow-x: auto;
  border-radius: 0.45rem;
  padding: 0.55rem 0.65rem;
  color: #d9e2f2;
  background: #17223b;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1.55;
  white-space: pre;
}

.html-ref-card pre code {
  font: inherit;
}

.html-ref-card__note {
  margin: 0.55rem 0 0;
  color: #6d7890;
  font-size: 0.7rem;
  line-height: 1.5;
}

.css-reference {
  width: min(100% - 3rem, 1600px);
  margin: 0 auto;
  border-top: 1px solid #dce2ed;
  padding: 2.5rem 0 4rem;
}

.css-reference__header {
  margin-bottom: 2rem;
}

.css-reference__eyebrow {
  margin: 0 0 0.35rem;
  color: #4c6fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.css-reference__header h2 {
  margin: 0;
  color: #17223b;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  line-height: 1.3;
}

.css-reference__header > p:last-child {
  margin: 0.55rem 0 0;
  color: #637089;
  font-size: 0.94rem;
}

.css-reference__category + .css-reference__category {
  margin-top: 2.25rem;
}

.css-reference__category h3 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  color: #17223b;
  font-size: 1.05rem;
}

.css-reference__category h3::before {
  width: 0.25rem;
  height: 1.15rem;
  border-radius: 999px;
  background: #4c6fff;
  content: "";
}

.css-reference__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
}

.css-ref-card {
  min-width: 0;
  border: 1px solid #dce2ed;
  border-radius: 0.8rem;
  padding: 0.9rem;
  background: #fff;
  box-shadow: 0 5px 18px rgba(32, 46, 77, 0.05);
}

.css-ref-card--wide {
  grid-column: 1 / -1;
}

.css-ref-card h4 {
  margin: 0 0 0.55rem;
  color: #33415c;
  font-size: 0.82rem;
  line-height: 1.5;
}

.css-ref-card > code,
.css-ref-card pre {
  display: block;
  overflow-wrap: anywhere;
  border-radius: 0.45rem;
  padding: 0.55rem 0.65rem;
  color: #d9e2f2;
  background: #17223b;
  font-family: Consolas, "SFMono-Regular", "Courier New", monospace;
  font-size: 0.75rem;
  line-height: 1.55;
}

.css-ref-card pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre;
}

.css-ref-card pre code {
  font: inherit;
}

.css-ref-card__note {
  margin: 0.6rem 0 0;
  color: #6d7890;
  font-size: 0.73rem;
  line-height: 1.6;
}

.css-ref-demo,
.css-ref-flex-demo {
  min-height: 2.8rem;
  margin-top: 0.65rem;
  border: 1px dashed #cbd4e3;
  padding: 0.55rem;
  color: #59667e;
  background: #f8faff;
  font-size: 0.75rem;
}

.css-ref-demo--text-color { color: #c5004c; }
.css-ref-demo--font-size { font-size: 20px; line-height: 1.4; }
.css-ref-demo--bold { font-weight: bold; }
.css-ref-demo--line-height { line-height: 1.8; }
.css-ref-demo--align-left { text-align: left; }
.css-ref-demo--align-center { text-align: center; }
.css-ref-demo--align-right { text-align: right; }

.css-ref-demo--background-color {
  border-color: #c5004c;
  color: #fff;
  background-color: #c5004c;
  text-align: center;
}

.css-ref-margin-diagram {
  margin: 0.65rem 0 0;
}

.css-ref-margin-diagram__parent {
  border: 1px dashed #9ca9bc;
  border-radius: 0.5rem;
  padding: 0.4rem;
  background: #f8faff;
}

.css-ref-margin-diagram__parent-label {
  display: block;
  margin-bottom: 0.25rem;
  color: #66738a;
  font-size: 0.6rem;
  font-weight: 700;
}

.css-ref-margin-diagram__area {
  display: grid;
  grid-template-columns: 2.7rem minmax(3.8rem, 1fr) 2.7rem;
  grid-template-rows: 1.2rem 2.5rem 1.2rem;
  align-items: center;
  overflow: hidden;
  border: 1px solid #e1bc4d;
  border-radius: 0.35rem;
  color: #7a5b13;
  background: #fff1b8;
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.css-ref-margin-diagram__top {
  grid-column: 2;
  grid-row: 1;
}

.css-ref-margin-diagram__left {
  grid-column: 1;
  grid-row: 2;
}

.css-ref-margin-diagram__element {
  display: grid;
  min-height: 2rem;
  grid-column: 2;
  grid-row: 2;
  place-items: center;
  border-radius: 0.3rem;
  color: #fff;
  background: #149fc4;
  font-size: 0.66rem;
}

.css-ref-margin-diagram__right {
  grid-column: 3;
  grid-row: 2;
}

.css-ref-margin-diagram__bottom {
  grid-column: 2;
  grid-row: 3;
}

.css-ref-margin-diagram figcaption {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin-top: 0.4rem;
  color: #6d7890;
  font-size: 0.66rem;
  line-height: 1.5;
}

.css-ref-margin-diagram figcaption::before {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 0.65rem;
  margin-top: 0.15rem;
  border: 1px solid #e1bc4d;
  border-radius: 0.15rem;
  background: #fff1b8;
  content: "";
}

.css-ref-padding-diagram {
  margin: 0.65rem 0 0;
}

.css-ref-padding-diagram__element {
  border: 1px solid #8294e8;
  border-radius: 0.5rem;
  padding: 0.4rem;
  background: #f8faff;
}

.css-ref-padding-diagram__element-label {
  display: block;
  margin-bottom: 0.25rem;
  color: #5264b7;
  font-size: 0.6rem;
  font-weight: 700;
}

.css-ref-padding-diagram__area {
  display: grid;
  grid-template-columns: 2.7rem minmax(3.8rem, 1fr) 2.7rem;
  grid-template-rows: 1.2rem 2.5rem 1.2rem;
  align-items: center;
  overflow: hidden;
  border: 1px solid #9aa9ef;
  border-radius: 0.35rem;
  color: #46589e;
  background: #dfe5ff;
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.css-ref-padding-diagram__top {
  grid-column: 2;
  grid-row: 1;
}

.css-ref-padding-diagram__left {
  grid-column: 1;
  grid-row: 2;
}

.css-ref-padding-diagram__content {
  display: grid;
  min-height: 2rem;
  grid-column: 2;
  grid-row: 2;
  place-items: center;
  border: 1px solid #cfd6e5;
  border-radius: 0.3rem;
  color: #59667e;
  background: #fff;
  font-size: 0.66rem;
}

.css-ref-padding-diagram__right {
  grid-column: 3;
  grid-row: 2;
}

.css-ref-padding-diagram__bottom {
  grid-column: 2;
  grid-row: 3;
}

.css-ref-padding-diagram figcaption {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin-top: 0.4rem;
  color: #6d7890;
  font-size: 0.66rem;
  line-height: 1.5;
}

.css-ref-padding-diagram figcaption::before {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 0.65rem;
  margin-top: 0.15rem;
  border: 1px solid #9aa9ef;
  border-radius: 0.15rem;
  background: #dfe5ff;
  content: "";
}

.css-ref-demo--center-block span {
  display: block;
  width: 60%;
  margin: 0 auto;
  border-radius: 0.3rem;
  padding: 0.25rem;
  color: #fff;
  background: #4c6fff;
  text-align: center;
}

.css-ref-demo--padding {
  padding: 0.75rem 1rem;
  background: #e6ebff;
}

.css-ref-demo--padding span {
  display: block;
  border-radius: 0.3rem;
  padding: 0.25rem;
  background: #fff;
  text-align: center;
}

.css-ref-demo--border {
  border: 1px solid #333;
  text-align: center;
}

.css-ref-demo--radius {
  border-style: solid;
  border-radius: 10px;
  text-align: center;
}

.css-ref-demo--image {
  padding: 0.4rem;
  background: #edf1f8;
}

.css-ref-demo--image span {
  display: grid;
  width: 100%;
  min-height: 2.5rem;
  place-items: center;
  border-radius: 0.35rem;
  color: #42506a;
  background: linear-gradient(135deg, #dce4ff, #f2e5f4);
}

.css-ref-flex-demo {
  display: flex;
  min-height: 3.5rem;
  align-items: flex-start;
  gap: 0.35rem;
}

.css-ref-flex-demo span {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 1.65rem;
  place-items: center;
  border-radius: 0.3rem;
  color: #fff;
  background: #4c6fff;
  font-size: 0.68rem;
  font-weight: 700;
}

.css-ref-flex-demo--center { justify-content: center; }
.css-ref-flex-demo--between { justify-content: space-between; }

.css-ref-flex-demo--align-center {
  min-height: 4.25rem;
  align-items: center;
}

.css-ref-flex-demo--align-center span:nth-child(2) { height: 2.6rem; }

.css-ref-flex-demo--wrap {
  flex-wrap: wrap;
  max-width: 5rem;
}

.css-ref-flex-demo--gap {
  justify-content: center;
  gap: 20px;
}

@media (max-width: 767px) {
  .board-header {
    align-items: stretch;
    flex-direction: column;
    gap: 1rem;
    width: min(100% - 2rem, 1600px);
    padding-top: 1.35rem;
  }

  .board-actions { display: grid; grid-template-columns: 1fr; }
  .board-actions__warning { text-align: left; }
  .board-button { width: 100%; }
  .board-layout { grid-template-columns: 1fr; width: min(100% - 2rem, 1600px); }
  .editor-column { grid-template-rows: none; }
  .editor-panel { min-height: 21rem; }
  .preview-panel { min-height: 30rem; }
  .html-reference { width: min(100% - 2rem, 1600px); padding-top: 2rem; }
  .css-reference { width: min(100% - 2rem, 1600px); padding-top: 2rem; }
}

@media (max-width: 520px) {
  .html-reference__grid { grid-template-columns: 1fr; }
  .css-reference__grid { grid-template-columns: 1fr; }
  .css-reference__category + .css-reference__category { margin-top: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
