:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5c667a;
  --line: #dbe3f0;
  --blue: #1458d4;
  --blue-dark: #0c3f9f;
  --blue-soft: #eaf2ff;
  --yellow: #fff7cf;
  --yellow-line: #e5ca57;
  --paper: #ffffff;
  --page: #f4f7fb;
  --code: #101827;
  --code-ink: #e9f0ff;
  --green: #177453;
  --shadow: 0 12px 34px rgba(25, 48, 86, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.68;
}

.mode-status-note {
  margin: 0 0 22px;
  padding: 14px 17px;
  border: 1px solid #e5ca57;
  border-radius: 12px;
  background: #fff7cf;
  color: #594513;
  line-height: 1.55;
}
.mode-status-note strong { display: block; }
.mode-exam-nav { padding: 10px 20px; border-bottom: 1px solid #dbe3f0; background: #eaf2ff; }
.mode-exam-nav a { color: #0c3f9f; font-weight: 750; text-underline-offset: 3px; }

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 22px;
  color: #f7faff;
  background: linear-gradient(165deg, #102a56 0%, #0d459e 58%, #1766db 100%);
  box-shadow: 6px 0 24px rgba(15, 43, 88, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 13px;
  color: #123b7f;
  background: #ffdc4f;
  font-size: 25px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 22px;
  letter-spacing: 0.08em;
}

.brand small {
  color: #cfe0ff;
  font-size: 12px;
}

.sidebar-intro {
  margin: 0 0 24px;
  color: #d8e7ff;
  font-size: 13px;
  line-height: 1.5;
}

.nav-label {
  margin: 22px 8px 8px;
  color: #92b9fa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar nav a {
  display: block;
  margin: 2px 0;
  padding: 7px 10px;
  border-radius: 8px;
  color: #eff5ff;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  transition: background 120ms ease, transform 120ms ease;
}

.sidebar nav a:hover,
.sidebar nav a:focus {
  background: rgba(255, 255, 255, 0.13);
  transform: translateX(2px);
}

.sidebar nav .memo-link {
  margin-top: 14px;
  border: 1px solid rgba(255, 220, 79, 0.6);
  color: #fff2a8;
  font-weight: 700;
}

main {
  min-width: 0;
  padding: 42px clamp(24px, 5vw, 72px) 50px;
}

article {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 68px);
  border: 1px solid #e5eaf2;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
h4 {
  color: #10264a;
  line-height: 1.24;
}

h1 {
  margin: 0 0 16px;
  color: var(--blue-dark);
  font-size: clamp(34px, 5vw, 54px);
  letter-spacing: -0.035em;
}

h2 {
  margin: 72px 0 22px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
  font-size: 30px;
  letter-spacing: -0.02em;
}

h3 {
  margin: 38px 0 12px;
  color: #174b9b;
  font-size: 22px;
}

h4 {
  margin: 28px 0 8px;
  font-size: 18px;
}

p {
  margin: 12px 0;
}

a {
  color: var(--blue);
}

strong {
  color: #102e61;
}

hr {
  margin: 48px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

blockquote {
  margin: 22px 0;
  padding: 16px 20px;
  border: 1px solid var(--yellow-line);
  border-left: 6px solid #e1b900;
  border-radius: 8px;
  color: #4c421a;
  background: var(--yellow);
}

blockquote p {
  margin: 0;
}

ul,
ol {
  padding-left: 26px;
}

li {
  margin: 6px 0;
}

table {
  width: 100%;
  margin: 24px 0;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.table-scroll table {
  min-width: 560px;
}

th,
td {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  color: #103d86;
  background: var(--blue-soft);
  font-weight: 750;
}

pre {
  margin: 22px 0;
  padding: 20px 22px;
  overflow-x: auto;
  border: 1px solid #263956;
  border-radius: 12px;
  color: var(--code-ink);
  background: var(--code);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 14px;
  line-height: 1.55;
}

code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  color: #0b4ca5;
  background: #edf4ff;
  font-family: Consolas, "Cascadia Code", monospace;
  font-size: 0.92em;
}

pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
}

details {
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

summary {
  padding: 15px 18px;
  cursor: pointer;
  color: #123f89;
  background: var(--blue-soft);
  user-select: none;
}

details[open] summary {
  border-bottom: 1px solid var(--line);
}

details > :not(summary) {
  margin-right: 20px;
  margin-left: 20px;
}

details > :last-child {
  margin-bottom: 20px;
}

.class-diagram {
  margin: 24px 0;
  padding: 20px;
  overflow-x: auto;
  border: 1px solid #bfd3f4;
  border-radius: 14px;
  background:
    linear-gradient(rgba(20, 88, 212, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 88, 212, 0.035) 1px, transparent 1px),
    #fbfdff;
  background-size: 22px 22px;
}

.class-diagram img {
  display: block;
  width: auto;
  min-width: 320px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.class-diagram figcaption {
  max-width: 760px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.class-diagram-wrong {
  border-color: #e5a0a0;
  background: #fff7f7;
}

.class-diagram-wrong figcaption {
  color: #9b2525;
  font-weight: 700;
}

.schema-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 24px 0;
  padding: 22px;
  border: 1px solid #bfd3f4;
  border-radius: 14px;
  background: #f5f9ff;
}

.schema-grid-wide {
  justify-content: flex-start;
}

.schema-card {
  display: grid;
  min-width: 170px;
  overflow: hidden;
  border: 1px solid #9fbce8;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(17, 55, 110, 0.08);
  font-size: 14px;
}

.schema-card > strong {
  padding: 8px 13px;
  color: #fff;
  background: #174b9b;
  font-size: 13px;
  letter-spacing: 0.035em;
}

.schema-card > span {
  padding: 6px 13px;
  border-top: 1px solid #e4eaf3;
  white-space: nowrap;
}

.schema-card em {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  color: #12533d;
  background: #dcf7e9;
  font-size: 11px;
  font-style: normal;
  font-weight: 750;
}

.schema-join > strong {
  background: #177453;
}

.schema-arrow {
  color: #174b9b;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-right: 7px;
  accent-color: var(--green);
  vertical-align: -3px;
}

article > a[id] {
  display: block;
  position: relative;
  top: -24px;
  visibility: hidden;
}

footer {
  max-width: 980px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: white;
  background: var(--blue);
  box-shadow: 0 7px 18px rgba(20, 88, 212, 0.3);
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 20px;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 10px;
  }

  .nav-label {
    grid-column: 1 / -1;
  }

  main {
    padding: 20px 12px 40px;
  }

  article {
    padding: 26px 20px;
    border-radius: 14px;
  }

  h2 {
    margin-top: 54px;
  }
}

@media print {
  body {
    background: white;
    font-size: 11pt;
  }

  .layout {
    display: block;
  }

  .sidebar,
  .back-to-top,
  footer {
    display: none;
  }

  main,
  article {
    max-width: none;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  h2 {
    break-before: page;
  }

  pre,
  blockquote,
  table,
  details,
  .class-diagram {
    break-inside: avoid;
  }

  .class-diagram {
    padding: 10px;
    border: 1px solid #ccd5e3;
    background: white;
  }

  details > * {
    display: block;
  }
}
