/* ---- Variables ---- */
:root {
  --black:        #1a1a1a;
  --grey-dark:    #555555;
  --grey-mid:     #767676;
  --grey-light:   #e8e4de;
  --grey-bg:      #f5f2ee;
  --white:        #fafafa;
  --terracotta:   #c0634c;
  --beige:        #e8ddd0;
  --olive:        #6b7052;

  --font-serif: 'Noto Serif JP', '游明朝', serif;
  --font: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;

  --max-w: 1160px;
  --pad-x: 1rem;
  --pad-y: 2.5rem;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--black);
  background: var(--white);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---- Skip Link ---- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--black);
  color: var(--white);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
}

/* ---- Nav ---- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--pad-x);
  background: var(--white);
  border-bottom: 1px solid var(--grey-light);
}
.nav-brand {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  font-size: 0.8125rem;
  color: var(--grey-dark);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--black); }
.nav-signout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--grey-light);
  border-radius: 2px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--grey-mid);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.nav-signout:hover { color: var(--black); border-color: var(--grey-dark); }
#auth-email { display: none; }

/* Hamburger button */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-hamburger span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--black);
  transition: transform 0.2s, opacity 0.2s;
}

/* Drawer overlay */
.nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  z-index: 200;
  flex-direction: column;
  padding: 1.5rem var(--pad-x);
}
.nav-drawer.is-open {
  display: flex;
}
.nav-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
.nav-drawer-brand {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.nav-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--black);
  line-height: 1;
  padding: 4px 8px;
}
.nav-drawer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.nav-drawer-links li {
  border-bottom: 1px solid var(--grey-light);
}
.nav-drawer-links a {
  display: block;
  padding: 1rem 0;
  font-size: 1rem;
  color: var(--black);
  text-decoration: none;
  letter-spacing: 0.04em;
}

/* ---- Layout ---- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}
.section {
  padding: var(--pad-y) var(--pad-x);
}
.section--alt {
  background: var(--grey-bg);
}
.section-title {
  font-family: var(--font-serif);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--grey-mid);
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--grey-light);
}
.section-desc {
  margin-top: -1.25rem;
  margin-bottom: 2rem;
  font-size: 0.9375rem;
  color: var(--grey-dark);
}

/* ---- Hero ---- */
.section--hero {
  padding: 4rem var(--pad-x) 3rem;
  border-bottom: 1px solid var(--grey-light);
}
.hero-logo {
  display: block;
  width: clamp(200px, 80vw, 320px);
  margin-bottom: 2rem;
}
.hero-sub {
  font-size: 0.9375rem;
  color: var(--grey-dark);
  letter-spacing: 0.04em;
  margin-bottom: 1.25rem;
}
.hero-desc {
  max-width: 580px;
  font-size: 0.9375rem;
  color: var(--grey-dark);
  line-height: 1.85;
  margin-bottom: 2rem;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.hero-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--grey-mid);
}

/* ---- Tags ---- */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--grey-light);
  color: var(--grey-dark);
}

/* ---- Common ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
}
.block-title {
  font-family: var(--font-serif);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--grey-mid);
  margin-bottom: 1.25rem;
}
.block-title--spaced {
  margin-top: 3rem;
}
code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--grey-light);
  padding: 0.15em 0.4em;
  color: var(--black);
}
.brand-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.brand-list li {
  font-size: 0.9375rem;
  color: var(--grey-dark);
  padding-left: 1.25rem;
  position: relative;
}
.brand-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--grey-mid);
}
.brand-list--warning li::before { color: var(--terracotta); }

/* ---- Brand Section ---- */
.brand-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.brand-block {
  padding: 1.5rem;
  border: 1px solid var(--grey-light);
}
.brand-block--warning {
  border-color: var(--terracotta);
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.swatch {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: flex-end;
  padding: 0.375rem;
}
.swatch-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: rgba(255,255,255,0.82);
  line-height: 1.4;
}
.swatch--light .swatch-label {
  color: rgba(0,0,0,0.45);
}
.brand-note {
  font-size: 0.8125rem;
  color: var(--grey-mid);
}
.brand-note--spaced {
  margin-top: 1rem;
}
.type-specimens {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.type-specimen {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.type-label {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-mid);
}
/* Typography specimen variants */
.type-example--heading {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.type-example--body {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.8;
}
.brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.brand-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--grey-light);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-mid);
}
.brand-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--grey-light);
  color: var(--grey-dark);
  font-size: 0.875rem;
}
.brand-table tr:last-child td { border-bottom: none; }

/* ---- Character ---- */
.character-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}
.character-visual {
  position: static;
  text-align: center;
}
.character-img {
  width: 100%;
  max-width: 180px;
  margin: 0 auto;
}
.character-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.char-name {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.char-name-jp {
  font-size: 0.875rem;
  color: var(--grey-mid);
}
.td-label {
  color: var(--grey-mid);
  font-size: 0.8125rem;
  width: 140px;
  vertical-align: top;
}
.character-desc {
  font-size: 0.9rem;
  color: var(--grey-dark);
  line-height: 1.8;
  margin-top: 1.5rem;
}
.character-story {
  margin-top: 1.5rem;
}
.character-story p {
  font-size: 0.9rem;
  color: var(--grey-dark);
  line-height: 1.8;
  margin-bottom: 0.75rem;
}
.character-poses {
  margin-top: 2rem;
}
.pose-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.pose-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}
.pose-item img {
  width: 100%;
  max-width: 80px;
}
.pose-item span {
  font-size: 0.625rem;
  color: var(--grey-mid);
  text-align: center;
  font-family: var(--mono);
}

/* ---- Business ---- */
.business-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.business-card {
  padding: 1.5rem;
  border: 1px solid var(--grey-light);
  background: var(--white);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.business-card--primary { border-color: var(--black); }
.business-card--future { opacity: 0.55; }
.business-badge {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--grey-light);
  line-height: 1;
}
.business-card--primary .business-badge { color: var(--black); }
.business-card h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
}
.business-status {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--terracotta);
}
.business-card > p {
  font-size: 0.9rem;
  color: var(--grey-dark);
  line-height: 1.75;
}
.business-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.business-note {
  font-size: 0.8125rem;
  color: var(--grey-mid);
  border-top: 1px solid var(--grey-light);
  padding-top: 0.875rem;
  margin-top: auto;
}

/* ---- Org Chart ---- */
.org-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2.5rem;
}
.org-owner {
  display: flex;
  justify-content: center;
}
.org-connector-v {
  width: 1px;
  height: 2rem;
  background: var(--grey-light);
}
.org-agents-row {
  width: 100%;
  position: relative;
}
.org-connector-h {
  position: absolute;
  top: 0;
  left: calc(10% + 0.5px);
  right: calc(10% + 0.5px);
  height: 1px;
  background: var(--grey-light);
}
.org-agents {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.org-agent-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.org-connector-v-short {
  width: 1px;
  height: 2rem;
  background: var(--grey-light);
}
.org-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem 1rem;
  border: 1px solid var(--grey-light);
  gap: 0.25rem;
  width: 100%;
}
.org-node--owner {
  border-color: var(--black);
  min-width: 200px;
  padding: 1.5rem 2.5rem;
}
.org-node--secretary {
  border-color: var(--grey-dark);
}
.org-node--auditor {
  border-color: var(--olive);
}
.org-node-handle {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.org-node-codename {
  font-size: 1rem;
  font-weight: 600;
}
.org-node-name,
.org-node-title {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--grey-mid);
}
.org-node-role {
  font-size: 0.8125rem;
  color: var(--grey-dark);
}
.org-node-scope {
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey-mid);
  border: 1px solid var(--grey-light);
  padding: 0.15rem 0.4rem;
  margin-top: 0.25rem;
}
.org-rules {
  padding: 1.5rem;
  border: 1px solid var(--grey-light);
}

/* ---- Agents ---- */
.agents-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.agent-card {
  padding: 1.5rem;
  border: 1px solid var(--grey-light);
  background: var(--white);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.agent-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.agent-codename {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
}
.agent-name {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--grey-mid);
}
.agent-scope-badge {
  margin-left: auto;
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--grey-mid);
  border: 1px solid var(--grey-light);
  padding: 0.2rem 0.5rem;
}
.agent-role {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-weight: 500;
}
.agent-desc {
  font-size: 0.9rem;
  color: var(--grey-dark);
  line-height: 1.8;
}
.agent-character h4,
.agent-stage h4,
.agent-triggers h4 {
  font-size: 0.625rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--grey-mid);
  margin-bottom: 0.625rem;
}
.agent-character p {
  font-size: 0.875rem;
  color: var(--grey-dark);
  margin-bottom: 0.625rem;
  line-height: 1.75;
}
.agent-character blockquote {
  border-left: 2px solid var(--grey-light);
  padding-left: 1rem;
  font-size: 0.875rem;
  color: var(--grey-dark);
  font-style: italic;
  line-height: 1.9;
}
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stage-item {
  display: flex;
  gap: 1rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--grey-mid);
}
.stage-item--current {
  background: var(--grey-light);
  color: var(--black);
}
.stage-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  min-width: 72px;
  flex-shrink: 0;
}
.triggers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.trigger {
  font-size: 0.8125rem;
  padding: 0.25rem 0.625rem;
  background: var(--grey-bg);
  color: var(--grey-dark);
  border: 1px solid var(--grey-light);
}
.section--alt .trigger {
  background: var(--white);
}
.agent-note {
  font-size: 0.8125rem;
  color: var(--grey-dark);
  background: var(--beige);
  padding: 0.75rem 1rem;
  border-left: 2px solid var(--terracotta);
  line-height: 1.7;
}
.agent-note--spaced {
  margin-top: 0.5rem;
}

/* ---- Decisions ---- */
.decisions-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--grey-light);
  gap: 1px;
  background: var(--grey-light);
}
.decision {
  background: var(--white);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.decision-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.decision-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--grey-mid);
}
.decision-tag {
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.175rem 0.5rem;
  border: 1px solid var(--grey-light);
  color: var(--grey-mid);
}
.decision-tag--new {
  border-color: var(--terracotta);
  color: var(--terracotta);
}
.decision h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
}
.decision > p {
  font-size: 0.9rem;
  color: var(--grey-dark);
  line-height: 1.75;
}
.decision-reason {
  font-size: 0.8125rem;
  color: var(--grey-mid);
  font-style: italic;
}
.deadends-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.deadend {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--grey-light);
  border-left: 3px solid var(--grey-mid);
}
.deadend h4 {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--grey-mid);
  text-decoration: line-through;
  margin-bottom: 0.375rem;
}
.deadend p {
  font-size: 0.875rem;
  color: var(--grey-dark);
}

/* ---- Changelog ---- */
.changelog-list {
  border: 1px solid var(--grey-light);
  display: flex;
  flex-direction: column;
}
.changelog-entry {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--grey-light);
}
.changelog-entry:last-child { border-bottom: none; }
.changelog-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--grey-mid);
  flex-shrink: 0;
}
.changelog-event {
  font-size: 0.9rem;
  color: var(--grey-dark);
}

/* ---- Footer ---- */
.footer {
  padding: 2rem var(--pad-x);
  border-top: 1px solid var(--grey-light);
}
.footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--grey-mid);
}
.footer-handle {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--grey-dark);
}

/* ---- Responsive: tablet (768px+) ---- */
@media (min-width: 768px) {
  :root {
    --pad-x: 2rem;
    --pad-y: 3.5rem;
  }

  .nav-links      { display: flex; }
  .nav-hamburger  { display: none; }

  .section--hero  { padding: 6rem var(--pad-x) 4.5rem; }
  .hero-logo      { width: clamp(280px, 50vw, 400px); }

  .section-title  { margin-bottom: 3rem; }
  .section-desc   { margin-top: -2rem; margin-bottom: 2.5rem; }

  .character-layout {
    grid-template-columns: 200px 1fr;
    gap: 3rem;
  }
  .character-visual {
    position: sticky;
    top: 5rem;
    text-align: left;
  }
  .character-img {
    max-width: 200px;
    margin: 0;
  }

  .pose-grid      { grid-template-columns: repeat(4, 1fr); }

  .business-grid  { grid-template-columns: repeat(2, 1fr); }

  .org-agents     { grid-template-columns: repeat(3, 1fr); }
  .org-connector-h {
    left: calc(16.67% + 0.5px);
    right: calc(16.67% + 0.5px);
  }

  .agents-grid    { grid-template-columns: 1fr; }

  .changelog-entry {
    flex-direction: row;
    align-items: baseline;
    gap: 2rem;
  }
  .changelog-date { min-width: 90px; }
}

/* ---- Responsive: laptop (1024px+) ---- */
@media (min-width: 1024px) {
  :root {
    --pad-y: 4rem;
  }

  .brand-grid     { grid-template-columns: 1fr 1fr; }

  .business-grid  { grid-template-columns: repeat(3, 1fr); }

  .org-agents     { grid-template-columns: repeat(5, 1fr); }
  .org-connector-h {
    left: calc(10% + 0.5px);
    right: calc(10% + 0.5px);
  }

  .agents-grid    { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Responsive: desktop (1280px+) ---- */
@media (min-width: 1280px) {
  :root {
    --pad-y: 5rem;
  }

  .hero-logo      { width: clamp(280px, 50vw, 560px); }

  .character-layout { grid-template-columns: 260px 1fr; }
  .character-img  { max-width: 240px; }

  .pose-grid      { grid-template-columns: repeat(6, 1fr); }
}

/* ---- Mobile nav (< 768px) ---- */
@media (max-width: 767px) {
  .nav-links      { display: none; }
  .nav-hamburger  { display: flex; }
}
