:root {
  --background: #f4f3ef;
  --panel: #ffffff;
  --text: #202522;
  --muted: #66706a;
  --line: #d8ddd9;
  --accent: #176b57;
  --accent-dark: #0e4d3e;
  --accent-soft: #e6f2ed;
  --code: #17201d;
  --code-text: #e8f0ec;
  --warning: #8a5a13;
  --warning-soft: #fff5df;
  --error: #a13a32;
  --error-soft: #fff0ee;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.75;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--accent-dark);
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.55rem 0.8rem;
  color: #fff;
  background: var(--accent-dark);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  font-weight: 700;
}

.back-link {
  text-decoration: none;
}

.page-layout {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 250px minmax(0, 760px);
  gap: clamp(2rem, 5vw, 5rem);
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2rem) 6rem;
}

.sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.9rem;
}

.sidebar-title {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-weight: 800;
}

.sidebar ul {
  margin: 0;
  padding-left: 1.1rem;
}

.sidebar li {
  margin: 0.3rem 0;
}

.sidebar a {
  color: var(--text);
  text-decoration: none;
}

.sidebar a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.content {
  min-width: 0;
}

.content > section {
  margin-top: 4.5rem;
}

.content > section:first-child {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.35;
  scroll-margin-top: 1rem;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  letter-spacing: -0.035em;
}

h2 {
  margin: 2.3rem 0 0.8rem;
  font-size: 1.35rem;
}

h3 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.05rem;
}

p,
ul,
ol,
table,
pre,
blockquote {
  margin-top: 0.8rem;
  margin-bottom: 0.8rem;
}

blockquote {
  margin-inline: 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}

blockquote p {
  margin: 0;
}

code {
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: #e8ebe9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 1rem;
  border-radius: 8px;
  color: var(--code-text);
  background: var(--code);
  line-height: 1.55;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 0.94rem;
}

th,
td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf0ee;
}

.formal-note {
  margin: 1.4rem 0;
  border: 1px solid #a8c7bb;
  border-radius: 8px;
  background: #f1f8f5;
}

.formal-note summary {
  padding: 0.8rem 1rem;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}

.formal-note[open] summary {
  border-bottom: 1px solid #c7ddd4;
}

.formal-note > :not(summary) {
  margin-right: 1rem;
  margin-left: 1rem;
}

.source-note pre {
  max-height: 34rem;
  overflow: auto;
}

math[display="block"] {
  display: block;
  max-width: 100%;
  margin: 1rem auto;
  overflow-x: auto;
  font-size: 1.15rem;
}

.misconception {
  margin: 1.2rem 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--warning);
  background: var(--warning-soft);
}

.simulator,
.quiz,
.jwt-tool {
  padding: clamp(1rem, 4vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.simulator h2,
.quiz h2,
.jwt-tool h2 {
  margin-top: 0;
}

.request-form {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 0.9rem;
}

.request-form label {
  display: grid;
  gap: 0.35rem;
}

.request-form label > span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.body-field,
.form-actions {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #aeb8b2;
  border-radius: 7px;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

textarea:disabled {
  color: var(--muted);
  background: #eef0ef;
}

.jwt-tool label {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
}

.jwt-tool label > span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.jwt-tool pre {
  min-height: 12rem;
}

.jwt-warning {
  color: var(--error);
  font-weight: 700;
}

.jwt-tool pre[data-kind="error"] {
  color: #ffd6d2;
}

.form-actions,
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

button {
  min-height: 42px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.quiz-options button {
  color: var(--text);
  background: #f5f7f6;
}

.request-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.response-summary {
  margin: 1rem 0;
  padding: 0.7rem 0.85rem;
  border-radius: 7px;
  background: #eef0ef;
}

.response-summary[data-kind="success"],
.quiz-feedback[data-kind="success"] {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.response-summary[data-kind="error"],
.quiz-feedback[data-kind="error"] {
  color: var(--error);
  background: var(--error-soft);
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.output-grid h3 {
  margin-top: 0;
}

.output-grid pre {
  min-height: 240px;
  margin-bottom: 0;
  font-size: 0.82rem;
}

.quiz + .quiz {
  margin-top: 1rem;
}

.quiz-options-long {
  display: grid;
}

.quiz-options button.is-selected {
  outline: 3px solid #d2d8d5;
}

.quiz-options button.is-correct {
  border-color: var(--accent);
}

.quiz-feedback {
  min-height: 1.75rem;
  padding: 0.3rem 0.5rem;
}

@media (max-width: 820px) {
  .page-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .sidebar nav > ul {
    columns: 2;
  }
}

@media (max-width: 600px) {
  .request-form,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .path-field,
  .body-field,
  .form-actions {
    grid-column: auto;
  }

  .sidebar nav > ul {
    columns: 1;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
