:root{
  --bg: #f5fbff;
  --bg-soft: #edf7fb;
  --surface: rgba(255,255,255,0.82);
  --surface-strong: #ffffff;
  --surface-dark: #0d2430;
  --text: #10212b;
  --text-soft: #46606f;
  --text-inverse: #f5fbff;
  --line: rgba(16,33,43,0.10);
  --line-strong: rgba(16,33,43,0.18);

  --brand-900: #072737;
  --brand-800: #0b3f55;
  --brand-700: #0f5f7c;
  --brand-600: #167ea2;
  --brand-500: #1c9cc3;
  --brand-400: #50bddb;
  --brand-300: #8ad8ee;
  --brand-200: #c9f0fb;

  --accent-1: #00a6c7;
  --accent-2: #1c73c9;
  --accent-3: #6ce0ff;
  --accent-warm: #f4b860;

  --success: #0d8b6a;
  --warning: #b87211;
  --danger: #c63b3b;

  --shadow-sm: 0 8px 22px rgba(10, 37, 64, 0.06);
  --shadow-md: 0 16px 40px rgba(10, 37, 64, 0.10);
  --shadow-lg: 0 24px 60px rgba(8, 28, 48, 0.16);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-xl: 34px;
  --radius-pill: 999px;

  --content: 1200px;
  --content-narrow: 840px;
  --header-h: 76px;

  --font-sans: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --font-en: Inter, "Helvetica Neue", Arial, sans-serif;

  --step--1: clamp(0.84rem, 0.80rem + 0.2vw, 0.95rem);
  --step-0: clamp(1rem, 0.96rem + 0.25vw, 1.08rem);
  --step-1: clamp(1.15rem, 1.02rem + 0.55vw, 1.35rem);
  --step-2: clamp(1.35rem, 1.12rem + 1vw, 1.75rem);
  --step-3: clamp(1.75rem, 1.35rem + 1.8vw, 2.6rem);
  --step-4: clamp(2.2rem, 1.6rem + 3vw, 4rem);

  --space-1: 0.35rem;
  --space-2: 0.55rem;
  --space-3: 0.8rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3.5rem;
  --space-10: 5rem;

  --hero-overlay: linear-gradient(180deg, rgba(7,39,55,0.62), rgba(7,39,55,0.38) 45%, rgba(7,39,55,0.74));
  --soft-gradient: radial-gradient(circle at top left, rgba(138,216,238,0.40), transparent 45%),
                   radial-gradient(circle at bottom right, rgba(28,115,201,0.16), transparent 40%),
                   linear-gradient(180deg, #f7fcff 0%, #edf7fb 100%);
}

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

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

body{
  margin:0;
  font-family:var(--font-sans);
  font-size:var(--step-0);
  line-height:1.75;
  color:var(--text);
  background:var(--soft-gradient);
  text-rendering:optimizeLegibility;
}

body.lang-en{
  font-family:var(--font-en), var(--font-sans);
}

body.nav-open{
  overflow:hidden;
}

img,
svg,
video{
  max-width:100%;
  display:block;
}

picture{
  display:block;
}

a{
  color:var(--brand-700);
  text-decoration:none;
  transition:color .2s ease, opacity .2s ease, transform .2s ease;
}

a:hover{
  color:var(--brand-500);
}

p,
ul,
ol,
blockquote{
  margin:0 0 1em;
}

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

h1,h2,h3,h4,h5,h6{
  margin:0 0 0.55em;
  line-height:1.15;
  color:var(--brand-900);
  letter-spacing:-0.02em;
}

h1{ font-size:var(--step-4); }
h2{ font-size:var(--step-3); }
h3{ font-size:var(--step-2); }
h4{ font-size:var(--step-1); }

small,
.meta,
.eyebrow{
  font-size:var(--step--1);
}

.serif{
  font-family:var(--font-serif);
}

.container{
  width:min(calc(100% - 1.5rem), var(--content));
  margin-inline:auto;
}

.container.narrow{
  width:min(calc(100% - 1.5rem), var(--content-narrow));
}

.section{ padding:var(--space-9) 0; }
.section-tight{ padding:var(--space-8) 0; }
.section-compact{ padding:var(--space-7) 0; }

.stack > * + *{
  margin-top:var(--space-5);
}

.cluster{
  display:flex;
  flex-wrap:wrap;
  gap:var(--space-3);
}

.grid{
  display:grid;
  gap:var(--space-5);
}

.grid-2{ grid-template-columns:repeat(2, minmax(0,1fr)); }
.grid-3{ grid-template-columns:repeat(3, minmax(0,1fr)); }
.grid-4{ grid-template-columns:repeat(4, minmax(0,1fr)); }

@media (max-width: 980px){
  .grid-4{ grid-template-columns:repeat(2, minmax(0,1fr)); }
  .grid-3{ grid-template-columns:repeat(2, minmax(0,1fr)); }
}

@media (max-width: 640px){
  .grid-2,
  .grid-3,
  .grid-4{
    grid-template-columns:1fr;
  }
}

.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* Header */

.site-header{
  position:sticky;
  top:0;
  z-index:1000;
  min-height:var(--header-h);
  backdrop-filter: blur(18px);
  background:rgba(247,252,255,0.92);
  border-bottom:1px solid rgba(16,33,43,0.08);
}

.site-header.scrolled{
  box-shadow:var(--shadow-sm);
  background:rgba(255,255,255,0.96);
}

.header-inner{
  min-height:var(--header-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:var(--space-4);
}

.logo{
  display:inline-flex;
  align-items:center;
  gap:0.75rem;
  font-weight:800;
  letter-spacing:-0.02em;
  color:var(--brand-900);
}

.logo-mark{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:50%;
  background:linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color:#fff;
  box-shadow:var(--shadow-sm);
  flex:0 0 auto;
}

.logo-text{
  display:flex;
  flex-direction:column;
  line-height:1.05;
}

.logo-text strong{
  font-size:1.02rem;
}

.logo-text span{
  font-size:0.72rem;
  color:var(--text-soft);
  font-weight:600;
}

.site-nav{
  display:flex;
  align-items:center;
  gap:1rem;
}

.nav-list{
  list-style:none;
  display:flex;
  align-items:center;
  gap:0.4rem;
  margin:0;
  padding:0;
}

.nav-list a,
.nav-list button.nav-link{
  border:0;
  background:none;
  font:inherit;
  color:var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:44px;
  padding:0.6rem 0.9rem;
  border-radius:var(--radius-pill);
  cursor:pointer;
  font-weight:700;
}

.nav-list a:hover,
.nav-list button.nav-link:hover,
.nav-list a.active{
  color:var(--brand-700);
  background:rgba(28,156,195,0.08);
}

.header-actions{
  display:flex;
  align-items:center;
  gap:0.65rem;
}

.lang-switch,
.theme-toggle,
.search-toggle,
.nav-toggle{
  min-width:44px;
  min-height:44px;
  border-radius:50%;
  border:1px solid var(--line);
  background:rgba(255,255,255,0.88);
  color:var(--brand-900);
  display:grid;
  place-items:center;
  cursor:pointer;
  transition:transform .2s ease, background .2s ease, border-color .2s ease;
}

.lang-switch:hover,
.theme-toggle:hover,
.search-toggle:hover,
.nav-toggle:hover{
  transform:translateY(-1px);
  background:#fff;
  border-color:var(--line-strong);
}

.lang-switch{
  width:auto;
  min-width:unset;
  padding:0 0.9rem;
  border-radius:var(--radius-pill);
  font-weight:800;
}

.nav-toggle{
  display:none;
}

@media (max-width: 980px){
  .nav-toggle{ display:grid; }

  .site-nav{
    position:fixed;
    inset:var(--header-h) 0 auto 0;
    background:rgba(250,254,255,0.98);
    backdrop-filter:blur(16px);
    border-bottom:1px solid var(--line);
    box-shadow:var(--shadow-md);
    padding:1rem;
    transform:translateY(-120%);
    opacity:0;
    pointer-events:none;
    transition:transform .28s ease, opacity .28s ease;
  }

  body.nav-open .site-nav{
    transform:translateY(0);
    opacity:1;
    pointer-events:auto;
  }

  .nav-list{
    width:100%;
    flex-direction:column;
    align-items:stretch;
  }

  .nav-list li{
    width:100%;
  }

  .nav-list a,
  .nav-list button.nav-link{
    width:100%;
    justify-content:flex-start;
    border-radius:var(--radius-md);
    padding:0.9rem 1rem;
  }
}

/* Hero */

.hero{
  position:relative;
  overflow:hidden;
  color:var(--text-inverse);
  background:
    var(--hero-overlay),
    linear-gradient(120deg, rgba(7,39,55,0.85), rgba(15,95,124,0.72));
}

.hero.has-image{
  min-height:clamp(520px, 72vh, 860px);
}

.hero-media{
  position:absolute;
  inset:0;
  z-index:0;
}

.hero-media img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.hero::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:0;
  background:linear-gradient(180deg, rgba(0,0,0,.30), rgba(0,0,0,.20) 40%, rgba(0,0,0,.42));
}

.hero::after{
  content:"";
  position:absolute;
  inset:auto 0 0 0;
  height:140px;
  background:linear-gradient(180deg, transparent, rgba(0,0,0,0.10));
  pointer-events:none;
}

.hero-inner{
  position:relative;
  z-index:1;
  min-height:inherit;
  display:flex;
  align-items:flex-end;
  padding:clamp(5rem, 12vh, 8rem) 0 3rem;
}

.hero-copy{
  width:min(100%, 760px);
}

.hero .eyebrow{
  display:inline-flex;
  align-items:center;
  gap:0.55rem;
  text-transform:uppercase;
  letter-spacing:0.12em;
  font-weight:800;
  color:rgba(255,255,255,0.88);
  margin-bottom:1rem;
}

.hero h1,
.hero h2,
.hero p,
.hero li{
  color:#fff;
}

.hero h1{
  margin-bottom:0.55rem;
  text-shadow:0 2px 10px rgba(0,0,0,.35);
}

.hero-lead{
  font-size:clamp(1.05rem, 0.98rem + 0.4vw, 1.25rem);
  max-width:62ch;
  color:rgba(255,255,255,0.96);
  text-shadow:0 2px 10px rgba(0,0,0,.28);
}

.hero-actions{
  display:flex;
  flex-wrap:wrap;
  gap:0.75rem;
  margin-top:1.2rem;
}

.hero-meta{
  display:flex;
  flex-wrap:wrap;
  gap:0.6rem;
  margin-top:1.2rem;
}

.hero-meta span{
  background:rgba(255,255,255,0.14);
  border:1px solid rgba(255,255,255,0.18);
  padding:0.45rem 0.8rem;
  border-radius:var(--radius-pill);
  font-size:0.92rem;
  font-weight:700;
  backdrop-filter:blur(10px);
  color:#fff;
}

/* Buttons */

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:0.55rem;
  min-height:48px;
  padding:0.8rem 1.1rem;
  border-radius:var(--radius-pill);
  border:1px solid transparent;
  font-weight:800;
  line-height:1;
  cursor:pointer;
  text-decoration:none;
  transition:transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
}

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

.btn-primary{
  color:#fff;
  background:linear-gradient(135deg, var(--brand-700), var(--brand-500));
  box-shadow:var(--shadow-sm);
}

.btn-primary:hover{
  color:#fff;
  box-shadow:var(--shadow-md);
}

.btn-secondary{
  color:var(--brand-900);
  background:rgba(255,255,255,0.94);
  border-color:rgba(255,255,255,0.25);
}

.btn-secondary:hover{
  color:var(--brand-900);
  background:#fff;
}

.btn-outline{
  color:var(--brand-800);
  background:transparent;
  border-color:var(--line-strong);
}

.btn-ghost{
  color:var(--brand-700);
  background:rgba(28,156,195,0.08);
}

.btn-small{
  min-height:40px;
  padding:0.65rem 0.9rem;
  font-size:0.92rem;
}

/* Cards */

.card{
  background:var(--surface);
  border:1px solid rgba(255,255,255,0.45);
  box-shadow:var(--shadow-sm);
  border-radius:var(--radius-lg);
  overflow:hidden;
  backdrop-filter:blur(12px);
}

.card-body{ padding:1.15rem; }
.card-title{ margin-bottom:0.45rem; }
.card p:last-child{ margin-bottom:0; }

.card-media{
  aspect-ratio:16 / 10;
  overflow:hidden;
  background:linear-gradient(180deg, #dff4fb, #cfeaf7);
}

.card-media img{
  width:100%;
  height:100%;
  object-fit:cover;
  transition:transform .5s ease;
}

.card:hover .card-media img{
  transform:scale(1.04);
}

.card-link{
  display:flex;
  flex-direction:column;
  height:100%;
  color:inherit;
}

.card-link:hover{
  color:inherit;
}

.feature-card{
  position:relative;
  overflow:hidden;
  background:linear-gradient(180deg, rgba(11,63,85,0.90), rgba(7,39,55,0.95));
  color:#fff;
  border-radius:var(--radius-xl);
  padding:1.35rem;
  box-shadow:var(--shadow-md);
}

.feature-card h3,
.feature-card p,
.feature-card a{
  color:#fff;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:0.4rem;
  min-height:32px;
  padding:0.3rem 0.7rem;
  border-radius:var(--radius-pill);
  background:rgba(28,156,195,0.10);
  color:var(--brand-800);
  font-size:0.84rem;
  font-weight:800;
  border:1px solid rgba(28,156,195,0.15);
}

.badge.light{
  color:#fff;
  background:rgba(255,255,255,0.12);
  border-color:rgba(255,255,255,0.16);
}

/* Intro blocks */

.section-head{
  display:flex;
  flex-wrap:wrap;
  align-items:end;
  justify-content:space-between;
  gap:1rem;
  margin-bottom:1.4rem;
}

.section-head p{
  max-width:65ch;
  color:var(--text-soft);
}

.eyebrow{
  display:inline-block;
  text-transform:uppercase;
  letter-spacing:0.14em;
  font-weight:800;
  color:var(--brand-600);
  margin-bottom:0.6rem;
}

/* Article pages */

.article-shell{
  display:grid;
  grid-template-columns:minmax(0, 1fr) 290px;
  gap:2rem;
}

.article-main{
  min-width:0;
}

.article-sidebar{
  position:sticky;
  top:calc(var(--header-h) + 1rem);
  align-self:start;
}

@media (max-width: 980px){
  .article-shell{
    grid-template-columns:1fr;
  }

  .article-sidebar{
    position:static;
  }
}

.article-card{
  background:rgba(255,255,255,0.92);
  border:1px solid rgba(255,255,255,0.52);
  border-radius:var(--radius-xl);
  box-shadow:var(--shadow-sm);
  padding:clamp(1.1rem, 1rem + 0.8vw, 2rem);
  color:#1a1a1a;
}

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

.article-card h2,
.article-card h3{
  scroll-margin-top:calc(var(--header-h) + 18px);
}

.article-card p,
.article-card li{
  color:#1a1a1a;
}

.article-card .lead{
  font-size:1.08rem;
  color:#3d5360;
}

.article-card table{
  width:100%;
  border-collapse:collapse;
  margin:1.2rem 0;
  overflow:hidden;
  border-radius:var(--radius-md);
  background:#fff;
}

.article-card th,
.article-card td{
  text-align:left;
  padding:0.85rem 0.9rem;
  border-bottom:1px solid var(--line);
  vertical-align:top;
}

.article-card th{
  background:#f3fbff;
  color:var(--brand-900);
}

.article-card blockquote{
  margin:1.4rem 0;
  padding:1rem 1.1rem;
  border-left:4px solid var(--brand-500);
  background:#f4fbfe;
  border-radius:0 var(--radius-md) var(--radius-md) 0;
}

.article-card figure{
  margin:1.5rem 0;
}

.article-card figcaption{
  margin-top:0.55rem;
  color:#4b616e;
  font-size:var(--step--1);
}

/* Sidebar nav */

.toc{
  background:rgba(255,255,255,0.92);
  border:1px solid rgba(255,255,255,0.54);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  padding:1rem;
  color:#1a1a1a;
}

.toc h3{
  font-size:1rem;
  margin-bottom:0.8rem;
  color:#0f1720;
}

.toc ul{
  list-style:none;
  margin:0;
  padding:0;
}

.toc li + li{
  margin-top:0.25rem;
}

.toc a{
  display:block;
  padding:0.55rem 0.65rem;
  border-radius:12px;
  color:#234050;
  font-weight:700;
}

.toc a:hover,
.toc a.active{
  color:var(--brand-700);
  background:rgba(28,156,195,0.08);
}

/* Highlight stat cards */

.stats{
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr));
  gap:1rem;
}

.stat{
  background:rgba(255,255,255,0.9);
  border:1px solid rgba(255,255,255,0.54);
  border-radius:var(--radius-lg);
  padding:1rem;
  box-shadow:var(--shadow-sm);
}

.stat strong{
  display:block;
  font-size:clamp(1.5rem, 1.2rem + 1vw, 2.2rem);
  line-height:1.05;
  color:var(--brand-900);
}

.stat span{
  display:block;
  margin-top:0.4rem;
  color:var(--text-soft);
  font-weight:700;
}

@media (max-width: 980px){
  .stats{ grid-template-columns:repeat(2, minmax(0,1fr)); }
}

@media (max-width: 640px){
  .stats{ grid-template-columns:1fr; }
}

/* Filters / chips */

.chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:0.6rem;
}

.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:0.55rem 0.9rem;
  border-radius:var(--radius-pill);
  border:1px solid var(--line);
  background:rgba(255,255,255,0.74);
  color:var(--brand-900);
  font-weight:800;
  cursor:pointer;
  transition:background .2s ease, border-color .2s ease, transform .2s ease;
}

.chip:hover,
.chip.active{
  background:rgba(28,156,195,0.12);
  border-color:rgba(28,156,195,0.25);
  transform:translateY(-1px);
}

/* Search */

.search-panel{
  display:none;
  margin-top:1rem;
}

.search-panel.open{
  display:block;
}

.search-box{
  display:flex;
  gap:0.75rem;
  flex-wrap:wrap;
  padding:1rem;
  background:rgba(255,255,255,0.88);
  border:1px solid rgba(255,255,255,0.52);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
}

.search-box input,
.search-box select,
.search-box textarea{
  width:100%;
  min-height:48px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  padding:0.85rem 0.95rem;
  outline:none;
  transition:border-color .2s ease, box-shadow .2s ease, background .2s ease;
  font:inherit;
}

.search-box input:focus,
.search-box select:focus,
.search-box textarea:focus{
  border-color:rgba(28,156,195,0.55);
  box-shadow:0 0 0 4px rgba(28,156,195,0.12);
}

/* Tabs */

.tabs{
  display:flex;
  flex-wrap:wrap;
  gap:0.6rem;
  margin-bottom:1rem;
}

.tab-button{
  appearance:none;
  border:1px solid var(--line);
  background:rgba(255,255,255,0.72);
  min-height:42px;
  padding:0.6rem 0.85rem;
  border-radius:var(--radius-pill);
  font:inherit;
  font-weight:800;
  color:var(--brand-900);
  cursor:pointer;
}

.tab-button[aria-selected="true"]{
  background:linear-gradient(135deg, var(--brand-700), var(--brand-500));
  border-color:transparent;
  color:#fff;
}

.tab-panel{
  display:none;
}

.tab-panel.active{
  display:block;
}

/* Accordion */

.accordion{
  display:grid;
  gap:0.75rem;
}

.accordion-item{
  background:rgba(255,255,255,0.88);
  border:1px solid rgba(255,255,255,0.52);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}

.accordion-trigger{
  width:100%;
  border:0;
  background:none;
  text-align:left;
  padding:1rem 1.1rem;
  font:inherit;
  font-weight:800;
  color:var(--brand-900);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
  cursor:pointer;
}

.accordion-trigger span:last-child{
  flex:0 0 auto;
  font-size:1.2rem;
  color:var(--brand-600);
}

.accordion-panel{
  display:none;
  padding:0 1.1rem 1.05rem;
  color:var(--text-soft);
}

.accordion-item.open .accordion-panel{
  display:block;
}

/* Tables on mobile */

.table-wrap{
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  border-radius:var(--radius-md);
  box-shadow:inset 0 0 0 1px var(--line);
}

/* Callout */

.callout{
  padding:1rem 1.1rem;
  border-radius:var(--radius-lg);
  background:linear-gradient(180deg, rgba(28,156,195,0.12), rgba(28,156,195,0.05));
  border:1px solid rgba(28,156,195,0.16);
}

.callout strong{
  color:var(--brand-900);
}

/* Language blocks */

[data-lang]{
  display:none;
}

body.lang-ja [data-lang="ja"],
body.lang-en [data-lang="en"]{
  display:initial;
}

body.lang-ja .lang-block[data-lang="ja"],
body.lang-en .lang-block[data-lang="en"]{
  display:block;
}

body.lang-ja .lang-flex[data-lang="ja"],
body.lang-en .lang-flex[data-lang="en"]{
  display:flex;
}

body.lang-ja .lang-grid[data-lang="ja"],
body.lang-en .lang-grid[data-lang="en"]{
  display:grid;
}

/* Forms */

label{
  display:block;
  margin-bottom:0.35rem;
  font-weight:700;
  color:var(--brand-900);
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:1rem;
}

@media (max-width: 700px){
  .form-grid{
    grid-template-columns:1fr;
  }
}

/* Footer */

.site-footer{
  margin-top:var(--space-9);
  background:linear-gradient(180deg, rgba(7,39,55,0.98), rgba(6,25,37,1));
  color:rgba(255,255,255,0.88);
}

.footer-inner{
  padding:3rem 0 2rem;
}

.footer-grid{
  display:grid;
  grid-template-columns:1.2fr 1fr 1fr 1fr;
  gap:1.2rem;
}

.footer-title{
  color:#fff;
  font-size:1rem;
  margin-bottom:0.75rem;
}

.site-footer a{
  color:rgba(255,255,255,0.82);
}

.site-footer a:hover{
  color:#fff;
}

.footer-meta{
  margin-top:1.8rem;
  padding-top:1rem;
  border-top:1px solid rgba(255,255,255,0.10);
  color:rgba(255,255,255,0.62);
  font-size:0.92rem;
  display:flex;
  flex-wrap:wrap;
  justify-content:space-between;
  gap:0.75rem;
}

@media (max-width: 980px){
  .footer-grid{
    grid-template-columns:repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 640px){
  .footer-grid{
    grid-template-columns:1fr;
  }
}

/* Utility */

.center{ text-align:center; }
.text-soft{ color:var(--text-soft); }

.surface{
  background:rgba(255,255,255,0.85);
  border:1px solid rgba(255,255,255,0.52);
  border-radius:var(--radius-xl);
  box-shadow:var(--shadow-sm);
}

.pad-lg{
  padding:clamp(1rem, 0.8rem + 1vw, 2rem);
}

.mt-0{ margin-top:0 !important; }
.mb-0{ margin-bottom:0 !important; }
.mb-1{ margin-bottom:0.5rem !important; }
.mb-2{ margin-bottom:1rem !important; }
.mb-3{ margin-bottom:1.5rem !important; }
.mb-4{ margin-bottom:2rem !important; }

.reveal{
  opacity:0;
  transform:translateY(18px);
  transition:opacity .6s ease, transform .6s ease;
}

.reveal.is-visible{
  opacity:1;
  transform:none;
}

/* Back to top */

.back-to-top{
  position:fixed;
  right:1rem;
  bottom:1rem;
  z-index:999;
  width:50px;
  height:50px;
  border-radius:50%;
  border:1px solid rgba(255,255,255,0.38);
  background:linear-gradient(135deg, var(--brand-700), var(--brand-500));
  color:#fff;
  display:grid;
  place-items:center;
  box-shadow:var(--shadow-md);
  cursor:pointer;
  opacity:0;
  pointer-events:none;
  transform:translateY(10px);
  transition:opacity .2s ease, transform .2s ease;
}

.back-to-top.show{
  opacity:1;
  pointer-events:auto;
  transform:none;
}

/* Dark mode kept minimal to avoid light-on-light conflicts on story pages */

html[data-theme="dark"]{
  --bg: #071722;
  --bg-soft: #0b1f2c;
  --surface: rgba(255,255,255,0.92);
  --surface-strong: #ffffff;
  --text: #10212b;
  --text-soft: #46606f;
  --text-inverse: #f7fdff;
  --line: rgba(16,33,43,0.10);
  --line-strong: rgba(16,33,43,0.18);
  --soft-gradient: radial-gradient(circle at top left, rgba(138,216,238,0.40), transparent 45%),
                   radial-gradient(circle at bottom right, rgba(28,115,201,0.16), transparent 40%),
                   linear-gradient(180deg, #f7fcff 0%, #edf7fb 100%);
}

html[data-theme="dark"] body{
  background:var(--soft-gradient);
  color:#10212b;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6{
  color:var(--brand-900);
}

html[data-theme="dark"] .site-header{
  background:rgba(247,252,255,0.92);
  border-bottom-color:rgba(16,33,43,0.08);
}

html[data-theme="dark"] .site-header.scrolled{
  background:rgba(255,255,255,0.96);
}

html[data-theme="dark"] .logo,
html[data-theme="dark"] .nav-list a,
html[data-theme="dark"] .nav-list button.nav-link{
  color:var(--brand-900);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .article-card,
html[data-theme="dark"] .toc,
html[data-theme="dark"] .accordion-item,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .surface,
html[data-theme="dark"] .stat{
  background:rgba(255,255,255,0.92) !important;
  border-color:rgba(16,33,43,0.10) !important;
  color:#1a1a1a !important;
}

html[data-theme="dark"] .article-card p,
html[data-theme="dark"] .article-card li,
html[data-theme="dark"] .toc,
html[data-theme="dark"] .toc a,
html[data-theme="dark"] .text-soft,
html[data-theme="dark"] .article-card .lead,
html[data-theme="dark"] .section-head p,
html[data-theme="dark"] .stat span,
html[data-theme="dark"] .accordion-panel{
  color:#1a1a1a !important;
}

html[data-theme="dark"] .chip,
html[data-theme="dark"] .tab-button,
html[data-theme="dark"] .lang-switch,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .search-toggle,
html[data-theme="dark"] .nav-toggle{
  background:rgba(255,255,255,0.88);
  color:var(--brand-900);
  border-color:rgba(16,33,43,0.10);
}

html[data-theme="dark"] .article-card th{
  background:#f3fbff;
  color:var(--brand-900);
}

html[data-theme="dark"] .callout,
html[data-theme="dark"] .article-card blockquote{
  background:#f4fbfe;
}

/* Strong readability overrides for species/story pages */

.story-block,
.story-block p,
.story-block li,
.story-block ul,
.story-block ol,
.story-block blockquote,
.article-card,
.article-card p,
.article-card li,
.quickfacts div,
.quickfacts strong,
.toc,
.toc a,
.toc h3,
.quote-line{
  color:#1a1a1a !important;
}

.story-block h1,
.story-block h2,
.story-block h3,
.article-card h1,
.article-card h2,
.article-card h3,
.quickfacts strong,
.toc h3,
.quote-line{
  color:#0f1720 !important;
}

html[data-theme="dark"] .story-block,
html[data-theme="dark"] .story-block p,
html[data-theme="dark"] .story-block li,
html[data-theme="dark"] .story-block ul,
html[data-theme="dark"] .story-block ol,
html[data-theme="dark"] .story-block blockquote,
html[data-theme="dark"] .quickfacts div,
html[data-theme="dark"] .quickfacts strong,
html[data-theme="dark"] .toc,
html[data-theme="dark"] .toc a,
html[data-theme="dark"] .toc h3,
html[data-theme="dark"] .quote-line{
  color:#1a1a1a !important;
}

html[data-theme="dark"] .story-block h1,
html[data-theme="dark"] .story-block h2,
html[data-theme="dark"] .story-block h3{
  color:#0f1720 !important;
}

/* Mobile-specific hard fix */

@media (max-width: 700px){
  .hero-copy{
    background:rgba(7,39,55,0.72) !important;
    padding:1rem !important;
    border-radius:18px !important;
    backdrop-filter:blur(8px);
  }

  .hero .eyebrow,
  .hero h1,
  .hero p,
  .hero li,
  .hero-lead,
  .hero-meta span{
    color:#ffffff !important;
  }

  .story-block,
  .article-card,
  .quickfacts div,
  .toc{
    background:#ffffff !important;
  }

  .story-block,
  .story-block p,
  .story-block li,
  .story-block ul,
  .story-block ol,
  .article-card,
  .article-card p,
  .article-card li,
  .quickfacts div,
  .quickfacts strong,
  .toc,
  .toc a,
  .toc h3,
  .quote-line{
    color:#111111 !important;
    opacity:1 !important;
    text-shadow:none !important;
  }

  .story-block h1,
  .story-block h2,
  .story-block h3,
  .article-card h1,
  .article-card h2,
  .article-card h3,
  .quickfacts strong,
  .toc h3,
  .quote-line{
    color:#0b1620 !important;
  }
}
