/* Shared appearance tokens cover the map, public catalog, journals and account forms. */
:root {
  color-scheme: light;
  --bg: #fafafc;
  --panel: #ffffff;
  --surface-soft: #f3f3f7;
  --surface-hover: #ececf2;
  --header: #f7f7fa;
  --text: #18181c;
  --muted: #646570;
  --line: #e3e4e9;
  --line-strong: #c9cbd3;
  --accent: #315cd4;
  --accent-soft: #edf1ff;
  --primary: #315edc;
  --on-primary: #ffffff;
  --scrollbar: #a5a7b3;
  --backdrop: #17172080;
  --shadow: #17172014;
  --map-bg: #fdfdff;
  --map-region: #efeff5;
  --map-grid: #d1d3de;
  --map-edge: #737888;
  --genre-roots: #78613a;
  --genre-country: #a25323;
  --genre-jazz: #276c96;
  --genre-rap: #7251b4;
  --genre-rock: #85650b;
  --genre-pop: #a33c7b;
  --genre-club: #477525;
  --genre-bass: #14786a;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141416;
  --panel: #1b1b1f;
  --surface-soft: #232328;
  --surface-hover: #2c2c33;
  --header: #19191c;
  --text: #f2f2f5;
  --muted: #aaaab6;
  --line: #323239;
  --line-strong: #4c4c57;
  --accent: #9ab3ff;
  --accent-soft: #242e48;
  --primary: #3965db;
  --scrollbar: #62626f;
  --backdrop: #000000aa;
  --shadow: #00000033;
  --map-bg: #19191d;
  --map-region: #25252c;
  --map-grid: #3e3e4b;
  --map-edge: #9898ad;
  --genre-roots: #c9b58a;
  --genre-country: #eea46e;
  --genre-jazz: #74b5db;
  --genre-rap: #b6a0ff;
  --genre-rock: #e6be63;
  --genre-pop: #e697c4;
  --genre-club: #b5ed7d;
  --genre-bass: #72d9c7;
}

/* Digg-inspired compact type, quiet surfaces and clear editorial hierarchy. */
body {
  color-scheme: inherit;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Noto Sans JP', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
button { font-size: 13px; font-weight: 500; border-radius: 8px; }
p { line-height: 1.6; }
h1, h2, h3, h4 { letter-spacing: -.025em; }
::selection { background: var(--accent-soft); color: var(--text); }
.site-header { height: 68px; gap: 24px; padding-top: 0; padding-bottom: 0; background: var(--header); }
.site-header .brand { font-size: 22px; font-weight: 800; letter-spacing: -.9px; gap: 8px; }
.brand:hover { color: var(--text); }
.record { color: var(--text); font-size: 30px; font-weight: 600; line-height: 1; }
.gnb { align-self: center; gap: 4px; }
.gnb button { border-radius: 8px; padding: 8px 14px; font-size: 14px; }
.gnb button.active { color: var(--text); background: var(--surface-hover); font-weight: 650; }
.gnb button.active:after { display: none; }
.gnb button:hover { background: var(--surface-hover); color: var(--text); }
.header-actions { margin-left: 0; }
#account-button { border-radius: 999px; padding: 7px 16px; background: var(--panel); white-space: nowrap; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.theme-switch { display: inline-flex; align-items: center; flex-shrink: 0; margin-left: auto; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface-soft); }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 11px; line-height: 18px; padding: 4px 8px; }
.theme-switch button[aria-pressed="true"] { color: var(--text); background: var(--panel); box-shadow: 0 1px 3px var(--shadow); font-weight: 650; }
.theme-switch button:hover { color: var(--text); }
.theme-switch svg { height: 13px; width: 13px; flex: 0 0 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.site-header .language-select { font-size: 12px; border: 0; padding: 6px 3px; background: transparent; }
.atlas-count { font-size: 11px; padding-top: 14px; padding-bottom: 9px; font-variant-numeric: tabular-nums; }
.segmented { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { font-size: 12px; border-radius: 999px; padding: 6px 13px; }
.segmented .active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: 0 1px 3px var(--shadow); }
.toolbar { margin-bottom: 14px; align-items: center; }
.search { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 0 10px; }
.search input { font-size: 12px; padding: 8px 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.map-shell { background: var(--map-bg); border-radius: 12px; }
.map-heading, .map-footer { padding: 12px 16px; font-size: 11px; background: var(--panel); }
.map-heading { letter-spacing: .06em; }
#family-headers { background: var(--surface-soft); }
#family-headers span { font-size: 11px; font-weight: 650; letter-spacing: .025em; }
#year-axis { color: var(--text); }
svg .node text { stroke: var(--map-bg); font-weight: 550; }
svg .node:hover text, svg .node:focus text { fill: var(--text); }
#map { scrollbar-color: var(--scrollbar) var(--map-bg); }
.map-footer>div { gap: 5px; }
.map-footer button { font-size: 12px; }
.map-note { font-size: 11px; line-height: 1.6; }
.country-shortcut { gap: 6px; margin-top: 10px; }
.country-shortcut button { border-color: var(--line); color: var(--muted); background: transparent; font-size: 11px; border-radius: 999px; padding: 5px 10px; }
#hiphop-focus { color: var(--muted); border-color: var(--line); }
.country-shortcut button:hover, #hiphop-focus:hover { color: var(--text); background: var(--surface-soft); }
#detail, #detail.is-welcome { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px; scrollbar-color: var(--scrollbar) var(--panel); }
#detail.is-welcome { border-color: var(--line) !important; }
.detail-kicker { font-size: 10px; font-weight: 650; color: var(--muted); letter-spacing: .1em; }
#detail h2 { font-size: 24px; font-weight: 650; letter-spacing: -.035em; }
#detail .welcome-eyebrow { margin-top: 25px; font-size: 12px; color: var(--accent); }
#detail .welcome-title { font-size: 28px; line-height: 1.35; margin-bottom: 15px; }
#detail .welcome-lead { font-size: 13px; line-height: 1.7; margin-bottom: 20px; }
.welcome-steps li { padding: 13px 0 13px 30px; }
.welcome-steps li:before { top: 15px; font-size: 11px; }
.welcome-steps strong { font-size: 13px; }
#detail .welcome-steps p, #detail .welcome-footnote { font-size: 12px; line-height: 1.6; }
#detail .description, #detail .timeline-note, #detail .meta { font-size: 13px; line-height: 1.6; }
#detail .timeline-label { font-size: 14px; font-weight: 600; }
#detail .section-label { font-size: 11px; letter-spacing: .03em; }
.artist { background: var(--surface-soft); border-color: var(--line); }
#detail .artist { border-radius: 10px; padding: 14px 12px 3px; margin: 13px 0; }
#detail .artist+.artist { margin-top: 18px; }
#detail .artist-name { font-size: 18px; font-weight: 650; }
#detail .artist small { font-size: 12px; }
#detail .track-title { font-size: 14px; font-weight: 600; }
.youtube-link, .track-link .youtube-link { font-size: 12px; }
.journal-video { width: 100%; max-width: 640px; margin: 14px 0; }
.journal-video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; min-height: 200px; border: 1px solid var(--line); border-radius: 8px; background: #000; box-sizing: border-box; }
.journal-video figcaption { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.journal-video figcaption a { color: var(--muted); text-underline-offset: 3px; }
.journal-video figcaption a:hover { color: var(--accent); }
.composer-hint { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.related { gap: 5px; }
.related button { border-radius: 999px; padding: 5px 9px; font-size: 12px; }
.detail-source, #detail .detail-source { font-size: 12px; }
.community { max-width: 900px; }
.feed-heading { margin-bottom: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.feed-heading h1 { font-size: 16px; font-weight: 650; }
.post-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 12px; }
.post-top { margin-bottom: 13px; gap: 8px; }
.post-top strong { font-size: 13px; font-weight: 600; }
.post-top small { font-size: 11px; }
.avatar { flex-basis: 30px; height: 30px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.post-card h2, .legacy-post h2 { font-size: 20px; line-height: 1.4; font-weight: 650; letter-spacing: -.035em; }
.post-body, .legacy-post p { font-size: 14px; line-height: 1.65; }
.post-actions { gap: 7px; }
.post-actions button { border-radius: 999px; padding: 5px 10px; }
.post-actions [aria-pressed="true"] { background: var(--accent-soft); }
.genre-chips button { border-color: var(--line); color: var(--muted); background: var(--surface-soft); border-radius: 999px; }
.genre-chips button:hover { color: var(--accent); border-color: var(--accent); }
.journal-composer { background: var(--panel); border-color: var(--line); padding: 20px; }
.journal-composer h1 { font-size: 20px; font-weight: 650; margin-bottom: 16px; }
.automatic-music { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.automatic-music h2 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.automatic-music .composer-hint { margin: 0 0 10px; }
.automatic-genres { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.automatic-genres span, .recommendation-label { padding: 3px 7px; border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 12px; line-height: 1.4; }
.automatic-music.is-stale .composer-hint { color: var(--accent); }
.song-identity { flex: 1; min-width: 0; }
.recommendation-label { display: inline-block; margin-left: 8px; border: 1px solid var(--line); }
.composer-tools button[aria-busy="true"] { opacity: 1; cursor: wait; }
.ai-draft-status { display: flex; align-items: flex-start; gap: 10px; padding: 12px; margin: 12px 0 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-size: 13px; line-height: 1.6; }
.ai-draft-status[hidden] { display: none; }
.ai-draft-status[data-state="loading"], .ai-draft-status[data-state="waiting"] { border-color: var(--accent); background: var(--accent-soft); }
.ai-draft-message { flex: 1; min-width: 0; }
.ai-draft-elapsed { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-draft-spinner { display: none; flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: draft-spin .85s linear infinite; }
.ai-draft-status[data-state="loading"] .ai-draft-spinner, .ai-draft-status[data-state="waiting"] .ai-draft-spinner { display: block; }
@keyframes draft-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai-draft-spinner { animation: none; } }
.form-field { font-size: 12px; gap: 6px; }
.form-field input, .form-field textarea, .draft-track select { background: var(--surface-soft); border-color: var(--line); font-size: 14px; border-radius: 8px; }
.primary { background: var(--primary) !important; color: var(--on-primary) !important; border-color: var(--primary) !important; border-radius: 999px; }
.primary:hover { filter: brightness(1.08); }
.account-dialog, dialog { background: var(--panel); border-color: var(--line); box-shadow: 0 16px 60px var(--shadow); border-radius: 16px; }
.account-dialog h2 { font-weight: 650; letter-spacing: -.035em; }
.form-status { color: var(--accent); }
#feed-status:not(:empty) { background: var(--panel); border-style: solid; }
#toast { background: var(--text); color: var(--panel); box-shadow: 0 6px 28px var(--shadow); border-radius: 999px; font-size: 13px; }
.sleaze-journal { background: var(--panel); }
.study-grid>div, .sleaze-context, .sleaze-artist { background: var(--surface-soft); }
footer { font-size: 11px; letter-spacing: .02em; padding-top: 18px; }

@media (min-width: 761px) { #detail { top: 52px; } }
@media (min-width: 761px) and (max-width: 1100px) {
  .site-header { gap: 12px; }
  .site-header .brand { font-size: 18px; }
  .gnb button { font-size: 13px; padding: 8px 10px; }
  .theme-switch button { padding: 4px 6px; }
  .theme-switch svg { display: none; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  .toolbar { flex-wrap: nowrap; }
  .toolbar .search { flex: 1; width: auto; min-width: 100px; }
}
@media (max-width: 760px) {
  .site-header { display: grid; grid-template-columns: minmax(0,1fr) auto auto; height: auto; min-height: 0; gap: 10px 8px; padding: 12px 4%; }
  .site-header .brand { grid-column: 1; grid-row: 1; font-size: 18px; min-width: 0; }
  .record { font-size: 26px; }
  .header-actions { grid-column: 2; grid-row: 1; margin-left: auto; }
  #account-button { font-size: 12px; padding: 5px 11px; max-width: 100px; }
  .site-header .language-select { grid-column: 3; grid-row: 1; width: 74px; font-size: 11px; }
  .gnb { grid-column: 1; grid-row: 2; width: auto; margin: 0; gap: 0; }
  .gnb button { flex: initial; padding: 7px 9px; font-size: 12px; white-space: nowrap; }
  .theme-switch { grid-column: 2 / 4; grid-row: 2; margin-left: auto; }
  .theme-switch button { font-size: 10px; padding: 3px 7px; gap: 3px; }
  .theme-switch svg { width: 11px; height: 11px; flex-basis: 11px; }
  .toolbar { gap: 8px; }
  .search { width: auto; min-width: 150px; }
  .segmented button { padding: 6px 10px; }
  .map-heading, .map-footer { padding: 10px 12px; }
  .workspace #detail { margin-top: 20px; padding: 18px; }
  .community { margin-top: 22px; }
  .post-card, .journal-composer { padding: 16px; }
  .post-card h2, .legacy-post h2 { font-size: 18px; }
  .form-field input, .form-field textarea { font-size: 16px; }
}
@media (max-width: 370px) {
  .site-header .brand { font-size: 16px; }
  .theme-switch svg { display: none; }
}

/* Pending applications stay visible to the administrator. */
.header-actions .approval-button { border-color: var(--accent, #d44a24); font-weight: 650; white-space: nowrap; }
.application { gap: .45rem; }


/* One text-flow policy for cards, including legacy journals and nested music cards.
   Prose uses the available card width; normal language-aware wrapping preserves
   words where possible, with anywhere as a fallback for long unbroken strings. */
:where(.post-card, #detail, .journal-composer, .account-dialog, #feed-status) {
  min-width: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}
:where(.post-card, #detail, .journal-composer, .account-dialog, #feed-status)
  :where(h1, h2, h3, h4, h5, h6, p, blockquote, figcaption, summary, a, button) {
  min-width: 0;
  max-width: 100%;
}
:where(.study-grid, .sleaze-artist-grid, .community-song, .artist) > * {
  min-width: 0;
}
/* Authored line breaks remain content; layout must not invent or remove them. */
.post-body, .comment p, .form-field textarea { white-space: pre-wrap; }
#detail .welcome-title { white-space: pre-line; }
/* Let long author names wrap beside the fixed avatar and actions. */
.post-top > div:not(.post-options) { flex: 1; min-width: 0; }
.post-options { flex-shrink: 0; }

.translation-control { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 10px; margin: 6px 0 10px; color: var(--muted); font-size: 12px; }
.translation-control button, .comment .translation-control button { position: static; border: 0; padding: 0; background: none; color: var(--muted); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.translation-control[aria-busy="true"] > span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; vertical-align: -1px; animation: draft-spin .85s linear infinite; }
@media (prefers-reduced-motion: reduce) { .translation-control[aria-busy="true"] > span::before { animation: none; } }
