:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #fffdf8;
  --text: #222621;
  --muted: #686d66;
  --line: #d9d2c4;
  --accent: #315b57;
  --accent-strong: #234440;
  --danger: #9f3f35;
  --success: #376d4e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(247, 244, 238, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand,
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(#f2b84b, #71a96b, #5f8fc8, #7b70b3, #5f7892, #7b9a54, #c65d4b, #d88a3d, #f2b84b);
}

.nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.94rem;
}

.nav a,
.link-button,
.back-link {
  color: var(--accent);
  text-decoration: none;
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px);
}

.tool-header,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.split-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  margin-top: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.15rem;
}

.muted,
small {
  color: var(--muted);
}

.primary-button,
.search-form button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.primary-button:hover,
.search-form button:hover {
  background: var(--accent-strong);
}

.wheel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.petal-panel {
  margin: 24px 0;
}

.selector-heading {
  margin-bottom: 12px;
}

.selector-heading h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.selector-heading p {
  margin: 0;
  color: var(--muted);
}

.petal-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.family-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 4px 2px 10px;
}

.family-strip-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.family-strip-link i {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--family-color);
}

.family-strip-link.selected {
  border-color: var(--family-color);
  background: color-mix(in srgb, var(--family-color) 14%, var(--panel));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--family-color) 24%, transparent);
}

.family-petal {
  min-height: 118px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.family-petal {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  padding: 16px;
  border-top: 5px solid var(--family-color);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--family-color) 12%, transparent), transparent 46%),
    var(--panel);
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.family-petal:hover,
.family-petal:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(34, 38, 33, 0.12);
}

.family-petal strong {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.12rem;
  font-weight: 850;
}

.family-petal i {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--family-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--family-color) 20%, transparent);
}

.family-petal small {
  color: var(--muted);
  line-height: 1.35;
}

.family-tile,
.emotion-card,
.auth-panel,
.detail,
.entry-list a,
.split-layout > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.family-tile {
  min-height: 132px;
  padding: 16px;
  text-decoration: none;
  border-top: 5px solid var(--family-color);
}

.family-tile span {
  display: block;
  margin-bottom: 8px;
  font-size: 1.12rem;
  font-weight: 800;
}

.family-tile small {
  display: block;
  line-height: 1.4;
}

.split-layout > div,
.auth-panel,
.detail {
  padding: 20px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-row a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-form input,
.form-stack input,
.entry-form input,
.entry-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

.emotion-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-left: 6px solid var(--family-color);
}

.emotion-save-link {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.emotion-mode-form {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.emotion-mode-form label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.emotion-mode-form select {
  min-height: 36px;
  padding: 7px 34px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  font: inherit;
  font-weight: 800;
}

.selection-helper {
  max-width: 720px;
  margin: -2px auto 14px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 650;
  text-align: center;
}

.compact-emotion-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.44fr);
  gap: 14px;
  align-items: start;
}

.human-emotion-picker {
  display: block;
}

.compact-node-list,
.compact-group {
  display: grid;
  gap: 8px;
}

.human-emotion-picker .compact-node-list {
  max-width: 760px;
  margin: 0 auto;
}

.compact-group {
  padding: 10px 0;
  border-top: 1px solid color-mix(in srgb, var(--family-color) 20%, var(--line));
}

.feeling-cluster {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--family-color) 16%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--family-color) 4%, transparent);
}

.compact-group h3,
.model-group-heading {
  margin: 0;
  color: var(--accent);
  font-size: 0.96rem;
}

.model-group-heading {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--family-color) 10%, transparent);
  color: color-mix(in srgb, var(--accent) 86%, var(--family-color));
  font-weight: 850;
  cursor: default;
}

.compact-node-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.intensity-scale {
  display: grid;
  gap: 10px;
}

.intensity-band {
  border-top: 0;
  border-left: calc(4px + var(--intensity-step) * 3px) solid var(--family-color);
  border-radius: 8px;
  padding: calc(8px + var(--intensity-step) * 3px);
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--family-color) calc(5% + var(--intensity-step) * 7%), transparent),
      transparent 72%
    ),
    var(--panel);
}

.intensity-band .emotion-node {
  min-height: calc(30px + var(--intensity-step) * 6px);
  padding-inline: calc(7px + var(--intensity-step) * 3px);
  font-size: calc(0.82rem + var(--intensity-step) * 0.04rem);
}

.geneva-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.geneva-cell {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--family-color) 18%, var(--line));
  border-radius: 8px;
  background: var(--panel);
}

.geneva-valence-pleasant {
  background:
    linear-gradient(180deg, color-mix(in srgb, #eef6df 82%, white), transparent 78%),
    var(--panel);
}

.geneva-valence-mixed {
  background:
    linear-gradient(180deg, color-mix(in srgb, #ece8f5 80%, white), transparent 78%),
    var(--panel);
}

.geneva-valence-unpleasant {
  background:
    linear-gradient(180deg, color-mix(in srgb, #f5e3df 78%, white), transparent 78%),
    var(--panel);
}

.geneva-control-low {
  opacity: 0.88;
}

.geneva-control-medium {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--family-color) 12%, transparent);
}

.geneva-control-high {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--family-color) 24%, transparent);
}

.compact-node {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.compact-node.selected,
.compact-node[aria-pressed="true"] {
  border-color: var(--family-color);
  background: color-mix(in srgb, var(--family-color) 13%, var(--panel));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--family-color) 24%, transparent);
}

.compact-node.family-node {
  display: grid;
  gap: 6px;
  width: min(100%, 640px);
  margin: 0 auto 10px;
  padding: 16px;
  border-left: 8px solid var(--family-color);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--family-color) 14%, transparent), transparent 52%),
    var(--panel);
}

.compact-node.family-node strong {
  color: var(--text);
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  line-height: 1.05;
}

.compact-node.family-node small {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.35;
}

.feeling-root {
  justify-items: center;
  text-align: center;
}

.compact-node.subcategory-node {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-weight: 850;
}

.compact-node.feeling-area {
  width: min(100%, 420px);
  justify-content: center;
  margin: 0 auto;
  padding: 12px 16px;
  text-align: center;
}

.compact-node.emotion-node {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 750;
}

.feeling-word {
  text-align: center;
}

.emotion-inline-detail {
  display: grid;
  gap: 10px;
  width: min(100%, 640px);
  margin: 10px auto 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--family-color);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(34, 38, 33, 0.07);
}

.emotion-inline-detail h3 {
  margin: 0;
  font-size: 1.22rem;
}

.emotion-inline-detail p {
  margin: 0;
}

.model-details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.model-details summary {
  width: fit-content;
  cursor: pointer;
  color: var(--accent);
  font-weight: 750;
}

.model-details dl {
  margin-top: 8px;
}

.family-detail {
  margin-top: 24px;
}

.reveal-in {
  animation: revealUp 180ms ease-out;
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.emotion-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.emotion-chip {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 750;
}

.emotion-chip.selected {
  border-color: var(--family-color);
  background: color-mix(in srgb, var(--family-color) 18%, var(--panel));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--family-color) 38%, transparent);
}

.emotion-detail-panel {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--family-color);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(34, 38, 33, 0.08);
}

.emotion-detail-panel h3 {
  margin: 0;
  font-size: 1.28rem;
}

.emotion-detail-panel p {
  margin: 0;
}

.detail-flash {
  animation: revealUp 140ms ease-out;
}

.family-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.emotion-card h2 {
  margin: 4px 0 8px;
}

dl {
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

dd {
  margin: 0 0 10px;
}

.entry-form,
.form-stack {
  display: grid;
  gap: 18px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  font-weight: 800;
}

.emotion-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.emotion-picker label {
  min-height: 44px;
  cursor: pointer;
}

.emotion-picker input {
  position: absolute;
  opacity: 0;
}

.emotion-picker span {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.emotion-picker input:checked + span {
  border-color: var(--family-color);
  box-shadow: inset 0 0 0 2px var(--family-color);
}

.expanded-fields {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.expanded-fields[open] {
  display: grid;
  gap: 12px;
}

.entry-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.entry-list a {
  display: grid;
  gap: 4px;
  padding: 14px;
  text-decoration: none;
}

.entry-list.compact a {
  border: 0;
  background: transparent;
  padding: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 8px 16px;
}

.lead {
  font-size: 1.15rem;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  background: #efe8d9;
}

.flash.error {
  background: #f4dedb;
  color: var(--danger);
}

.flash.success {
  background: #dcebdc;
  color: var(--success);
}

@media (max-width: 820px) {
  .topbar,
  .tool-header,
  .split-layout {
    grid-template-columns: 1fr;
  }

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

  .nav {
    justify-content: flex-start;
  }

  .wheel-grid,
  .emotion-grid,
  .emotion-picker,
  .compact-emotion-picker,
  .geneva-grid {
    grid-template-columns: 1fr;
  }

  .emotion-mode-form {
    justify-content: flex-start;
  }

  .emotion-detail-panel {
    position: static;
  }

  .compact-node.family-node {
    padding: 14px;
  }

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

  .family-petal {
    min-height: 104px;
  }

  .wheel-legend {
    grid-template-columns: 1fr;
  }

  .search-form {
    width: 100%;
  }

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

@media (max-width: 560px) {
  .petal-selector {
    grid-template-columns: 1fr;
  }

  .family-petal {
    min-height: auto;
  }
}
