:root {
  --ink: #192321;
  --muted: #68726e;
  --paper: #f4f0e8;
  --surface: #fbf9f4;
  --white: #fffefa;
  --line: #d9d4c9;
  --deep: #123d39;
  --teal: #216a63;
  --lime: #a8bf46;
  --amber: #d79246;
  --coral: #c9705c;
  --blue: #4f83a1;
  --shadow: 0 22px 60px rgba(25, 35, 33, 0.09);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(168, 191, 70, 0.08), transparent 24rem),
    var(--paper);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, select { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(33, 106, 99, 0.25);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 62px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 249, 244, 0.88);
  backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--deep);
  font-size: 1.15rem;
}
.brand small, .brand strong { display: block; }
.brand small { margin-bottom: 1px; color: var(--muted); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; }
.brand strong { font-size: 0.98rem; }
.button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--deep);
  border-radius: 99px;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}
.button:hover { color: white; background: var(--deep); }

main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: clamp(34px, 6vw, 80px) 0 70px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr); gap: 48px; align-items: end; margin-bottom: clamp(30px, 5vw, 58px); }
.eyebrow { margin: 0 0 9px; color: var(--teal); font-size: 0.66rem; font-weight: 750; letter-spacing: 0.16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 6vw, 5.9rem);
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: -0.055em;
}
h1 em { color: var(--teal); font-weight: 400; }
.hero-intro { max-width: 500px; margin: 0 0 4px; color: var(--muted); font-size: clamp(0.95rem, 1.3vw, 1.08rem); line-height: 1.7; }

.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: stretch; }
.egogram-card, .reflection-card, .theory {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.egogram-card { min-width: 0; padding: clamp(20px, 3vw, 34px); }
.card-head { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.card-head h2, .reflection-card h2, .theory-intro h2 { margin-bottom: 0; font-family: Georgia, serif; font-weight: 400; }
.card-head h2 { font-size: clamp(1.6rem, 2.7vw, 2.25rem); }
.preset-control { display: grid; gap: 5px; }
.preset-control span { color: var(--muted); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.preset-control select { min-width: 190px; height: 40px; padding: 0 34px 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); }

.chart {
  position: relative;
  height: clamp(370px, 48vw, 510px);
  min-height: 340px;
  padding: 16px 10px 58px 54px;
  border-radius: 7px;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), rgba(25, 35, 33, 0.095) 25%),
    #eeebe3;
  overflow: hidden;
}
.chart::after { content: ""; position: absolute; right: 10px; bottom: 57px; left: 53px; height: 2px; background: var(--ink); }
.scale { position: absolute; top: 14px; bottom: 56px; left: 10px; display: flex; flex-direction: column; justify-content: space-between; color: #8b918d; font-size: 0.56rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.bars { position: relative; z-index: 1; display: grid; height: 100%; grid-template-columns: repeat(5, minmax(64px, 1fr)); gap: clamp(8px, 2.3vw, 34px); }
.bar-control { position: relative; display: grid; height: 100%; min-width: 0; grid-template-rows: minmax(0, 1fr) 68px; justify-items: center; }
.bar-track { position: relative; width: min(78%, 84px); height: 100%; align-self: end; }
.bar-fill {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--value);
  border: 2px solid color-mix(in srgb, var(--bar-color), #192321 18%);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: color-mix(in srgb, var(--bar-color), white 77%);
  transition: height 120ms ease;
}
.bar-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, rgba(255,255,255,.35), transparent 55%); }
.bar-value {
  position: absolute;
  z-index: 2;
  top: clamp(28px, calc(100% - var(--value)), calc(100% - 5px));
  left: 50%;
  width: 38px;
  height: 20px;
  transform: translate(-50%, -115%);
  border-radius: 99px;
  color: white;
  background: var(--bar-color);
  pointer-events: none;
  transition: top 120ms ease;
}
.bar-value::after { content: "•••"; display: block; color: white; font-size: 0.56rem; line-height: 16px; letter-spacing: 1px; text-align: center; }
.bar-control input[type="range"] {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  width: 100%;
  height: 100%;
  margin: 0;
  transform: translateX(-50%);
  direction: rtl;
  writing-mode: vertical-lr;
  -webkit-appearance: slider-vertical;
  opacity: 0;
  cursor: ns-resize;
}
.bar-control:focus-within .bar-fill { box-shadow: 0 0 0 4px color-mix(in srgb, var(--bar-color), transparent 72%); }
.bar-label { width: 100%; min-width: 0; align-self: stretch; padding-top: 7px; text-align: center; }
.bar-label strong { display: block; color: var(--bar-color); font-size: clamp(1rem, 2vw, 1.45rem); line-height: 1.05; letter-spacing: 0.02em; }
.bar-label small { display: block; max-width: 112px; margin: 3px auto 0; color: var(--muted); font-size: clamp(0.55rem, 0.8vw, 0.67rem); line-height: 1.2; overflow-wrap: break-word; hyphens: auto; }
.chart-notes { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; margin-top: 15px; }
.chart-notes p { display: flex; align-items: center; gap: 9px; min-height: 44px; margin: 0; padding: 8px 11px; border-radius: 5px; color: var(--muted); font-size: 0.68rem; line-height: 1.35; }
.score-note { background: #ebe7d9; }
.chart-hint { border: 1px solid var(--line); }
.chart-notes p > span:first-child { display: grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--teal); font-size: 0.64rem; font-weight: 750; }
.score-note strong { color: var(--ink); }

.reflection-card { display: flex; min-height: 420px; flex-direction: column; padding: 29px 25px 25px; color: white; background: var(--deep); }
.reflection-card .eyebrow { color: #cbd990; }
.reflection-symbol { display: grid; width: 62px; height: 62px; margin: 16px 0 24px; place-items: center; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; font-family: Georgia, serif; font-size: 1.7rem; }
.reflection-card h2 { margin-bottom: 13px; font-size: 1.65rem; line-height: 1.08; }
.reflection-card > p:not(.eyebrow) { margin-bottom: 28px; color: rgba(255,255,255,.72); font-size: 0.82rem; line-height: 1.6; }
.reflection-question { display: flex; gap: 11px; margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.18); }
.reflection-question > span { display: grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--deep); background: #cbd990; font-weight: 750; }
.reflection-question strong { font-size: 0.72rem; }
.reflection-question p { margin: 5px 0 0; color: rgba(255,255,255,.68); font-size: 0.69rem; line-height: 1.48; }

.theory { margin-top: 18px; overflow: hidden; }
.theory-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 25px; padding: 23px clamp(20px, 3vw, 34px); border: 0; background: transparent; text-align: left; cursor: pointer; }
.toggle-label .eyebrow, .toggle-label strong { display: block; }
.toggle-label .eyebrow { margin-bottom: 6px; }
.toggle-label strong { font-family: Georgia, serif; font-size: clamp(1.25rem, 2.3vw, 1.75rem); font-weight: 400; }
.toggle-action { display: flex; align-items: center; gap: 13px; color: var(--teal); font-size: 0.72rem; font-weight: 750; white-space: nowrap; }
.toggle-action i { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 1.2rem; font-style: normal; transition: transform 220ms ease; }
.theory-toggle[aria-expanded="true"] .toggle-action i { transform: rotate(180deg); }
.theory-panel { padding: 0 clamp(20px, 3vw, 34px) 32px; border-top: 1px solid var(--line); }
.theory-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 380px); gap: clamp(35px, 7vw, 90px); align-items: center; padding: 35px 0; }
.theory-intro h2 { margin-bottom: 13px; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.theory-intro p:not(.eyebrow) { max-width: 680px; margin-bottom: 0; color: var(--muted); line-height: 1.72; }
.pac-model { display: grid; grid-template-columns: 1fr; justify-self: stretch; padding: 20px 24px; border-radius: 7px; background: #ebe7de; }
.pac-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 13px; align-items: center; }
.pac-row b { font-family: Georgia, serif; font-size: 1.08rem; font-weight: 400; }
.pac-row small { color: var(--muted); font-size: 0.68rem; font-weight: 750; }
.pac-node { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: white; background: var(--deep); font-family: Georgia, serif; font-size: 1.2rem; }
.pac-node.adult { background: var(--teal); }
.pac-node.child { color: var(--ink); background: #cbd990; }
.pac-line { width: 1px; height: 12px; margin-left: 23px; background: #b9b4aa; }
.position-list { display: grid; border-top: 1px solid var(--line); }
.position-item { border-bottom: 1px solid var(--line); }
.position-item button { display: grid; width: 100%; grid-template-columns: 64px minmax(0, 0.8fr) minmax(0, 1.45fr) 30px; gap: 18px; align-items: center; padding: 18px 7px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.position-code { display: grid; width: 46px; height: 46px; place-items: center; border: 2px solid var(--item-color); border-radius: 50%; color: var(--item-color); font-weight: 750; }
.position-name strong, .position-name small { display: block; }
.position-name strong { font-family: Georgia, serif; font-size: 1.05rem; font-weight: 400; }
.position-name small { margin-top: 3px; color: var(--muted); font-size: 0.64rem; }
.position-summary { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.position-chevron { color: var(--item-color); font-size: 1.2rem; transition: transform 180ms ease; }
.position-item button[aria-expanded="true"] .position-chevron { transform: rotate(45deg); }
.position-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 0 7px 22px 89px; }
.position-detail[hidden] { display: none; }
.position-detail div { padding: 16px; border-radius: 5px; background: #efebe3; }
.position-detail strong { display: block; margin-bottom: 5px; color: var(--item-color); font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; }
.position-detail p { margin-bottom: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.55; }
.position-example {
  position: relative;
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px 18px 16px 50px;
  border-left: 3px solid var(--item-color);
  border-radius: 0 5px 5px 0;
  background: color-mix(in srgb, var(--item-color), white 91%);
}
.position-example::before {
  content: "“";
  position: absolute;
  top: 5px;
  left: 16px;
  color: var(--item-color);
  font-family: Georgia, serif;
  font-size: 2.4rem;
  line-height: 1;
}
.position-example p { color: var(--ink); font-family: Georgia, serif; font-size: 1rem; font-style: italic; }
.theory-note { display: flex; align-items: center; justify-content: space-between; gap: 35px; padding-top: 28px; }
.theory-note p { max-width: 760px; margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.55; }
.theory-note a { flex: 0 0 auto; color: var(--teal); font-size: 0.72rem; font-weight: 750; text-decoration: none; }
.theory-note a:hover { text-decoration: underline; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 10; padding: 11px 15px; border-radius: 5px; color: white; background: var(--deep); font-size: 0.74rem; opacity: 0; transform: translateY(10px); pointer-events: none; transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .tool-layout { grid-template-columns: 1fr; }
  .reflection-card { min-height: 300px; }
  .theory-intro { grid-template-columns: 1fr; }
  .pac-model { max-width: 520px; justify-self: stretch; }
}

@media (max-width: 620px) {
  .topbar { min-height: 70px; gap: 10px; padding-right: 12px; padding-left: 12px; }
  .brand-mark { width: 37px; height: 37px; }
  .brand { min-width: 0; gap: 9px; }
  .brand > span:last-child { min-width: 0; }
  .brand small { display: none; }
  .brand strong { font-size: 0.9rem; white-space: nowrap; }
  .button-quiet { padding: 0 11px; font-size: 0.72rem; }
  main { width: min(100% - 24px, 1240px); padding-top: 34px; }
  h1 { font-size: clamp(2.65rem, 14vw, 4rem); }
  .card-head { align-items: start; flex-direction: column; }
  .preset-control, .preset-control select { width: 100%; }
  .chart { height: 410px; padding-right: 5px; padding-left: 36px; }
  .chart::after { right: 5px; left: 35px; }
  .scale { left: 7px; }
  .bars { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .bar-track { width: min(74%, 62px); }
  .bar-value { width: 31px; height: 18px; }
  .bar-value::after { line-height: 14px; }
  .bar-label strong { font-size: clamp(0.92rem, 6vw, 1.15rem); }
  .bar-label small { max-width: 58px; font-size: 0.5rem; }
  .chart-notes { grid-template-columns: 1fr; }
  .chart-notes p { align-items: flex-start; }
  .score-note > span:last-child { min-width: 0; overflow-wrap: anywhere; }
  .theory-toggle { align-items: end; }
  .toggle-action > span { display: none; }
  .position-item button { grid-template-columns: 48px 1fr 28px; gap: 10px; }
  .position-summary { display: none; }
  .position-detail { grid-template-columns: 1fr; padding-left: 65px; }
  .theory-note { align-items: start; flex-direction: column; }
}

@media (max-width: 370px) {
  .button-quiet { min-height: 36px; padding: 0 9px; font-size: 0.66rem; }
  .egogram-card { padding-right: 12px; padding-left: 12px; }
  .chart { padding-left: 32px; }
  .chart::after { left: 31px; }
  .scale { left: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
