/* Home art direction: an open music journal, not a wall of dashboard cards.
   Shared geometry and ink tokens keep both appearances and all languages aligned.
   The extra theme attribute intentionally outranks the older page palette. */
html[data-theme-page="home"] {
  --home-paper: #191a18;
  --home-surface: #22231f;
  --home-soft: #2b2d27;
  --home-ink: #eeeae0;
  --home-muted: #aaa99e;
  --home-line: #3b3d34;
  --home-accent: #d4b183;
  --home-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", sans-serif;
}
html[data-theme-page="home"][data-theme="light"] {
  --home-paper: #f8f7f3;
  --home-surface: #efeee8;
  --home-soft: #e8e7df;
  --home-ink: #252820;
  --home-muted: #66685d;
  --home-line: #d9dbd0;
  --home-accent: #866241;
}
html[data-theme-page="home"][data-theme] {
  body { background: var(--home-paper); color: var(--home-ink); }
  body:has(#homePanel:not([hidden])) {
    --page-gutter: clamp(22px, 5vw, 88px);
  }
  /* A typeset masthead leaves the ornate artwork a single, deliberate role. */
  body:has(#homePanel:not([hidden])) header {
    max-width: 1560px; margin-inline: auto; min-height: 88px;
    padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: 16px;
    gap: 16px;
  }
  .brand-typeset { display: none; }
  body:has(#homePanel:not([hidden])) {
    header h1 { width: auto; height: auto; margin-right: auto; }
    .brand-wordmark { display: none !important; }
    .brand-home { text-decoration: none; }
    .brand-typeset {
      display: block; color: var(--home-ink); font: 550 29px/1 var(--home-font);
      letter-spacing: -.065em; white-space: nowrap;
      span { font-weight: 350; }
      i { color: var(--home-accent); font-style: normal; }
    }
    .header-builder-link {
      border: 0; padding: 10px 0; background: transparent; color: var(--home-ink);
      font-size: 12px; font-weight: 500; letter-spacing: 0;
    }
    .theme-toggle, #guideBtn {
      min-height: 36px; height: 36px; background: transparent;
      border-color: var(--home-line); color: var(--home-muted);
    }
    #status { display: none; }
  }
  .home-panel { max-width: 1384px; padding: 0 0 48px; }
  .home-edition-bar {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 49px; border-top: 1px solid var(--home-line); position: relative; z-index: 5;
  }
  .home-edition-name { font-size: 10px; font-weight: 550; letter-spacing: .19em; color: var(--home-muted); }
  .home-preferences {
    position: relative;
    > summary {
      display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer;
      list-style: none; font-size: 11px; color: var(--home-muted);
      > span:first-child { font-size: 16px; letter-spacing: -.07em; }
      &::-webkit-details-marker { display: none; }
    }
    &[open] .home-preferences-plus { transform: rotate(45deg); }
    .home-preferences-plus { font-size: 19px; font-weight: 300; }
  }
  .home-language-picker {
    position: absolute; right: 0; top: calc(100% + 8px); width: min(430px, calc(100vw - 44px));
    padding: 22px; margin: 0; background: var(--home-paper); border: 1px solid var(--home-line);
    border-radius: 4px; box-shadow: 0 12px 36px #00000012;
  }
  .home-language-head { display: block; margin-bottom: 14px; }
  .home-language-heading { display: block; color: var(--home-ink); font-weight: 550; }
  .home-language-status { display: block; color: var(--home-muted); text-align: left; margin-top: 6px; white-space: normal; }
  .home-language-picker .language-choice-grid { flex-wrap: wrap; overflow: visible; gap: 7px; }
  .home-language-picker .language-choice {
    min-width: 44px; min-height: 44px; border-radius: 4px; padding: 8px;
    border: 1px solid var(--home-line); background: transparent; color: var(--home-muted);
    &[aria-pressed="true"] { background: var(--home-ink); color: var(--home-paper); border-color: var(--home-ink); box-shadow: none; }
  }
  .home-language-picker .home-font-pick { border-color: var(--home-line); color: var(--home-muted); margin-top: 18px; padding-top: 14px; }
  .home-font-pick input { accent-color: var(--home-ink); }
  /* The opening spread: copy and artwork share a baseline, with open edges. */
  .home-hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, .92fr); gap: clamp(40px, 6vw, 96px);
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
    padding: 50px 0 56px; overflow: visible; min-height: 0;
  }
  .home-hero-copy { display: flex; padding: 0; justify-content: center; min-width: 0; }
  .home-eyebrow {
    color: var(--home-accent); font-size: calc(10px * var(--app-font-scale));
    font-weight: 500; letter-spacing: .13em; line-height: 1.6; margin-bottom: 22px;
  }
  .home-title {
    font-family: var(--home-font); font-size: clamp(calc(38px * var(--app-font-scale)), 4.5vw, calc(67px * var(--app-font-scale)));
    font-weight: 500; line-height: 1.07; letter-spacing: -.055em;
    color: var(--home-ink); text-wrap: balance; white-space: pre-line; max-width: 660px;
  }
  .home-intro {
    font-size: calc(15px * var(--app-font-scale)); line-height: 1.8;
    max-width: 470px; margin: 24px 0 0; color: var(--home-muted);
  }
  .home-search {
    grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center;
    gap: 8px; margin-top: 32px; padding: 7px 7px 7px 14px;
    border: 1px solid var(--home-line); border-radius: 6px;
    background: transparent; box-shadow: none; transform: none;
    &:focus-within { border-color: var(--home-ink); transform: none; box-shadow: 0 0 0 2px var(--home-soft); }
    textarea {
      grid-column: 2; padding: 8px 3px; min-height: 52px;
      background: transparent; color: var(--home-ink); font-weight: 400;
      font-size: calc(13px * var(--app-font-scale)); line-height: 1.5;
      &::placeholder { color: var(--home-muted); }
    }
    button {
      grid-column: 3; min-height: 48px; padding: 12px 18px;
      border-radius: 3px; background: var(--home-ink); color: var(--home-paper);
      box-shadow: none; font-size: calc(13px * var(--app-font-scale)); font-weight: 500;
      &:hover { background: var(--home-muted); }
    }
  }
  .home-search-mark {
    display: block; width: 22px; height: 24px; margin: 0; background: transparent; color: var(--home-muted);
    &::before { width: 11px; height: 11px; border-width: 1.5px; top: 3px; left: 1px; }
    &::after { height: 1.5px; width: 7px; top: 15px; left: 12px; }
  }
  .home-primary-actions { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 15px; align-items: center; }
  .home-primary, .home-secondary {
    width: auto;
    min-height: 44px; border-radius: 0; padding: 8px 0;
    font-size: calc(12px * var(--app-font-scale)); font-weight: 500; box-shadow: none;
    white-space: normal; overflow: visible;
  }
  .home-primary:not(.listening), .home-secondary:not(.listening) {
    background: transparent; border: 0; color: var(--home-ink);
    &:hover { color: var(--home-accent); text-decoration: underline; text-underline-offset: 5px; }
  }
  .home-primary::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 8px; vertical-align: middle; }
  .home-builder-entry {
    flex: 1 0 100%; margin-top: 4px; padding: 13px 0; min-height: 0;
    border: 0; border-block: 1px solid var(--home-line); border-radius: 0;
    background: transparent; box-shadow: none; gap: 5px 12px;
    &:hover { background: transparent; border-color: var(--home-muted); transform: none; }
  }
  .home-builder-entry-kicker { color: var(--home-ink); font-size: 11px; font-weight: 550; letter-spacing: .05em; }
  .home-builder-entry-copy { color: var(--home-muted); font-size: 11px; }
  .home-builder-entry-arrow { color: var(--home-accent); }
  .home-privacy-note { font-size: calc(11px * var(--app-font-scale)); line-height: 1.65; color: var(--home-muted); margin-top: 12px; max-width: 450px; }
  .home-mascot-note { margin-top: 10px; color: var(--home-muted); font-size: 11px; line-height: 1.6; font-style: normal; }
  .home-hero-figure {
    align-self: center; height: auto; padding: 0; background: transparent; overflow: visible;
    picture { height: auto; }
    img { height: auto; width: 100%; border-radius: 2px; }
    &::after { display: none; }
  }
  /* Examples read as a small index beneath the opening spread. */
  .home-samples { margin: 0; gap: 0 36px; padding-top: 26px; border-top: 1px solid var(--home-line); }
  .home-sample {
    border: 0; border-radius: 0; padding: 0 0 26px; background: transparent;
    box-shadow: none; transform: none; gap: 12px;
    &:hover { transform: none; background: transparent; }
    strong { color: var(--home-ink); font: 400 calc(29px * var(--app-font-scale))/1.2 Georgia, "Songti SC", serif; }
  }
  .home-sample-label { border: 0; padding: 0; color: var(--home-muted); font-weight: 500; font-size: 9px; letter-spacing: .13em; }
  .home-sample-action { color: var(--home-accent); font-size: 11px; font-weight: 500; }
  .home-sample-meta { color: var(--home-muted); max-width: 440px; line-height: 1.7; }
  .home-doorway-invite {
    background: transparent; border: 0; border-top: 1px solid var(--home-line); border-bottom: 1px solid var(--home-line);
    border-radius: 0; box-shadow: none; padding: 25px 0; gap: 6px 22px;
    &:hover { background: var(--home-surface); box-shadow: none; transform: none; border-color: var(--home-line); }
  }
  .home-doorway-label { color: var(--home-muted); font-weight: 500; font-size: 9px; }
  .home-doorway-title { color: var(--home-ink); font: 500 20px/1.4 var(--home-font); }
  .home-doorway-meta { color: var(--home-muted); max-width: 740px; }
  .home-doorway-action { color: var(--home-accent); font-weight: 500; font-size: 11px; }
  .home-doorway-mark { border-color: var(--home-accent); box-shadow: none; &::after { background: var(--home-accent); } }
  /* Sections are separated by rhythm; borders are reserved for real boundaries. */
  .home-section, .home-access { margin-top: 88px; }
  .home-section-head, .home-playlist-head, .home-access-head { margin-bottom: 32px; }
  .home-section-title, .home-access-title, .home-feedback-title, .home-pwa-title {
    color: var(--home-ink); font: 500 clamp(26px, 2.6vw, 36px)/1.2 var(--home-font); letter-spacing: -.035em;
  }
  .home-section-note { color: var(--home-muted); margin-top: 12px; font-size: 14px; line-height: 1.7; max-width: 640px; }
  .home-playlist-section { background: transparent; border: 0; padding: 0; border-radius: 0; box-shadow: none; }
  .home-playlist-summary { color: var(--home-muted); background: transparent; border-color: var(--home-line); font-weight: 400; }
  .home-playlist-evidence li { background: transparent; color: var(--home-muted); border: 0; padding-left: 0; }
  .home-playlist-card { background: var(--home-surface); border-color: var(--home-line); border-radius: 5px; box-shadow: none; }
  .home-playlist-footnote { color: var(--home-muted); }
  .home-journeys { gap: 0 36px; }
  .home-journey, .home-journey.wide, .home-journey.full, .home-journey.third {
    grid-column: span 6; min-height: 0; padding: 28px 0 36px;
    border: 0; border-top: 1px solid var(--home-line); border-radius: 0;
    background: transparent; box-shadow: none; transition: none;
    &:hover { background: transparent; transform: none; border-color: var(--home-line); }
    &:hover .home-journey-title { color: var(--home-accent); }
  }
  .home-journey-kicker { color: var(--home-muted); font-size: 10px; font-weight: 500; letter-spacing: .13em; margin-bottom: 15px; }
  .home-journey-title { color: var(--home-ink); font: 500 clamp(20px, 2vw, 27px)/1.3 var(--home-font); letter-spacing: -.025em; max-width: 560px; }
  .home-journey-copy { color: var(--home-muted); font-size: 13px; line-height: 1.75; margin: 12px 0 24px; max-width: 510px; }
  .home-journey-visual { border: 1px solid var(--home-line); border-radius: 4px; margin-top: auto; }
  .home-journey.feature {
    grid-column: 1 / -1; padding: 32px 0 40px;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    .home-journey-title { font: 500 clamp(26px, 3vw, 38px)/1.2 var(--home-font); letter-spacing: -.035em; }
    .home-journey-visual { margin-top: 0; }
  }
  .home-access { border: 0; border-top: 1px solid var(--home-line); background: transparent; border-radius: 0; padding: 36px 0 0; }
  .home-access-intro, .home-feedback-intro { color: var(--home-muted); font-size: 14px; line-height: 1.75; }
  .home-access-grid { gap: 36px; }
  .home-access-card { border: 0; background: transparent; border-radius: 0; padding: 20px 0; box-shadow: none; }
  .home-access-card.public, .home-access-card.account { border-top: 1px solid var(--home-line); }
  .home-access-label, .home-access-card.account .home-access-label { color: var(--home-muted); font-weight: 500; }
  .home-access-card h4 { color: var(--home-ink); font-weight: 500; }
  .home-access-list li { color: var(--home-muted); }
  .home-access-card.public .home-access-list li { border: 0; background: transparent; color: var(--home-muted); }
  .home-pwa-install {
    background: var(--home-surface); border: 0; border-radius: 4px; box-shadow: none;
    margin-top: 48px; padding: 32px; grid-template-columns: 72px minmax(0, 1fr);
    &::after { display: none; }
  }
  .home-pwa-icon { width: 72px; height: 72px; border-radius: 16px; box-shadow: none; }
  .home-pwa-eyebrow { color: var(--home-muted); font-weight: 500; font-size: 10px; }
  .home-pwa-body, .home-pwa-step { color: var(--home-muted); font-size: 13px; }
  .home-pwa-actions button, .home-access-card .home-text-button {
    border: 0; border-bottom: 1px solid var(--home-muted); background: transparent;
    color: var(--home-ink); border-radius: 0; padding: 8px 0; font-weight: 500;
  }
  .home-feedback { margin-top: 64px; border: 0; border-top: 1px solid var(--home-line); background: transparent; border-radius: 0; padding: 36px 0; box-shadow: none; }
  .home-feedback .guide-feedback { background: transparent; border: 0; padding: 0; }
  .home-feedback :is(input, textarea) { background: transparent; border: 1px solid var(--home-line); border-radius: 4px; color: var(--home-ink); }
  .home-feedback button[type="submit"] { background: var(--home-ink); color: var(--home-paper); border-color: var(--home-ink); border-radius: 3px; }
  .home-notice, .home-license, .home-project-journal { background: transparent; border: 0; border-top: 1px solid var(--home-line); border-radius: 0; box-shadow: none; padding-inline: 0; }
  .home-notice-title, .home-license-title { color: var(--home-ink); font-family: var(--home-font); font-weight: 500; }
  .home-license-copy, .home-license-disclaimer { color: var(--home-muted); }
  #homePanel :is(button, a, textarea, summary):focus-visible { outline: 2px solid var(--home-accent); outline-offset: 5px; }
}
html[data-theme-page="home"][data-theme][data-display-language*="chinese"] .home-title {
  font-size: clamp(calc(34px * var(--app-font-scale)), 4vw, calc(60px * var(--app-font-scale)));
  letter-spacing: -.035em; line-height: 1.26; text-wrap: pretty;
}
@media (max-width: 900px) {
  html[data-theme-page="home"][data-theme] {
    .home-hero { gap: 32px; }
    .home-title { font-size: 42px; }
    .home-search { grid-template-columns: 22px minmax(0, 1fr); button { grid-column: 1 / -1; } }
    .home-sample-action { white-space: normal; }
  }
}
@media (max-width: 760px) {
  html[data-theme-page="home"][data-theme] {
    body:has(#homePanel:not([hidden])) main { padding-inline: 22px; }
    body:has(#homePanel:not([hidden])) header { padding-inline: 22px; min-height: 76px; gap: 12px; flex-wrap: nowrap; }
    body:has(#homePanel:not([hidden])) .brand-typeset { font-size: 25px; }
    body:has(#homePanel:not([hidden])) .header-builder-link { display: none; }
    body:has(#homePanel:not([hidden])) :is(.theme-toggle, #guideBtn) { min-width: 44px; min-height: 44px; }
    .home-edition-name { font-size: 9px; letter-spacing: .14em; }
    .home-hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 32px 0; }
    .home-hero-copy { padding: 0; }
    .home-title { font-size: calc(41px * var(--app-font-scale)); line-height: 1.08; max-width: 560px; }
    .home-eyebrow { margin-bottom: 18px; font-size: 9px; }
    .home-intro { margin-top: 20px; font-size: calc(14px * var(--app-font-scale)); line-height: 1.8; }
    .home-search { margin-top: 24px; grid-template-columns: 22px minmax(0, 1fr) auto; button { grid-column: 3; padding-inline: 13px; } }
    .home-search textarea { font-size: 16px; }
    .home-primary-actions { gap: 4px 18px; margin-top: 10px; }
    .home-primary, .home-secondary { font-size: 12px; }
    .home-hero-figure { padding: 0; max-width: 480px; justify-self: center; width: 100%; }
    .home-mascot-note { font-size: 10px; }
    .home-samples { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .home-sample { padding-bottom: 20px; }
    .home-sample + .home-sample { border-top: 1px solid var(--home-line); padding-top: 20px; }
    .home-sample strong { font-size: 26px; }
    .home-doorway-invite { grid-template-columns: 28px minmax(0, 1fr); padding: 22px 0; gap: 8px 15px; }
    .home-doorway-mark { width: 23px; height: 36px; }
    .home-doorway-title { font-size: 19px; }
    .home-doorway-action { grid-column: 2; grid-row: 4; white-space: normal; }
    .home-doorway-meta { grid-column: 2; }
    .home-section, .home-access { margin-top: 56px; }
    .home-section-title, .home-access-title, .home-feedback-title, .home-pwa-title { font-size: 27px; line-height: 1.3; }
    .home-section-head, .home-playlist-head { margin-bottom: 24px; }
    .home-journeys { grid-template-columns: minmax(0, 1fr); }
    .home-journey, .home-journey.wide, .home-journey.full, .home-journey.third, .home-journey.feature { grid-column: 1; min-height: 0; padding: 24px 0 32px; }
    .home-journey.feature { display: flex; }
    .home-journey-title, .home-journey.feature .home-journey-title { font-size: 24px; }
    .home-journey-visual, .home-journey.feature .home-journey-visual { min-height: 160px; margin-top: 0; }
    .home-access-head, .home-access-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .home-pwa-install { padding: 24px; grid-template-columns: 48px minmax(0, 1fr); gap: 18px; }
    .home-pwa-icon { width: 48px; height: 48px; border-radius: 10px; }
    .home-pwa-title { font-size: 23px; }
    .home-feedback { padding: 28px 0; }
  }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme-page="home"][data-theme] #homePanel * { transition: none; }
}

/* Bilingual hints need room for both lines; larger text must remain usable. */
html[data-theme-page="home"][data-theme][data-display-language*="+"] .home-search textarea { min-height: 104px; }
html[data-theme-page="home"][data-theme] .home-search button { max-width: 150px; white-space: normal; }

/* Keep node geometry and labels in one coordinate system. */
html[data-theme-page="home"][data-theme] .home-tanda-graph-preview {
  display: block; min-height: 0; grid-template-rows: none; padding: 0;
  background: radial-gradient(ellipse at 30% 45%, #29232b, #171619 75%);
  border: 1px solid var(--home-line); border-radius: 12px; overflow: hidden;
}
.tanda-network { display: block; width: 100%; height: auto; }
.tanda-network.mobile { display: none; }
.tanda-network-edge { stroke: #b79a68; stroke-opacity: .55; stroke-width: 1.3; }
.tanda-network-dot { stroke: #242126; stroke-width: 3; }
.tanda-network-label, .tanda-network-artist {
  font-family: "Avenir Next", "PingFang SC", sans-serif; fill: #e9e4e8;
  font-size: 12px; paint-order: stroke; stroke: #1d1a20; stroke-width: 4px; stroke-linejoin: round;
}
.tanda-network-artist { font-size: 10px; fill: #afa7b1; }
.is-seed .tanda-network-label { font-size: 14px; font-weight: 600; }
html[data-theme="light"] .home-tanda-graph-preview { background: #f4f2ef !important; }
html[data-theme="light"] .tanda-network-label { fill: #383139; stroke: #f4f2ef; }
html[data-theme="light"] .tanda-network-artist { fill: #706672; stroke: #f4f2ef; }
html[data-theme="light"] .tanda-network-dot { stroke: #f4f2ef; }
@media (max-width: 700px) {
  .tanda-network.desktop { display: none; }
  .tanda-network.mobile { display: block; }
}
