:root {
  --paper: #FAF7F2;
  --paper-deep: #EFEAE0;
  --paper-edge: #E7E1D3;
  --ink: #1C1D21;
  --ink-soft: #34353A;
  --muted: #7C7870;
  --rule: #E4DFD3;
  --accent: #F05138;
  --accent-soft: rgba(240, 81, 56, 0.12);

  /* Xcode Default Dark — syntax palette */
  --xc-bg: #1F1F24;
  --xc-text: #FFFFFF;
  --xc-comment: #6C7986;
  --xc-string: #FC6A5D;
  --xc-number: #D0BF69;
  --xc-keyword: #FC5FA3;
  --xc-type-builtin: #D0A8FF;
  --xc-type-project: #5DD8FF;
  --xc-function: #67B7A4;
  --xc-attribute: #BF8555;
  --xc-preprocessor: #FD8F3F;

  --content-max: 760px;
  --wide-max: 1100px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 900px 520px at 85% -5%, rgba(240, 81, 56, 0.04), transparent 60%),
    radial-gradient(ellipse 700px 460px at 0% 10%, rgba(240, 81, 56, 0.02), transparent 60%);
  color: var(--ink);
  font-family: "IBM Plex Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-weight: 400;
  line-height: 1.75;
  min-height: 100vh;
  font-feature-settings: "palt" 1;
}

::selection {
  background: rgba(240, 81, 56, 0.22);
  color: var(--ink);
}

/* ────────── Masthead ────────── */
.masthead {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 1.1rem 2rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  border-bottom: 1px solid var(--rule);
}

.masthead::after {
  content: "";
  position: absolute;
  left: 2rem;
  bottom: -1.5px;
  height: 2px;
  width: 44px;
  background: var(--accent);
}

.wordmark {
  font-family: "IBM Plex Sans JP", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.wordmark-mark {
  width: 1.4em;
  height: 1.4em;
  flex-shrink: 0;
  display: block;
}

.masthead-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.masthead-nav a {
  font-family: "IBM Plex Sans JP", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

.masthead-nav a:hover {
  color: var(--accent);
}

.masthead-nav a[aria-current="page"] {
  color: var(--accent);
}

.eyebrow-id {
  color: var(--accent);
  font-weight: 600;
}

.eyebrow-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.eyebrow-link:hover,
.eyebrow-link:focus-visible {
  color: var(--accent);
}

.eyebrow-link-arrow {
  display: inline-block;
  margin-left: 0.25em;
  font-size: 0.85em;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.eyebrow-link:hover .eyebrow-link-arrow,
.eyebrow-link:focus-visible .eyebrow-link-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.eyebrow-sep {
  color: var(--rule);
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.5em;
  vertical-align: 0.1em;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status-dot-accepted {
  background: #1F9D55;
  box-shadow: 0 0 0 3px rgba(31, 157, 85, 0.14);
}

.status-dot-ongoing {
  background: #2F6FE4;
  box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.14);
}

.status-dot-not-accepted {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status-dot-others {
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(124, 120, 112, 0.14);
}

/* ────────── Prose body (rendered markdown) ────────── */
.section-body {
  font-size: 0.95rem;
  line-height: 1.78;
  color: var(--ink-soft);
}

.section-body > *:first-child { margin-top: 0; }
.section-body > *:last-child { margin-bottom: 0; }

.section-body p {
  margin: 0 0 0.9rem;
}

.section-body h3 {
  font-family: "IBM Plex Sans JP", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 1.7rem 0 0.6rem;
  padding-left: 0.75rem;
  position: relative;
}

.section-body h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 3px;
  height: 1em;
  background: var(--accent);
  border-radius: 1px;
}

.section-body h4 {
  font-family: "IBM Plex Sans JP", sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 1.3rem 0 0.5rem;
}

.section-body strong {
  font-weight: 600;
  color: var(--ink);
}

.section-body a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(180deg, transparent 0, transparent 62%, rgba(240, 81, 56, 0.28) 62%, rgba(240, 81, 56, 0.28) 82%, transparent 82%);
  transition: color 0.15s ease, background-image 0.15s ease;
  padding: 0 0.05em;
}

.section-body a:hover {
  color: var(--accent);
  background-image: linear-gradient(180deg, transparent 0, transparent 62%, rgba(240, 81, 56, 0.55) 62%, rgba(240, 81, 56, 0.55) 82%, transparent 82%);
}

.section-body ul,
.section-body ol {
  margin: 0.6rem 0 1rem;
  padding-left: 1.5rem;
}

.section-body li {
  margin-bottom: 0.25rem;
}

.section-body ul li::marker { color: var(--accent); }
.section-body ol li::marker {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
}

.section-body blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.15rem 0 0.15rem 1rem;
  margin: 1rem 0;
  color: var(--muted);
}

.section-body hr {
  border: none;
  height: 1px;
  background: var(--rule);
  margin: 1.6rem 0;
}

.section-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.1rem 0;
  font-size: 0.86rem;
}

.section-body th,
.section-body td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.section-body th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--ink);
}

/* Inline code */
.section-body code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85em;
  background: var(--paper-deep);
  color: var(--ink);
  padding: 0.08em 0.38em;
  border-radius: 3px;
  font-weight: 500;
  border: 1px solid var(--paper-edge);
}

/* ────────── Code blocks (Xcode Default Dark) ────────── */
.section-body pre {
  background: var(--xc-bg);
  color: var(--xc-text);
  padding: 1rem 1.2rem 1.1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.1rem -0.4rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 16px 32px -22px rgba(28, 29, 33, 0.45);
}

.section-body pre::before {
  content: "swift";
  position: absolute;
  top: 0;
  right: 1rem;
  padding: 0.2rem 0.5rem;
  background: rgba(240, 81, 56, 0.18);
  color: #FFAE91;
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border-radius: 0 0 3px 3px;
}

.section-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-weight: 400;
  font-size: inherit;
  white-space: pre;
}

/* Rouge syntax highlighting — Xcode Default Dark */
.highlight .k,
.highlight .kd,
.highlight .kr,
.highlight .kn,
.highlight .kp,
.highlight .kc { color: var(--xc-keyword); }       /* let, var, func, return, if, class, nil, true */
.highlight .kt { color: var(--xc-type-builtin); }  /* built-in types: Int, String, Optional */
.highlight .nc { color: var(--xc-type-project); }  /* user-declared class/struct names */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .se,
.highlight .sr { color: var(--xc-string); }
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs,
.highlight .cp { color: var(--xc-comment); }
.highlight .mi,
.highlight .mf,
.highlight .il,
.highlight .mb,
.highlight .mh,
.highlight .mo { color: var(--xc-number); }
.highlight .nf,
.highlight .fm { color: var(--xc-function); }
.highlight .nb { color: var(--xc-type-builtin); }
.highlight .na { color: var(--xc-attribute); }
.highlight .nd { color: var(--xc-attribute); }
.highlight .nv,
.highlight .n,
.highlight .nl { color: var(--xc-text); }
.highlight .o,
.highlight .ow,
.highlight .p { color: var(--xc-text); }
.highlight .err { color: var(--xc-string); background: transparent; }
.highlight .bp { color: var(--xc-keyword); }

/* ────────── Section heading (shared) ────────── */
.section-heading {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.section-num {
  flex-shrink: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(240, 81, 56, 0.35);
  border-radius: 3px;
  line-height: 1;
  text-transform: uppercase;
  position: relative;
  top: -0.1em;
}

.section-heading-text {
  font-family: "IBM Plex Sans JP", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.45;
  letter-spacing: -0.012em;
  color: var(--ink);
}

/* ────────── Colophon ────────── */
.colophon {
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 1.4rem 2rem 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  position: relative;
}

.colophon::before {
  content: "";
  position: absolute;
  left: 2rem;
  top: -1.5px;
  height: 2px;
  width: 44px;
  background: var(--accent);
}

.colophon-mark {
  color: var(--ink);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.colophon-mark-logo {
  width: 1.3em;
  height: 1.3em;
  flex-shrink: 0;
  display: block;
}

.colophon-nav {
  display: inline-flex;
  align-items: baseline;
  gap: 1.2rem;
}

.colophon-link {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.colophon-link:hover,
.colophon-link[aria-current="page"] {
  color: var(--accent);
}

/* ────────── Focus & motion ────────── */
a:focus-visible,
.wordmark:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ────────── Responsive ────────── */
@media (max-width: 720px) {
  .masthead {
    padding: 0.9rem 1.2rem 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .masthead::after { left: 1.2rem; }

  .section-body pre {
    margin: 1rem -1.2rem;
    border-radius: 0;
    padding: 0.9rem 1.2rem 1rem;
  }

  .section-heading-text { font-size: 1.15rem; }

  .colophon {
    padding: 1.2rem 1.2rem 1.8rem;
  }
  .colophon::before { left: 1.2rem; }
}
