.emotion-tree-app {
  min-height: 100vh;
}

.emotion-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.4rem;
}

.emotion-heading {
  max-width: 44rem;
  margin-bottom: 0.95rem;
}

.emotion-heading h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
}

.emotion-heading p:last-child {
  max-width: 38rem;
  margin: 0;
  color: var(--pico-muted-color);
  font-size: 1.05rem;
  line-height: 1.55;
}

.track-toolbar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.view-switcher {
  display: inline-flex;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  padding: 0.24rem;
  border: 1px solid rgba(92, 74, 52, 0.18);
  border-radius: 0.6rem;
  background: rgba(255, 250, 240, 0.62);
}

.view-switcher button {
  border: 0;
  border-radius: 0.42rem;
  background: transparent;
  color: #39443d;
  min-height: 2.05rem;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.view-switcher button.active {
  background: #111827;
  color: #fff;
}

.track-toolbar button,
.track-actions button,
.question-actions button,
.track-name-btn {
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
  background: #111827;
  color: #fff;
  min-height: 2.55rem;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.track-toolbar button.secondary,
.track-actions button,
.question-actions button.secondary {
  background: rgba(255, 250, 240, 0.68);
  color: #111827;
  border-color: rgba(92, 74, 52, 0.24);
}

.track-toolbar button.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.emotion-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}

.track-list,
.track-workspace {
  border: 1px solid rgba(92, 74, 52, 0.18);
  border-radius: 0.75rem;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.track-list {
  display: flex;
  flex-direction: column;
  padding: 0.85rem;
  position: sticky;
  top: 5.5rem;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.panel-heading-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.2;
}

.add-part-button {
  border: 1px solid #111827;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  min-height: 1.55rem;
  padding: 0.18rem 0.48rem;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

#trackCount {
  display: block;
  margin-top: 0.12rem;
  color: var(--pico-muted-color);
  font-size: 0.74rem;
  line-height: 1.25;
}

.track-list-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.track-card {
  position: relative;
  display: grid;
  grid-template-columns: 0.28rem minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  padding: 0.55rem 0.5rem;
  text-align: left;
  cursor: pointer;
}

.track-card:hover {
  background: rgba(255, 255, 255, 0.36);
}

.track-card.active {
  border-color: rgba(17, 24, 39, 0.16);
  background: rgba(255, 255, 255, 0.62);
}

.track-card-title {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  color: #111827;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
}

.track-card-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-card-title span:last-child {
  flex: 0 0 auto;
  color: var(--pico-muted-color);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
}

.track-card-summary {
  grid-column: 2;
  margin-top: 0.2rem;
  color: var(--pico-muted-color);
  font-size: 0.72rem;
  line-height: 1.35;
}

.track-family-dots {
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  min-height: 1.7rem;
  margin-top: 0.12rem;
}

.track-family-dots span {
  width: 0.28rem;
  min-height: 0.42rem;
  flex: 1;
  border-radius: 999px;
  background: var(--family-color);
  opacity: var(--family-alpha, 0.92);
}

.track-family-dots.empty span {
  background: rgba(92, 74, 52, 0.18);
}

.track-panel-footer {
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(92, 74, 52, 0.12);
}

.track-panel-footer button {
  border: 0;
  background: transparent;
  color: var(--pico-muted-color);
  padding: 0;
  font: inherit;
  font-size: 0.68rem;
  line-height: 1.2;
  cursor: pointer;
}

.track-panel-footer button:hover {
  color: #111827;
  text-decoration: underline;
}

.track-workspace {
  min-height: 34rem;
  padding: clamp(0.85rem, 1.8vw, 1.15rem);
}

.active-track-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

.track-name-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.track-name-row input {
  width: min(22rem, 100%);
  border: 1px solid rgba(92, 74, 52, 0.2);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.66);
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.track-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.answer-path {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  margin: 0.55rem 0 0.85rem;
}

.path-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 0;
  border-radius: 999px;
  background: #e4eae6;
  color: #39443d;
  padding: 0.22rem 0.52rem;
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.25;
  font-family: inherit;
  cursor: pointer;
}

.question-panel {
  border-top: 1px solid rgba(92, 74, 52, 0.14);
  padding-top: 0.75rem;
}

.question-panel h2 {
  margin: 0 0 0.28rem;
  font-size: 1.22rem;
  line-height: 1.2;
}

.question-hint {
  max-width: 42rem;
  margin: 0 0 0.7rem;
  color: var(--pico-muted-color);
  font-size: 0.92rem;
  line-height: 1.38;
}

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

.option-button {
  min-height: 3.25rem;
  border: 1px solid color-mix(in srgb, var(--family-border, rgba(92, 74, 52, 0.18)) 72%, white);
  border-left: 0.3rem solid color-mix(in srgb, var(--family-color, #8b8173) 70%, white);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--family-soft, #f5f0df) 44%, white);
  padding: 0.42rem 0.52rem;
  text-align: left;
  cursor: pointer;
}

.option-button.selected {
  border-color: var(--family-color, #111827);
  border-left-color: var(--family-color, #111827);
  background: color-mix(in srgb, var(--family-soft, #f5f0df) 70%, white);
  box-shadow: inset 0 0 0 1px var(--family-color, #111827);
}

.option-title {
  display: block;
  margin-bottom: 0.08rem;
  color: #111827;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.2;
}

.option-desc {
  display: block;
  color: var(--pico-muted-color);
  font-size: 0.72rem;
  line-height: 1.18;
}

.question-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.65rem;
}

.result-box {
  border: 1px solid rgba(92, 74, 52, 0.15);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.48);
  padding: 0.7rem;
}

.result-box h3 {
  margin: 0 0 0.28rem;
  font-size: 0.86rem;
}

.result-box p,
.result-box ul {
  margin: 0;
  color: var(--pico-muted-color);
  font-size: 0.82rem;
  line-height: 1.38;
}

.result-box ul {
  padding-left: 1.1rem;
}

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

.family-card {
  margin: 0;
  border: 1px solid var(--family-border);
  border-left-width: 0.36rem;
  border-radius: 0.62rem;
  background: color-mix(in srgb, var(--family-soft) 52%, white);
  padding: 0.46rem 0.5rem;
  opacity: var(--family-alpha, 0.92);
}

.family-card.texture-activated {
  border-color: var(--family-color);
  border-left-width: 0.58rem;
  background: color-mix(in srgb, var(--family-soft) 78%, white);
  opacity: 1;
}

.family-card.texture-settled {
  border-color: color-mix(in srgb, var(--family-border) 80%, white);
  background: color-mix(in srgb, var(--family-soft) 36%, white);
  opacity: var(--family-alpha, 0.62);
}

.family-card.texture-unclear {
  border-style: dashed;
  border-color: #b2b7af;
  background: color-mix(in srgb, #e6e7e2 54%, white);
  opacity: var(--family-alpha, 0.5);
}

.family-card-header {
  margin: 0 0 0.36rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.family-card-header h3 {
  margin: 0 0 0.1rem;
  font-size: 0.9rem;
  line-height: 1.2;
}

.family-card-header p {
  margin: 0;
  color: var(--pico-muted-color);
  font-size: 0.76rem;
  line-height: 1.24;
}

.texture-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.16rem;
  margin-bottom: 0.32rem;
}

.texture-chip {
  border: 1px solid rgba(92, 74, 52, 0.2);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.7);
  color: #39443d;
  min-height: 1.38rem;
  padding: 0.1rem 0.34rem;
  font: inherit;
  font-size: 0.64rem;
  font-weight: 680;
  line-height: 1.1;
  cursor: pointer;
}

.texture-chip.selected {
  border-color: var(--family-color);
  background: var(--family-color);
  color: #fff;
}

.family-card-body {
  display: grid;
  gap: 0.42rem;
}

.family-card-body h4 {
  margin: 0 0 0.14rem;
  font-size: 0.7rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #39443d;
}

.family-card-body p {
  margin: 0;
  color: var(--pico-muted-color);
  font-size: 0.76rem;
  line-height: 1.28;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.14rem;
}

.word-cloud button {
  border: 0;
  border-radius: 999px;
  background: #e4eae6;
  color: #39443d;
  min-height: 1.32rem;
  padding: 0.08rem 0.32rem;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 650;
  line-height: 1.12;
  cursor: pointer;
}

.word-cloud button.selected {
  background: var(--family-color, #111827);
  color: #fff;
}

.word-cloud.compact button {
  cursor: default;
}

.summary-view {
  border: 1px solid rgba(92, 74, 52, 0.18);
  border-radius: 0.75rem;
  background: rgba(255, 250, 240, 0.84);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: clamp(0.85rem, 1.8vw, 1.15rem);
}

.summary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.summary-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
}

.summary-header p:last-child {
  margin: 0;
  color: var(--pico-muted-color);
}

.summary-header button {
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
  background: #111827;
  color: #fff;
  min-height: 2.55rem;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.summary-section {
  border-top: 1px solid rgba(92, 74, 52, 0.14);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.summary-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.92rem;
}

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

.color-stack {
  display: flex;
  width: 100%;
  min-height: 1.05rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(92, 74, 52, 0.14);
  margin-bottom: 0.85rem;
}

.color-stack span {
  background: var(--family-color);
}

.family-count-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: var(--family-color);
}

.summary-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(92, 74, 52, 0.16);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.36);
}

.summary-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  margin: 0;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid rgba(92, 74, 52, 0.12);
  border-right: 1px solid rgba(92, 74, 52, 0.1);
  padding: 0.42rem 0.48rem;
  vertical-align: top;
}

.summary-table tr:last-child th,
.summary-table tr:last-child td {
  border-bottom: 0;
}

.summary-table th:last-child,
.summary-table td:last-child {
  border-right: 0;
}

.summary-table thead th {
  position: sticky;
  top: 0;
  background: rgba(255, 250, 240, 0.96);
  color: #111827;
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  z-index: 1;
}

.summary-table thead th:not(:first-child) {
  background: color-mix(in srgb, var(--family-soft) 58%, white);
}

.summary-table thead .family-count-dot {
  display: inline-block;
  width: 0.58rem;
  height: 0.58rem;
  margin-right: 0.3rem;
  vertical-align: -0.05rem;
}

.summary-table tbody th {
  width: 9rem;
  color: #111827;
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: left;
  background: rgba(255, 250, 240, 0.58);
}

.summary-empty-cell {
  background: rgba(255, 255, 255, 0.24);
}

.summary-filled-cell {
  background: color-mix(in srgb, var(--family-soft) 62%, white);
}

.summary-cell-fill {
  display: grid;
  gap: 0.18rem;
  min-height: 3rem;
  border-left: 0.28rem solid var(--family-color);
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--family-soft) 70%, white);
  padding: 0.36rem 0.42rem;
}

.summary-cell-fill strong {
  color: #111827;
  font-size: 0.74rem;
  line-height: 1.25;
}

.summary-cell-fill span {
  color: var(--pico-muted-color);
  font-size: 0.68rem;
  line-height: 1.28;
}

.combined-panel {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(92, 74, 52, 0.14);
  padding-top: 0.75rem;
}

.combined-panel h2 {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.combined-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.empty-note {
  color: var(--pico-muted-color);
  margin: 0;
}

@media (max-width: 820px) {
  .emotion-layout {
    grid-template-columns: 1fr;
  }

  .track-list {
    position: static;
  }

  .track-list-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  }

  .active-track-header,
  .result-grid,
  .family-card-grid,
  .summary-two-col {
    grid-template-columns: 1fr;
  }

  .summary-header {
    flex-direction: column;
  }

  .track-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .emotion-shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }

  .emotion-heading h1 {
    font-size: 2.3rem;
  }

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