:root {
  --primary: #ff52e5;
  --primary-dark: #ca27b2;
  --secondary: #f6d242;
  --secondary-dark: #eeb608;
  --secondary-shadow: #f1e9c5;
  --secondary-light: #fff1b9;
  --secondary-lighter: #fff8d9;
  --grey: #7a7a7a;
  --grey-dark: #4a4a4a;
  --grey-light: #b5b5b5;
  --grey-lighter: #dbdbdb;
  --ink: #1a1a1a;
  --black: #0a0a0a;
  --doom-tint: #ffe9f7;
  --shine-tint: #fff8d9;
  --auto: #2da854;
  --stale: #c83737;
  --manual: #5b8def;
  --seed: #f29028;
  --rail-w: 60px;
  --col-min: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100vh;
  overflow: hidden;
}

body {
  background: #fafafa;
  color: var(--ink);
  font-family: "Source Sans 3", "Noto Sans KR", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

a:hover {
  color: var(--primary);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--primary-dark);
  outline-offset: 3px;
}

#app {
  display: flex;
  height: 100vh;
  min-width: 0;
}

#app-brand,
#app-topics,
#app-filters,
#app-feed,
#app-timeline {
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
}

#app-topics::-webkit-scrollbar,
#app-filters::-webkit-scrollbar,
#app-feed::-webkit-scrollbar,
#app-timeline::-webkit-scrollbar {
  width: 6px;
}

#app-topics::-webkit-scrollbar-thumb,
#app-filters::-webkit-scrollbar-thumb,
#app-feed::-webkit-scrollbar-thumb,
#app-timeline::-webkit-scrollbar-thumb {
  background: var(--grey-lighter);
  border-radius: 3px;
}

#app-brand {
  width: var(--rail-w);
  min-width: var(--rail-w);
  background-color: var(--primary);
  background-image: linear-gradient(120deg, var(--secondary) 10%, var(--primary) 100%);
  border: 0;
  color: var(--black);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  text-align: center;
  text-shadow: 0 0 5px var(--secondary);
  z-index: 1000;
}

.brand-icon {
  width: var(--rail-w);
  height: var(--rail-w);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-family: "JetBrains Mono", monospace;
  transition: background-color 0.15s;
}

#app-brand:hover .brand-icon,
#app-brand.is-active .brand-icon {
  background: var(--secondary-dark);
}

.brand-label {
  margin-top: 18px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: "Bagel Fat One", cursive;
  font-size: 18px;
  letter-spacing: 0.05em;
}

.data-pulse {
  margin-top: auto;
  margin-bottom: 16px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--black);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-shadow: none;
}

.dot {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--seed);
  animation: pulse 1.6s ease-in-out infinite;
}

#app[data-freshness="auto"] .dot {
  background: var(--auto);
}

#app[data-freshness="stale"] .dot {
  background: var(--stale);
}

#app[data-freshness="manual"] .dot {
  background: var(--manual);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

#app-topics {
  position: fixed;
  left: var(--rail-w);
  top: 0;
  bottom: 0;
  width: var(--col-min);
  min-width: var(--col-min);
  background: #fff;
  border-right: 1px solid var(--grey-lighter);
  box-shadow: 4px 0 18px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease;
  z-index: 900;
}

#app-topics.is-hidden {
  transform: translateX(-110%);
}

#app-topics header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-image: linear-gradient(120deg, var(--secondary) 10%, var(--primary) 100%);
}

#search-form {
  display: flex;
}

#topic-search {
  flex: 1;
  min-width: 0;
  height: 60px;
  padding: 0 0 0 20px;
  border: 0;
  background: rgba(255, 255, 255, 0.95);
}

#topic-search:focus-visible {
  outline-offset: -5px;
}

#search-form button {
  width: 60px;
  height: 60px;
  border: 0;
  background: transparent;
  color: var(--black);
  font-size: 22px;
}

.topic-card {
  position: relative;
  display: block;
  height: 110px;
  overflow: hidden;
}

.topic-card:hover {
  box-shadow: inset 0 0 0 5px var(--primary);
}

.topic-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  filter: saturate(0.8);
}

.cat-economy .topic-bg {
  background: linear-gradient(135deg, #f6d242, #fff1b9);
}

.cat-culture .topic-bg {
  background: linear-gradient(135deg, #ff52e5, #ffd6f5);
}

.cat-people .topic-bg {
  background: linear-gradient(135deg, #b1e1ff, #cdffc0);
}

.cat-life .topic-bg {
  background: linear-gradient(135deg, #ffa9ac, #ffcab3);
}

.topic-label {
  position: absolute;
  bottom: 0;
  left: 10px;
  background-color: var(--primary);
  background-image: linear-gradient(120deg, var(--secondary) 10%, var(--primary) 100%);
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 3px var(--primary-dark);
}

.topic-count {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

#app-filters {
  flex: 1 0 var(--col-min);
  min-width: var(--col-min);
  padding: 0 0 20px;
  border-left: 5px solid var(--secondary-shadow);
  background: var(--secondary-lighter);
}

#app-filters header,
#app-timeline header,
#app-feed header {
  position: sticky;
  top: 0;
  z-index: 100;
}

#app-filters header {
  padding: 20px 14px 14px;
  background-image: linear-gradient(0deg, transparent 0%, var(--secondary-lighter) 50%);
}

#app-filters header h2,
#app-timeline header h2 {
  margin-bottom: 4px;
  color: var(--grey-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sub {
  color: var(--grey);
  font-size: 12px;
}

#filters-main {
  padding: 0 14px;
}

.filter-group {
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.filter-group + .filter-group {
  border-top: 1px dashed var(--secondary-shadow);
  padding-top: 12px;
}

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.group-head b {
  color: var(--grey-dark);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 5px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--grey-dark);
  text-align: left;
}

.filter-item:hover,
.filter-item.is-active {
  background: var(--secondary-light);
  color: var(--ink);
}

.filter-item.is-active {
  font-weight: 600;
}

.ico {
  width: 26px;
  height: 22px;
  flex: 0 0 26px;
  border: 1px solid var(--secondary-shadow);
  border-radius: 4px;
  background: #fff;
  color: var(--grey-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 600;
}

.name {
  flex: 1;
  min-width: 0;
}

.count {
  color: var(--grey);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

#app-feed {
  flex: 20 1 auto;
  min-width: 0;
  padding: 0 22px;
  background: #fff;
}

#app-feed header {
  padding: 18px 0 14px;
  background-image: linear-gradient(0deg, transparent 0%, #fff 30%);
}

.feed-tabs {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--grey-lighter);
}

.feed-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: var(--grey);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.feed-tabs button:hover,
.feed-tabs button.is-active {
  color: var(--ink);
}

.feed-tabs button.is-active {
  background: #fff;
  border-color: var(--grey-lighter);
  margin-bottom: -1px;
}

.live-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 8px;
  color: var(--grey);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  white-space: nowrap;
}

#feed-main {
  padding-bottom: 60px;
}

.indicator {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px dotted var(--grey-lighter);
}

.indicator:first-child {
  border-top: 0;
}

.ind-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.indicator.shine .ind-icon {
  background: var(--shine-tint);
}

.indicator.doom .ind-icon {
  background: var(--doom-tint);
}

.ind-body {
  flex: 1;
  min-width: 0;
}

.ind-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.ind-label {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.ind-label-kr {
  color: var(--grey);
  font-family: "Noto Sans KR", sans-serif;
  font-size: 12px;
}

.ind-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--grey-light);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pip {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  vertical-align: middle;
}

.cad-daily {
  background: #ff3b3b;
}

.cad-monthly {
  background: #2da854;
}

.cad-quarterly {
  background: #5b8def;
}

.cad-annual {
  background: #f29028;
}

.status-auto {
  color: var(--auto);
}

.status-stale {
  color: var(--stale);
}

.status-manual {
  color: var(--manual);
}

.status-seed {
  color: var(--seed);
}

.ind-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ind-number {
  color: var(--ink);
  font-family: "Bagel Fat One", cursive;
  font-size: 44px;
  line-height: 0.95;
}

.indicator.shine .ind-number {
  color: var(--secondary-dark);
}

.indicator.doom .ind-number {
  color: var(--primary-dark);
}

.ind-unit {
  padding-bottom: 6px;
  color: var(--grey);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.ind-context {
  margin-left: auto;
  padding-bottom: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-align: right;
}

.delta {
  font-size: 12px;
  font-weight: 600;
}

.delta.up {
  color: #2da854;
}

.delta.down {
  color: #c83737;
}

.delta.flat {
  color: var(--grey);
}

.vs {
  display: block;
  margin-top: 2px;
  color: var(--grey);
  font-family: "Noto Sans KR", "Source Sans 3", sans-serif;
  font-size: 11px;
}

.ind-spark {
  width: 100%;
  height: 38px;
  margin-bottom: 10px;
  display: block;
  overflow: visible;
}

.ind-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--grey);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.ind-source {
  color: var(--grey-dark);
  border-bottom: 1px dotted currentColor;
  padding-bottom: 1px;
}

#app-timeline {
  flex: 1 0 var(--col-min);
  min-width: var(--col-min);
  padding: 0 14px;
  border-left: 1px dotted var(--grey-lighter);
  background: #fff;
}

#app-timeline header {
  padding: 20px 4px 14px;
  background-image: linear-gradient(0deg, transparent 0%, #fff 50%);
}

#timeline-main {
  padding-bottom: 80px;
}

.tl-row {
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: 3px;
  color: inherit;
  font-size: 11px;
}

.tl-row:hover {
  background: var(--secondary-lighter);
}

.tl-date {
  flex: 0 0 64px;
  color: var(--grey);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-align: right;
}

.tl-bars {
  height: 12px;
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

.tl-bar {
  height: 12px;
  border: 1px solid transparent;
  border-radius: 2px;
}

.tl-bar.cad-daily {
  background: #ffd6d6;
  border-color: #ff8a8a;
}

.tl-bar.cad-monthly {
  background: #cdffc0;
  border-color: #9fee8b;
}

.tl-bar.cad-quarterly {
  background: #d6e6ff;
  border-color: #94b6f5;
}

.tl-bar.cad-annual {
  background: #ffe1c2;
  border-color: #f4b87a;
}

.is-month-marker {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--grey-lighter);
}

.is-month-marker .tl-date {
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.tl-month-label {
  flex: 1;
  color: var(--grey-dark);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tl-legend {
  margin-top: 16px;
  padding: 10px 4px;
  border-top: 1px dashed var(--grey-lighter);
  color: var(--grey);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.empty-state,
.noscript {
  padding: 40px 0;
  color: var(--grey);
  text-align: center;
}

@media (max-width: 1100px) {
  #app-timeline {
    display: none;
  }
}

@media (max-width: 900px) {
  .live-status {
    display: none;
  }
}

@media (max-width: 740px) {
  #app-filters {
    display: none;
  }

  .brand-label {
    display: none;
  }

  #app-feed {
    padding: 0 14px;
  }

  #app-topics {
    width: calc(100% - var(--rail-w));
  }

  .feed-tabs {
    align-items: stretch;
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .feed-tabs button {
    padding: 8px 10px;
  }

  .indicator {
    gap: 12px;
  }

  .ind-icon {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    font-size: 22px;
  }

  .ind-number {
    font-size: 36px;
  }

  .ind-context {
    width: 100%;
    margin-left: 0;
    padding-bottom: 0;
    text-align: left;
  }

  .ind-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
