:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --accent: #0d9488;
  --accent-soft: rgba(13, 148, 136, 0.1);
  --shadow-card: 0 12px 32px -12px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.04);
}

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

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

body {
  margin: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Compact Mosaic Header */
.doc-hero {
  background-color: #1e2433;
  background-image: linear-gradient(
      160deg,
      rgba(15, 23, 42, 0.56) 0%,
      rgba(15, 23, 42, 0.8) 100%
    ),
    url("../../images/bg.svg");
  background-position: top left, center center;
  background-repeat: no-repeat, no-repeat;
  background-size: cover, cover;
  color: #f8fafc;
}

.doc-hero-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4.25rem;
}

.doc-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f8fafc;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease,
    transform 0.18s ease;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
  transform: translateX(-2px);
}

.back-link:focus-visible,
.home-link:focus-visible,
.doc-tab:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.back-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.home-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(248, 250, 252, 0.72);
  text-decoration: none;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  transition: color 0.15s ease;
}

.home-link:hover {
  color: #ffffff;
}

.doc-identity {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  margin-top: 1.5rem;
}

.doc-app-icon {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
}

.doc-app-meta {
  min-width: 0;
}

.doc-app-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  line-height: 1.25;
}

.doc-app-sub {
  font-size: 0.82rem;
  color: rgba(248, 250, 252, 0.7);
  margin-top: 0.15rem;
}

.doc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.35rem;
}

.doc-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(248, 250, 252, 0.88);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.16s ease, border-color 0.16s ease,
    color 0.16s ease;
}

.doc-tab:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.doc-tab.is-active {
  background: #ffffff;
  border-color: #ffffff;
  color: #0f172a;
  font-weight: 600;
}

/* Main Reading Card */
.doc-main {
  max-width: 820px;
  margin: -2.5rem auto 3rem;
  padding: 0 1.25rem;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: clamp(1.75rem, 4.5vw, 3.25rem);
}

/* Legal Document Typography */
.doc-body {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.doc-body > :first-child {
  margin-top: 0;
}

.doc-body h1,
.doc-body > strong:first-child,
.doc-body .ql-container > h2:first-child {
  display: block;
  margin: 0 0 1.5rem;
  padding-top: 0;
  padding-bottom: 1rem;
  border-top: 0;
  border-bottom: 1px solid var(--border);
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text-primary);
}

.doc-body h2 {
  margin: 2.25rem 0 0.85rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 1.22rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--text-primary);
  scroll-margin-top: 1.5rem;
}

.doc-body > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.doc-body h3 {
  margin: 1.75rem 0 0.65rem;
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  scroll-margin-top: 1.5rem;
}

.doc-body h4 {
  margin: 1.4rem 0 0.5rem;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

.doc-body p {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.doc-body > p > strong:only-child {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--text-primary);
}

.doc-body strong,
.doc-body b {
  color: var(--text-primary);
  font-weight: 600;
}

.doc-body ul,
.doc-body ol {
  margin: 0.75rem 0 1.25rem;
  padding-left: 1.45rem;
}

.doc-body li {
  margin: 0.42rem 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.doc-body li::marker {
  color: var(--accent);
}

.doc-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(13, 148, 136, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

.doc-body a:hover {
  text-decoration-color: var(--accent);
}

/* Responsive Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
}

.doc-body table {
  width: 100%;
  border-collapse: collapse;
  border: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.doc-body thead th,
.doc-body tr:first-child th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.doc-body th,
.doc-body td {
  padding: 0.75rem 0.95rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-secondary);
}

.doc-body td p {
  margin: 0 0 0.5rem;
}

.doc-body td p:last-child {
  margin-bottom: 0;
}

.doc-body tbody tr:last-child td {
  border-bottom: 0;
}

.doc-body tbody tr:hover td {
  background: rgba(15, 23, 42, 0.018);
}

/* Document Footer */
.doc-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.doc-footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}

.doc-footer strong {
  color: var(--text-primary);
  font-weight: 600;
}

.doc-footer a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.doc-footer a:hover {
  border-bottom-color: var(--accent);
}

.doc-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

@media (max-width: 640px) {
  .doc-hero-inner {
    padding: 1.35rem 1rem 3.5rem;
  }

  .doc-main {
    margin: -2rem auto 2rem;
    padding: 0 0.85rem;
  }

  .doc-card {
    border-radius: 16px;
    padding: 1.4rem 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .back-link,
  .home-link,
  .doc-tab,
  .doc-body a,
  .doc-footer a {
    transition: none;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .doc-hero {
    background: none;
    color: var(--text-primary);
  }

  .doc-hero-inner {
    padding: 0 0 1rem;
  }

  .doc-topbar,
  .doc-tabs,
  .doc-footer-actions {
    display: none;
  }

  .doc-app-name {
    color: var(--text-primary);
  }

  .doc-app-sub {
    color: var(--text-muted);
  }

  .doc-main {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }

  .doc-card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
}
