:root {
  color-scheme: light;
  --background: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text-strong: #000000;
  --text: #1d1d1f;
  --muted: #48484A;
  --border: rgba(0, 0, 0, 0.08);
  --rule: rgba(0, 0, 0, 0.06);
  --chrome-surface: rgba(0, 0, 0, 0.015);
  --chrome-border: rgba(0, 0, 0, 0.04);
  --chrome-border-strong: rgba(0, 0, 0, 0.055);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.08);
  --prose-font: "New York", "New York Large", "New York Medium", "New York Small", ui-serif, Georgia, serif;
  --ui-font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono-font: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(16px, 4vw, 32px);
  background: linear-gradient(180deg, #ffffff 0%, var(--background) 100%);
  color: var(--text);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: auto;
  font-optical-sizing: auto;
}

main {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: clamp(24px, 6vw, 56px) clamp(20px, 5vw, 48px);
  border: 1px solid var(--border);
  border-radius: clamp(20px, 4vw, 28px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

article {
  width: min(100%, 820px);
  margin: 0 auto;
  overflow-wrap: break-word;
  font-family: var(--prose-font);
  font-size: clamp(1rem, 1.2vw, 1.0625rem);
  line-height: 1.72;
}

article > :last-child {
  margin-bottom: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-strong);
  font-family: var(--ui-font);
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

h2 {
  margin: clamp(40px, 6vw, 56px) 0 18px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 1em;
  line-height: inherit;
}

a {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.25);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-color: var(--text-strong);
}

ul,
ol {
  margin: 0 0 24px 1.35rem;
  padding: 0;
}

li {
  margin: 0 0 10px;
  padding-left: 0.2rem;
  color: var(--text);
  line-height: inherit;
}

li::marker {
  color: var(--text-strong);
}

li > *:last-child {
  margin-bottom: 0;
}

strong {
  color: var(--text-strong);
  font-weight: 700;
}

em {
  font-style: italic;
  color: var(--text);
}

blockquote {
  margin: 24px 0 28px;
  padding: 0.5em 0 0.5em 1.25em;
  border-left: 2px solid var(--text-strong);
  color: var(--text);
  font-style: italic;
}

blockquote > :last-child {
  margin-bottom: 0;
}

code {
  padding: 0.12em 0.38em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-strong);
  font-family: var(--mono-font);
  font-size: 0.88em;
}

pre {
  margin: 24px 0 28px;
  padding: 16px 20px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface-soft);
  -webkit-overflow-scrolling: touch;
}

pre code {
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
}

.inline-math {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--text-strong);
}

.inline-math mjx-container {
  max-width: 100%;
}

.equation {
  margin: 24px 0 30px;
  padding: clamp(16px, 4vw, 24px);
  border: 1px solid var(--chrome-border);
  border-radius: 20px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98) 0%,
    var(--chrome-surface) 100%
  );
  color: var(--text-strong);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: normal;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.8;
  -webkit-overflow-scrolling: touch;
}

.equation mjx-container {
  margin: 0 !important;
  max-width: 100%;
}

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

.table-wrap {
  margin: 28px 0 32px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  border: 1px solid var(--chrome-border);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  font-family: var(--ui-font);
}

thead {
  border-bottom: 1px solid var(--chrome-border-strong);
}

th,
td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--chrome-border);
  text-align: left;
  vertical-align: top;
  font-size: 0.95rem;
  line-height: 1.6;
  font-family: var(--ui-font);
}

th {
  background: transparent;
  color: var(--text-strong);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--text);
  background: transparent;
}

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

img,
svg,
canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

mjx-container[display='true'] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 720px) {
  body {
    padding: 0;
    background: #ffffff;
  }

  main {
    width: 100%;
    padding: 24px 20px 40px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  article {
    width: 100%;
    font-size: 1rem;
  }

  ul,
  ol {
    margin-left: 1rem;
  }

  .equation {
    padding: 16px 14px;
    overflow-x: visible;
  }

  mjx-container[display='true'] {
    overflow-x: visible;
    overflow-y: visible;
    white-space: normal !important;
  }

  mjx-container[display='true'] mjx-math,
  .inline-math mjx-container,
  .inline-math mjx-container mjx-math {
    white-space: normal !important;
  }

  th,
  td {
    padding: 12px;
  }
}
