*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --text:        #1a1a1a;
  --text-sub:    #555;
  --text-light:  #888;
  --bg:          #ffffff;
  --bg-sidebar:  #f7f7f8;
  --bg-code:     #f3f4f6;
  --border:      #e0e0e0;
  --border-dark: #b0b0b0;
  --link:        #1a56db;
  --link-hover:  #0f3bab;
  --accent:      #1a56db;
  --accent-light:#eff4ff;
  --warn-bg:     #fffbeb;
  --warn-border: #f59e0b;
  --note-bg:     #f0f9ff;
  --note-border: #38bdf8;
  --tip-bg:      #f0fdf4;
  --tip-border:  #22c55e;
  --sidebar-w:   260px;
  --content-max: 780px;
  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo a {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.sidebar-logo .sub {
  font-size: .75rem;
  color: var(--text-light);
  margin-top: .1rem;
}

.sidebar-nav { padding: .75rem 0 2rem; flex: 1; }

.sidebar-site-nav {
  padding-bottom: .75rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-site-nav a {
  font-weight: 600;
}

.nav-section {
  padding: .75rem 1.25rem .3rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-light);
}

.sidebar-nav a {
  display: block;
  padding: .35rem 1.25rem;
  font-size: .875rem;
  color: var(--text-sub);
  text-decoration: none;
  line-height: 1.4;
  border-left: 3px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .1s, color .1s;
}
.sidebar-nav a:hover {
  background: #ebebec;
  color: var(--text);
}
.sidebar-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.sidebar-nav a.sub {
  padding-left: 2.25rem;
  font-size: .825rem;
}
.sidebar-accordion {
  margin: .1rem 0;
}
.sidebar-accordion > summary.nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding-right: 1rem;
}
.sidebar-accordion > summary.nav-section::-webkit-details-marker {
  display: none;
}
.sidebar-accordion > summary.nav-section::after {
  content: "+";
  color: var(--text-light);
  font-family: var(--mono);
  font-size: .8rem;
}
.sidebar-accordion[open] > summary.nav-section::after {
  content: "-";
}
.sidebar-accordion > summary.nav-section:hover {
  background: #ebebec;
  color: var(--text-sub);
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .6rem 2.5rem;
  font-size: .8rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.topbar a { color: var(--link); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

.content {
  padding: 2.5rem 2.5rem 4rem;
  max-width: calc(var(--content-max) + 5rem);
  width: 100%;
}

/* ===== TYPOGRAPHY ===== */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: .5rem;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: .75rem;
}
.page-desc {
  font-size: .95rem;
  color: var(--text-sub);
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2.5rem 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
h2:first-child { margin-top: 0; }

h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.75rem 0 .5rem;
  color: var(--text);
}

h4 {
  font-size: .9rem;
  font-weight: 700;
  margin: 1.25rem 0 .4rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .78rem;
}

p { margin-bottom: .9rem; font-size: .95rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--link); }
a:hover { color: var(--link-hover); }

/* ===== ORDERED / UNORDERED LISTS ===== */
ol, ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  font-size: .95rem;
}
li { margin-bottom: .3rem; line-height: 1.6; }
li > ol, li > ul { margin-top: .3rem; margin-bottom: .3rem; }

/* Step list (numbered with styling) */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps > li {
  counter-increment: step;
  display: flex;
  gap: .9rem;
  margin-bottom: .75rem;
  align-items: flex-start;
  font-size: .95rem;
  line-height: 1.6;
}
.steps > li::before {
  content: counter(step);
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: .15rem;
  font-family: var(--mono);
}

/* ===== TABLES ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  margin: 1rem 0 1.5rem;
}
thead tr { background: #f0f0f0; }
th {
  text-align: left;
  padding: .6rem .85rem;
  font-weight: 700;
  font-size: .8rem;
  color: var(--text);
  border: 1px solid var(--border);
  white-space: normal;
}
/* 項目 | 内容 の2列表 */
.table-kv th:first-child,
.table-kv td:first-child {
  width: 32%;
  min-width: 14em;
  max-width: 22em;
  vertical-align: top;
  line-height: 1.55;
}
.table-kv th:last-child,
.table-kv td:last-child {
  width: 68%;
}
td {
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-sub);
  line-height: 1.55;
}
tr:nth-child(even) td { background: #fafafa; }

/* ===== CODE ===== */
code {
  font-family: var(--mono);
  font-size: .83em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: .1em .4em;
  border-radius: 3px;
  color: #c0392b;
}
pre {
  background: #1e2330;
  color: #d4d8e8;
  padding: 1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: .82rem;
  line-height: 1.6;
  margin: 1rem 0 1.5rem;
}
pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ===== CALLOUT BOXES ===== */
.note, .warn, .tip {
  padding: .9rem 1.1rem;
  border-left: 4px solid;
  border-radius: 0 4px 4px 0;
  margin: 1.25rem 0;
  font-size: .9rem;
  line-height: 1.6;
}
.note  { background: var(--note-bg);  border-color: var(--note-border); }
.warn  { background: var(--warn-bg);  border-color: var(--warn-border); }
.tip   { background: var(--tip-bg);   border-color: var(--tip-border); }
.note strong, .warn strong, .tip strong {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .3rem;
}
.note strong  { color: #0284c7; }
.warn strong  { color: #b45309; }
.tip strong   { color: #15803d; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .15em .55em;
  border-radius: 3px;
  font-family: var(--mono);
  vertical-align: middle;
  margin-left: .35rem;
}
.badge-flow     { background: #dcfce7; color: #166534; }
.badge-insp     { background: #dbeafe; color: #1e40af; }
.badge-license  { background: #fef3c7; color: #92400e; }

/* ===== PAGE NAV ===== */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  font-size: .85rem;
  color: var(--text-sub);
  max-width: 48%;
  transition: border-color .15s, background .15s;
}
.page-nav a:hover { border-color: var(--accent); background: var(--accent-light); }
.page-nav a span { font-size: .7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .06em; }
.page-nav .next { margin-left: auto; text-align: right; }

/* ===== FLOW DIAGRAM (CSS-only) ===== */
.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 1.25rem 0 1.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.flow-step {
  flex: 1;
  min-width: 120px;
  padding: .75rem .85rem;
  background: #fff;
  border-right: 1px solid var(--border);
  font-size: .8rem;
  position: relative;
  line-height: 1.4;
}
.flow-step:last-child { border-right: none; }
.flow-step .num {
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-light);
  font-family: var(--mono);
  display: block;
  margin-bottom: .2rem;
}
.flow-step .label { font-weight: 600; font-size: .8rem; }
.flow-step .tool { font-size: .65rem; margin-top: .3rem; }
.flow-step.active { background: var(--accent-light); }
.flow-step.active .label { color: var(--accent); }

/* ===== DETAIL SECTION ===== */
.section-box {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1.25rem 0;
  overflow: hidden;
}
.section-box-header {
  background: #f3f4f6;
  padding: .6rem 1rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-box-body { padding: 1rem; }

/* ===== GENERATED SAMPLE PAGES ===== */
.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 10;
  transform: translateY(-150%);
  background: var(--text);
  color: #fff;
  padding: .45rem .7rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: .82rem;
}
.skip-link:focus { transform: translateY(0); }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.sample-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  background: #fff;
}
.sample-card h2 {
  margin-top: 0;
  font-size: 1rem;
}
.sample-card h2 a {
  color: var(--text);
  text-decoration: none;
}
.sample-card h2 a:hover {
  color: var(--link);
}
.sample-card p {
  margin: .65rem 0 0;
  font-size: .9rem;
  color: var(--text-sub);
  line-height: 1.6;
}
.sample-card__meta {
  color: var(--text-light);
  font-size: .82rem;
}

.doc-list {
  list-style: none;
  padding-left: 0;
}
.doc-list li {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .7rem;
  align-items: baseline;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.doc-list code {
  color: var(--text-light);
}

blockquote {
  background: var(--note-bg);
  border-left: 4px solid var(--note-border);
  border-radius: 0 4px 4px 0;
  color: var(--text-sub);
  margin: 1.25rem 0;
  padding: .9rem 1.1rem;
}
blockquote p { font-size: .9rem; }

figure {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1.25rem 0 1.5rem;
  padding: .75rem;
  background: #fafafa;
}
figure img {
  display: block;
  max-width: 100%;
  height: auto;
}
figcaption {
  color: var(--text-light);
  font-size: .82rem;
  margin-top: .5rem;
}
.missing-image {
  border-style: dashed;
}
.missing-image__box {
  background: #fff;
  border: 1px dashed var(--border-dark);
  color: var(--text-sub);
  padding: 1rem;
}

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

/* ===== WCAG CATALOG SAMPLE PAGES ===== */
.wcag-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 1rem 0 1.5rem;
}
.wcag-meta .badge {
  margin-left: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
}

.wcag-case {
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1.5rem 0;
  padding: 1rem;
  background: #fff;
}
.wcag-case h2 {
  margin-top: 0;
}
.issue-note {
  background: #fff5f5;
  border-left: 4px solid #dc2626;
  border-radius: 0 4px 4px 0;
  color: var(--text-sub);
  margin: 1rem 0;
  padding: .85rem 1rem;
}
.demo-box {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
  margin-top: 1rem;
  max-width: 100%;
  overflow: auto;
  padding: 1rem;
}
.demo-box > * + * {
  margin-top: .75rem;
}
.demo-box video,
.demo-box audio,
.tool-case video,
.tool-case audio,
.tool-case-chart__svg {
  display: block;
  max-width: 100%;
  height: auto;
}
.tool-case-chart {
  max-width: 100%;
  margin-top: .5rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.tool-case {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  padding: 1rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.tool-case h3 {
  margin-top: 0;
  margin-bottom: .1rem;
}
.tool-case > p {
  font-size: .875rem;
  color: var(--text-sub);
  line-height: 1.55;
}
.tool-case button,
.tool-case input:not([type="hidden"]),
.tool-case select,
.tool-case textarea {
  font: inherit;
  font-size: .875rem;
  line-height: 1.4;
  padding: .45rem .7rem;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  max-width: 100%;
}
.tool-case button {
  background: #f8fafc;
  cursor: pointer;
}
.tool-case button:hover {
  background: #f1f5f9;
}
.tool-case button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tool-case input:focus-visible,
.tool-case select:focus-visible,
.tool-case textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.tool-case label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
}
.tool-case a:not(.tiny-target) {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: .875rem;
}
.tool-case a:not(.tiny-target):hover {
  color: var(--link-hover);
}
.tool-case nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .75rem;
  font-size: .875rem;
}
.tool-case nav a {
  text-decoration: none;
  padding: .2rem .35rem;
  border-radius: 3px;
}
.tool-case nav a:hover {
  background: var(--accent-light);
}
.tool-case [role="dialog"] {
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
}
.tool-case > table {
  margin: 0;
  font-size: .82rem;
}
.tool-case > li {
  margin-left: 1.1rem;
  font-size: .875rem;
  color: var(--text-sub);
  list-style: disc;
}
.tool-case .shake-control {
  font-size: .82rem;
  color: var(--text-sub);
  padding: .35rem 0;
}
.tool-case .fake-button {
  align-self: flex-start;
  border-radius: 4px;
}
.tool-case .tiny-target {
  margin-right: .25rem;
}
.tool-case .map-widget,
.tool-case .carousel-widget,
.tool-case .toast-message,
.tool-case .flash,
.tool-case-chart {
  margin-top: 0;
}
.tool-case [style*="position:sticky"] {
  border-radius: 4px;
  font-size: .82rem;
}
.reflow-demo {
  overflow-x: auto;
  max-width: 100%;
  margin-top: .5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  -webkit-overflow-scrolling: touch;
}
.reflow-demo__table {
  width: 900px;
  margin: 0;
  font-size: .8rem;
}
.reflow-demo__table th,
.reflow-demo__table td {
  white-space: normal;
}
.visual-only {
  color: #c00;
}
.map-widget,
.carousel-widget {
  min-height: 80px;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  padding: .8rem;
}
.toast-message {
  padding: .6rem .75rem;
  background: #ecfeff;
  border: 1px solid #67e8f9;
  border-radius: 4px;
}

.low-contrast { color: #b8b8b8; background: #fff; }
.tiny-target {
  display: inline-flex;
  width: 18px;
  height: 18px;
  line-height: 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid #666;
  text-decoration: none;
}
.fake-button {
  display: inline-block;
  padding: 8px 12px;
  background: #1f2937;
  color: #fff;
  cursor: pointer;
}
.tool-case .hidden-focus:focus,
.tool-case .hidden-focus:focus-visible,
.hidden-focus:focus { outline: none; }
.fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: #111827;
  color: #fff;
  z-index: 10;
  padding: 8px 20px;
}
.spacer { height: 90px; }
.columns { columns: 3; max-width: 38em; }
.text-spacing-break {
  height: 24px;
  overflow: hidden;
  border: 1px solid #ddd;
}
.hover-card {
  position: relative;
}
.hover-card .tip {
  display: none;
  position: absolute;
  max-width: 260px;
  padding: 8px;
  background: #111827;
  color: #fff;
  z-index: 1;
}
.hover-card:hover .tip,
.hover-card:focus-within .tip {
  display: block;
}
.flash {
  width: 160px;
  padding: 20px;
  background: #fff;
  color: #000;
  border: 1px solid #111;
}
.flash.is-flashing {
  animation: flash 0.2s linear infinite;
}
.flash.is-slow-flashing {
  animation: flash 1s linear infinite;
}
@keyframes flash {
  0%, 49% { background: #fff; color: #000; }
  50%, 100% { background: #000; color: #fff; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 820px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { display: none; }
  .topbar { padding: .6rem 1.5rem; }
  .content { padding: 1.5rem; }
  .page-nav { flex-direction: column; }
  .page-nav a { max-width: none; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar { display: none; }
  .topbar { display: none; }
  .page-nav { display: none; }
  .content { padding: 0; }
  pre { white-space: pre-wrap; }
}
