.katex-display {
  overflow-x: auto;
  max-width: 100%;
  font-size: 1rem;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.katex-display > .katex,
.katex-display > .katex > .katex-html {
  text-align: left;
}

.content {
  min-width: 0;
}

.markdown-section {
  box-sizing: border-box;
  max-width: min(980px, calc(100vw - 2rem));
  overflow-wrap: break-word;
}

.markdown-section * {
  box-sizing: border-box;
}

.markdown-section img,
.markdown-section video,
.markdown-section canvas,
.markdown-section iframe {
  display: block;
  max-width: 100%;
  height: auto;
}

.markdown-section iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.markdown-section table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  -webkit-overflow-scrolling: touch;
}

.markdown-section th,
.markdown-section td {
  min-width: max-content;
  vertical-align: top;
}

.markdown-section a {
  overflow-wrap: anywhere;
}

.markdown-section blockquote {
  max-width: 100%;
  margin-right: 0;
  overflow-wrap: break-word;
}

.markdown-section blockquote blockquote {
  margin-left: 0.75rem;
  padding-left: 0.75rem;
}

.markdown-section pre {
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.code-copy-button {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 1;
  min-width: 4.2rem;
  padding: 0.32rem 0.62rem;
  border: 1px solid color-mix(in srgb, var(--base-color, #333) 16%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--base-background-color, #fff) 88%, transparent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  color: color-mix(in srgb, var(--base-color, #333) 84%, transparent);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0.82;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease,
    transform 0.15s ease;
}

.code-copy-button:hover,
.code-copy-button:focus-visible {
  border-color: var(--link-color, #2563eb);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  color: var(--link-color, #2563eb);
  opacity: 1;
  transform: translateY(-1px);
}

.code-copy-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--link-color, #2563eb) 35%, transparent);
  outline-offset: 2px;
}

:root[data-theme="dark"] .code-copy-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(18, 24, 33, 0.86);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.38);
  color: rgba(255, 255, 255, 0.76);
}

:root[data-theme="dark"] .code-copy-button:hover,
:root[data-theme="dark"] .code-copy-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.46);
  color: #fff;
}

:root[data-theme="dark"] .code-copy-button:focus-visible {
  outline-color: rgba(255, 255, 255, 0.24);
}

.markdown-section pre code {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: pre;
}

.markdown-section :not(pre) > code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

:root[data-theme="eye"] {
  --base-background-color: #f5f3ed;
  --base-color: #3a3a3a;
  --sidebar-background: #ece8df;
  --sidebar-color: #3a3a3a;
  --link-color: #8b6f47;
  --link-color--hover: #6d5738;
  --heading-color: #2b2b2b;
}

#login-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

#theme-selector {
  position: fixed;
  top: 10px;
  right: 20px;
  z-index: 999;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 17px;
}

.math-card {
  display: block;
  margin: 1rem 0;
  padding: 1rem;
  border-left: 4px solid #ff9800;
  border-radius: 6px;
  background: color-mix(in srgb, var(--base-background-color, #fff) 88%, #ff9800);
}

.math-card strong {
  display: block;
  margin-bottom: 0.45rem;
}

.profile-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.85em;
  line-height: 1.4;
}

.role-home {
  display: grid;
  gap: 1.25rem;
  margin: 0.5rem 0 2.5rem;
}

.role-hero {
  padding: 1.45rem;
  border: 1px solid color-mix(in srgb, var(--base-color, #333) 14%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--base-background-color, #fff) 88%, var(--role-accent, #f6b35b)),
      color-mix(in srgb, var(--base-background-color, #fff) 94%, var(--role-secondary, #6ba99a)));
}

.role-kicker {
  margin: 0 0 0.35rem;
  color: color-mix(in srgb, var(--base-color, #333) 72%, transparent);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0;
}

.role-hero h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

.role-hero p {
  max-width: 44rem;
  margin: 0.7rem 0 0;
  color: color-mix(in srgb, var(--base-color, #333) 82%, transparent);
  line-height: 1.75;
}

.role-actions,
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.role-link,
.role-card {
  display: block;
  min-height: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid color-mix(in srgb, var(--base-color, #333) 12%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--base-background-color, #fff) 96%, var(--role-accent, var(--link-color, #8b6f47)));
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
  color: var(--base-color, #333);
  text-decoration: none;
}

.markdown-section .role-link,
.markdown-section .role-card {
  text-decoration: none;
}

.role-link:hover,
.role-card:hover {
  border-color: var(--role-accent, var(--link-color, #8b6f47));
  color: var(--base-color, #333);
  transform: translateY(-1px);
}

.role-link strong,
.role-card strong {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--heading-color, #2b2b2b);
  font-size: 1.02rem;
  text-decoration: none;
}

.role-link span,
.role-card span {
  display: block;
  color: color-mix(in srgb, var(--base-color, #333) 72%, transparent);
  font-size: 0.92rem;
  line-height: 1.55;
}

.role-section-title {
  margin: 0.5rem 0 0.1rem;
  font-size: 1.15rem;
}

.role-note {
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--role-accent, var(--link-color, #8b6f47));
  border-radius: 6px;
  background: color-mix(in srgb, var(--base-background-color, #fff) 90%, var(--role-accent, var(--link-color, #8b6f47)));
  color: color-mix(in srgb, var(--base-color, #333) 82%, transparent);
}

#switch-user-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 999;
  max-width: min(220px, calc(100vw - 36px));
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  background: var(--base-background-color, #fff);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  color: var(--base-color, #333);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#switch-user-button:hover {
  border-color: gray;
  color: gray;
}

#switch-user-button .switch-user-action {
  display: none;
}

#switch-user-button:hover .switch-user-action,
#switch-user-button:focus-visible .switch-user-action {
  display: inline;
}

#switch-user-button:hover .switch-user-label,
#switch-user-button:focus-visible .switch-user-label {
  display: none;
}

@media (max-width: 640px) {
  .content {
    left: 0;
    padding-top: 0;
  }

  .markdown-section {
    max-width: 100vw;
    padding: 1.05rem 0.95rem 5rem;
  }

  .markdown-section h1 {
    font-size: 1.65rem;
  }

  .markdown-section h2 {
    font-size: 1.35rem;
  }

  .markdown-section h3 {
    font-size: 1.15rem;
  }

  .markdown-section p,
  .markdown-section li {
    line-height: 1.75;
  }

  .markdown-section ul,
  .markdown-section ol {
    padding-left: 1.2rem;
  }

  .markdown-section blockquote {
    margin-left: 0;
    padding: 0.15rem 0 0.15rem 0.85rem;
  }

  .markdown-section blockquote blockquote {
    margin-left: 0.35rem;
    padding-left: 0.65rem;
  }

  .markdown-section img {
    width: auto;
    max-height: 78vh;
    object-fit: contain;
  }

  .markdown-section table {
    width: 100%;
    margin: 0.85rem 0;
    font-size: 0.9rem;
  }

  .markdown-section th,
  .markdown-section td {
    padding: 0.55rem 0.65rem;
  }

  .katex-display {
    font-size: 0.92rem;
  }

  .markdown-section pre {
    margin-right: 0;
    margin-left: 0;
    padding: 0.85rem;
    font-size: 0.86rem;
    line-height: 1.55;
  }

  .markdown-section pre code {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .role-hero {
    padding: 1.1rem;
  }

  .role-home {
    gap: 1rem;
    margin-bottom: 4rem;
  }

  .role-hero h1 {
    font-size: 1.55rem;
  }

  .role-hero p,
  .role-link span,
  .role-card span,
  .role-note {
    line-height: 1.65;
  }

  .role-link,
  .role-card {
    padding: 0.9rem;
  }

  .role-actions,
  .role-grid {
    grid-template-columns: 1fr;
  }

  #theme-selector {
    top: 8px;
    right: 10px;
    max-width: calc(100vw - 88px);
    padding: 7px 9px;
    font-size: 15px;
  }

  #switch-user-button {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
    padding: 9px 11px;
    font-size: 13px;
  }
}
