:root{
  --bg: #f6f3ea;
  --bg-accent-1: rgba(82, 114, 255, 0.08);
  --bg-accent-2: rgba(128, 84, 255, 0.08);

  --panel: rgba(255,255,255,0.88);
  --panel-solid: #fffdf8;
  --text: #1d232b;
  --muted: #5f6875;
  --heading: #121821;

  --accent: #3b82f6;
  --accent-2: #7c3aed;

  --border: rgba(20, 28, 40, 0.10);
  --shadow: 0 12px 40px rgba(16, 24, 40, 0.08);
  --radius: 20px;

  --content-width: 980px;
  --reading-width: 860px;
  --font-size: 21px;
  --line-height: 1.9;
  --letter-spacing: 0.003em;

  --font-body:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --font-heading:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --toolbar-height: 58px;
  --progress-height: 4px;
}

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

body{
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top, var(--bg-accent-1), transparent 35%),
    radial-gradient(circle at right top, var(--bg-accent-2), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: var(--line-height);
  letter-spacing: var(--letter-spacing);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding-top: calc(var(--toolbar-height) + 18px);
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

::selection{
  background: rgba(59,130,246,0.18);
}

a{
  color: #1d4ed8;
  text-decoration: none;
}

a:hover{
  text-decoration: underline;
}

.site-progress{
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--progress-height);
  z-index: 9999;
  background: transparent;
  pointer-events: none;
}

.site-progress-bar{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(59,130,246,0.35);
  transition: width 90ms linear;
}

.reader-toolbar{
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  width: min(calc(100% - 20px), 980px);
  min-height: var(--toolbar-height);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: var(--shadow);
  border-radius: 18px;
  transition:
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

.reader-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.reader-btn:hover{
  transform: translateY(-1px);
}

/* GENERIC LAYOUT */
.shell{
  width: min(calc(100% - 28px), var(--content-width));
  margin-left: auto;
  margin-right: auto;
}

/* TOP HEADER */
.topbar{
  width: min(calc(100% - 28px), var(--content-width));
  margin: 0 auto 18px auto;
  padding: 14px clamp(20px, 3vw, 42px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.topbar .shell{
  width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand{
  width: 100%;
  text-align: center;
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.1vw, 2.9rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--heading);
}

.brand span{
  color: var(--accent-2);
}

.nav{
  display: none;
}

/* MAIN PANEL */
main{
  width: min(calc(100% - 28px), var(--reading-width));
  margin: 0 auto 60px auto;
  padding: 28px clamp(20px, 3vw, 42px);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: calc(var(--radius) + 2px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

h1, h2, h3, h4{
  font-family: var(--font-heading);
  color: var(--heading);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1{
  font-size: clamp(2rem, 3vw, 3rem);
  margin: 0 0 0.8em;
  font-weight: 800;
}

h2{
  font-size: clamp(1.45rem, 2vw, 1.9rem);
  margin-top: 2em;
  margin-bottom: 0.85em;
  font-weight: 750;
}

h3{
  font-size: clamp(1.18rem, 1.6vw, 1.4rem);
  margin-top: 1.75em;
  margin-bottom: 0.7em;
  font-weight: 700;
}

p{
  margin: 0 0 1.05em;
  max-width: 70ch;
}

sup{
  font-size: 0.72em;
  font-weight: 700;
  color: #6c7583;
  vertical-align: super;
  margin-right: 0.18em;
}

blockquote{
  margin: 1.5em 0;
  padding: 1em 1.1em;
  background: rgba(59,130,246,0.05);
  border-left: 4px solid rgba(59,130,246,0.18);
  border-radius: 14px;
}

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

img{
  max-width: 100%;
  height: auto;
  border-radius: 14px;
}

table{
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  border-radius: 14px;
  overflow: hidden;
}

th, td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

ul, ol{
  padding-left: 1.4em;
}

li{
  margin-bottom: 0.55em;
}

/* HERO */
.hero{
  text-align: center;
  margin: 0 auto 2.2rem auto;
}

.hero .kicker{
  min-height: 0;
  margin: 0;
}

.hero h1{
  text-align: center;
  margin: 0 auto 0.8em auto;
  max-width: 22ch;
}

.hero p{
  text-align: center;
  margin: 0 auto 0 auto;
  max-width: 60ch;
  color: var(--muted);
}

/* CARD / LIST */
.card{
  margin-top: 1.5rem;
}

.list{
  display: grid;
  gap: 14px;
}

.item{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: 0 4px 16px rgba(16,24,40,0.04);
}

.item h3{
  margin: 0 0 0.25em 0;
  font-size: 1.1rem;
}

.item h3 a{
  color: var(--heading);
}

.item h3 a:hover{
  color: var(--accent);
  text-decoration: none;
}

.meta{
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.badge{
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.badge.verbatim{
  background: rgba(34,197,94,0.10);
  border-color: rgba(34,197,94,0.25);
}

.badge.partial{
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.25);
}

.badge.hybrid{
  background: rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.25);
}

.badge.group{
  background: rgba(59,130,246,0.10);
  border-color: rgba(59,130,246,0.20);
}

/* FOOTER */
.footer{
  width: min(calc(100% - 28px), var(--content-width));
  margin: 0 auto 34px auto;
  padding: 20px clamp(20px, 3vw, 42px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.footer .shell{
  width: 100%;
  margin: 0;
  max-width: 64ch;
  text-align: center;
  color: var(--muted);
  font-size: 0.95em;
  line-height: 1.8;
}

/* CLEANUP FOR STRAY EMPTY P OR SCRIPT WRAPPERS */
body > p:empty{
  display: none;
}

body > p > script:only-child{
  display: none;
}

/* THEMES */
html[data-theme="dark"]{
  --bg: #0e131a;
  --bg-accent-1: rgba(96, 165, 250, 0.08);
  --bg-accent-2: rgba(124, 58, 237, 0.10);

  --panel: rgba(18,24,33,0.88);
  --panel-solid: #121821;
  --text: #e8edf5;
  --muted: #9ba7b7;
  --heading: #ffffff;

  --border: rgba(255,255,255,0.10);
  --shadow: 0 16px 44px rgba(0,0,0,0.35);

  --accent: #60a5fa;
  --accent-2: #8b5cf6;
}

html[data-theme="sepia"]{
  --bg: #f4ecd8;
  --bg-accent-1: rgba(139, 94, 26, 0.08);
  --bg-accent-2: rgba(120, 82, 30, 0.06);

  --panel: rgba(255,249,236,0.88);
  --panel-solid: #fff9ec;
  --text: #33281d;
  --muted: #6a5847;
  --heading: #241b13;

  --border: rgba(70,52,34,0.12);
  --shadow: 0 12px 40px rgba(60,40,20,0.10);

  --accent: #8b5e1a;
  --accent-2: #a16207;
}

html[data-theme="dark"] body,
html[data-theme="sepia"] body{
  background:
    radial-gradient(circle at top, var(--bg-accent-1), transparent 35%),
    radial-gradient(circle at right top, var(--bg-accent-2), transparent 30%),
    var(--bg);
  color: var(--text);
}

html[data-theme="dark"] main,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .footer,
html[data-theme="sepia"] main,
html[data-theme="sepia"] .topbar,
html[data-theme="sepia"] .footer{
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .reader-toolbar,
html[data-theme="sepia"] .reader-toolbar{
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .reader-btn,
html[data-theme="sepia"] .reader-btn{
  background: var(--panel-solid);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .item,
html[data-theme="sepia"] .item{
  background: var(--panel-solid);
  border-color: var(--border);
}

html[data-theme="dark"] a{
  color: #8ab4ff;
}

html[data-theme="dark"] a:hover{
  color: #b6ceff;
}

html[data-theme="dark"] sup{
  color: #8ea1bc;
}

html[data-theme="sepia"] a{
  color: #8b5e1a;
}

html[data-theme="sepia"] a:hover{
  color: #6f4913;
}

html[data-theme="sepia"] sup{
  color: #8c7358;
}

@media (max-width: 700px){
  :root{
    --font-size: 19px;
    --line-height: 1.85;
  }

  .reader-toolbar{
    width: min(calc(100% - 14px), 98vw);
    top: 6px;
    padding: 8px;
    border-radius: 14px;
  }

  .reader-btn{
    padding: 9px 10px;
    font-size: 13px;
  }

  .topbar,
  main,
  .footer{
    width: min(calc(100% - 14px), 100%);
    padding: 20px 16px;
    border-radius: 16px;
  }

  .brand{
    font-size: clamp(1.55rem, 7vw, 2.2rem);
  }

  .hero h1{
    max-width: 100%;
  }

  .hero p,
  .footer .shell{
    max-width: 100%;
  }

  .item{
    flex-direction: column;
    align-items: flex-start;
  }
}