:root {
  --ink: #14211d;
  --ink-soft: #43514c;
  --paper: #f2efe6;
  --paper-bright: #fbf8ef;
  --line: rgba(20, 33, 29, 0.17);
  --green: #173f34;
  --green-deep: #0d2d25;
  --red: #be3b2f;
  --red-soft: #f1d5cf;
  --gold: #bd8b3a;
  --white: #fffdf7;
  --shadow: 0 24px 70px rgba(18, 42, 34, 0.12);
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: var(--sans); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at 12% 0%, rgba(189, 139, 58, 0.13), transparent 27rem),
    linear-gradient(180deg, #f8f5ec 0%, var(--paper) 42%, #ebe7dc 100%);
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}
.skip-link {
  position: fixed; left: 1rem; top: -4rem; z-index: 100; padding: 0.7rem 1rem;
  color: var(--white); background: var(--green); border-radius: 0 0 0.45rem 0.45rem;
}
.skip-link:focus { top: 0; }

.masthead {
  min-height: 19rem;
  padding: 3.25rem max(4vw, 2rem) 4.4rem;
  display: flex; justify-content: space-between; gap: 3rem;
  color: var(--white);
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 4.5rem 4.5rem,
    linear-gradient(20deg, var(--green-deep), var(--green));
  border-bottom: 0.38rem solid var(--red);
  position: relative; overflow: hidden;
}
.masthead::after {
  content: "LONG MONEY"; position: absolute; right: -1.2rem; bottom: -3.7rem;
  font-family: var(--serif); font-size: clamp(5rem, 11vw, 10rem); font-weight: 900;
  letter-spacing: -0.06em; color: transparent; -webkit-text-stroke: 1px rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.masthead-compact {
  min-height: 11.5rem;
  padding: 1.8rem max(4vw, 2rem) 3.4rem;
}
.masthead-compact .brand-block h1 {
  font-size: clamp(2.4rem, 5vw, 4.2rem);
}
.masthead-compact .subtitle { margin-top: 0.7rem; }
.masthead-compact::after { font-size: clamp(4rem, 8vw, 7rem); bottom: -2.6rem; }
.brand-block, .masthead-actions { position: relative; z-index: 1; }
.eyebrow {
  margin: 0 0 0.9rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold);
}
.brand-block h1 {
  margin: 0; font-family: var(--serif); font-size: clamp(3.5rem, 7vw, 6.4rem);
  font-weight: 900; line-height: 0.95; letter-spacing: -0.07em;
}
.subtitle { margin: 1.3rem 0 0; color: rgba(255, 253, 247, 0.69); font-size: 0.95rem; letter-spacing: 0.06em; }
.masthead-actions { display: flex; align-items: flex-start; gap: 1rem; }
.update-meta {
  min-height: 2.9rem; padding: 0.78rem 1rem; display: flex; align-items: center; gap: 0.55rem;
  color: rgba(255, 253, 247, 0.75); border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.055); backdrop-filter: blur(10px); font-size: 0.78rem;
}
.status-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%; flex: 0 0 auto;
  background: #76bf9e; box-shadow: 0 0 0 0.24rem rgba(118, 191, 158, 0.12);
}
.status-dot.is-running { background: #f3b53f; animation: pulse 1.35s infinite; }
.button {
  min-height: 2.9rem; border: 0; border-radius: 0; cursor: pointer; font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}
.button:hover { transform: translateY(-2px); }
.button:disabled { cursor: wait; opacity: 0.62; transform: none; }
.button-primary {
  padding: 0.75rem 1.15rem; display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--white); background: var(--red); box-shadow: 0.35rem 0.35rem 0 rgba(0, 0, 0, 0.18);
}
.button-primary svg, .input-shell svg {
  width: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8;
}
.button-primary.is-running svg { animation: spin 1s linear infinite; }

main { width: min(94rem, calc(100% - 2rem)); margin: -2.5rem auto 0; position: relative; z-index: 2; }
.hero-grid {
  display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); border: 1px solid var(--line);
  background: var(--paper-bright); box-shadow: var(--shadow); animation: rise 650ms both;
}
.lead-card, .metric-card {
  min-height: 11rem; padding: 1.45rem 1.6rem 1.3rem; display: flex; flex-direction: column;
  position: relative; border-right: 1px solid var(--line);
}
.metric-card:last-child { border-right: 0; }
.lead-card { color: var(--white); background: var(--red); }
.card-index {
  position: absolute; right: 1rem; top: 0.85rem; color: rgba(20, 33, 29, 0.28);
  font-family: var(--serif); font-size: 0.72rem; font-weight: 900;
}
.lead-card .card-index { color: rgba(255, 255, 255, 0.42); }
.lead-card p, .metric-card p { margin: 0; font-size: 0.73rem; font-weight: 700; letter-spacing: 0.1em; }
.lead-card strong, .metric-card strong {
  margin: auto 0 0.2rem; font-family: var(--serif); font-size: clamp(2.1rem, 3.6vw, 3.5rem);
  font-weight: 900; line-height: 1; letter-spacing: -0.06em;
}
.metric-card.accent-red strong { color: var(--red); }
.card-note { margin-top: 0.45rem; color: var(--ink-soft); font-size: 0.72rem; }
.lead-card .card-note { color: rgba(255, 255, 255, 0.68); }

.workspace {
  margin-top: 2.2rem; padding: 2.3rem; background: rgba(251, 248, 239, 0.88);
  min-width: 0;
  border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(18, 42, 34, 0.07);
  animation: rise 650ms 100ms both;
}
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.section-heading h2, .source-note h2 {
  margin: 0; font-family: var(--serif); font-size: 2rem; letter-spacing: -0.05em;
}
.view-actions { display: flex; align-items: center; gap: 1rem; color: var(--ink-soft); font-size: 0.78rem; }
.button-ghost { padding: 0.65rem 0.9rem; color: var(--green); background: transparent; border: 1px solid var(--green); }
.button-ghost-light {
  padding: 0.75rem 1.15rem;
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.category-tabs { margin-top: 1.8rem; display: flex; border-bottom: 1px solid var(--line); }
.category-tab {
  padding: 0.8rem 1.15rem; color: var(--ink-soft); border: 0; border-bottom: 3px solid transparent;
  background: transparent; cursor: pointer; font-weight: 700;
}
.category-tab.is-active { color: var(--red); border-bottom-color: var(--red); }
.filters {
  margin: 1.25rem 0; display: grid;
  grid-template-columns: minmax(16rem, 1.8fr) repeat(3, minmax(9rem, 1fr)) auto;
  gap: 0.8rem; align-items: end;
}
.field {
  display: grid; gap: 0.38rem; color: var(--ink-soft); font-size: 0.68rem;
  font-weight: 700; letter-spacing: 0.06em;
}
.field input, .field select, .pagination select {
  width: 100%; min-height: 2.65rem; padding: 0.55rem 0.7rem; color: var(--ink);
  background: var(--white); border: 1px solid var(--line); border-radius: 0;
}
.input-shell { display: flex; align-items: center; color: var(--ink-soft); background: var(--white); border: 1px solid var(--line); }
.input-shell svg { margin-left: 0.7rem; }
.input-shell input { border: 0; background: transparent; }
.button-reset { padding: 0.55rem 0.85rem; color: var(--ink-soft); background: #e9e5d9; border: 1px solid var(--line); }
.scroll-hint {
  display: none;
  margin: -0.35rem 0 0.7rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  text-align: right;
}
.table-frame {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
table { width: 100%; min-width: 76rem; border-collapse: collapse; font-size: 0.76rem; }
th {
  padding: 0; color: var(--ink-soft); background: #e8e3d6; border-bottom: 1px solid var(--line);
  text-align: left; white-space: nowrap;
}
th button {
  width: 100%; padding: 0.76rem 0.72rem; display: flex; justify-content: space-between; gap: 0.4rem;
  color: inherit; border: 0; background: transparent; cursor: pointer; font-size: inherit; font-weight: 700; text-align: left;
}
th.numeric button { text-align: right; }
td { padding: 0.82rem 0.72rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: rgba(189, 139, 58, 0.09); }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.stock-cell strong, .fund-cell strong { display: block; font-weight: 700; }
.stock-cell span, .fund-cell span { color: var(--ink-soft); font-size: 0.67rem; }
.badge {
  display: inline-flex; padding: 0.23rem 0.5rem; align-items: center; font-size: 0.66rem;
  font-weight: 700; white-space: nowrap; border: 1px solid currentColor;
}
.badge-social { color: #285d4d; background: #d9e8df; }
.badge-pension { color: #8b6429; background: #eee1c8; }
.badge-exec { color: #6b2b26; background: #f3ddd8; }
.badge-holder { color: #175d8f; background: #d9e8f3; }
.badge-leader-strong { color: #9f2d25; background: var(--red-soft); }
.badge-leader-weak { color: #8b6429; background: #eee1c8; }
.badge-watch { color: #6b4a12; background: #f3e3b8; }
.change-new { color: #175d8f; background: #d9e8f3; }
.change-up { color: #9f2d25; background: var(--red-soft); }
.change-down { color: #2c6a54; background: #d8e9df; }
.source-link {
  display: inline-grid; width: 1.8rem; height: 1.8rem; place-items: center; color: var(--green);
  border: 1px solid var(--line); text-decoration: none;
}
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-state span { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }
.empty-state p { color: var(--ink-soft); }
.pagination {
  padding-top: 1rem; display: flex; justify-content: space-between; align-items: center;
  color: var(--ink-soft); font-size: 0.72rem;
}
.pagination label { display: flex; align-items: center; gap: 0.5rem; }
.pagination select { min-height: 2rem; width: auto; padding: 0.25rem 1.7rem 0.25rem 0.45rem; }
.pagination-controls { display: flex; align-items: center; gap: 0.8rem; }
.page-button { width: 2.25rem; height: 2.25rem; color: var(--ink); border: 1px solid var(--line); background: var(--white); cursor: pointer; }
.page-button:disabled { opacity: 0.35; cursor: not-allowed; }

.board {
  margin-top: 2.2rem;
  display: grid;
  grid-template-columns: 22rem minmax(0, 1fr);
  min-height: 46rem;
  background: rgba(251, 248, 239, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 650ms 100ms both;
}
.stock-pane {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.3rem 1.15rem 1.1rem;
  border-right: 1px solid var(--line);
  background: #f7f3e8;
  min-width: 0;
}
.pane-heading { display: grid; gap: 0.15rem; }
.pane-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}
.pane-heading #result-count { color: var(--ink-soft); font-size: 0.72rem; }
.stock-filters { margin-top: 0; overflow-x: auto; }
.stock-filters .category-tab { padding: 0.55rem 0.62rem; font-size: 0.72rem; flex: 0 0 auto; }
.leader-filters { margin-top: 0.1rem; overflow-x: auto; }
.leader-filters .category-tab { padding: 0.42rem 0.62rem; font-size: 0.72rem; flex: 0 0 auto; }
.stock-list {
  flex: 1;
  min-height: 16rem;
  max-height: calc(100vh - 18rem);
  overflow: auto;
  border-top: 2px solid var(--ink);
}
.stock-item {
  width: 100%;
  padding: 0.55rem 0.45rem 0.55rem 0.55rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  color: inherit;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.stock-item:hover { background: rgba(189, 139, 58, 0.1); }
.stock-item.is-selected {
  background: #efe4cc;
  box-shadow: inset 3px 0 0 var(--red);
}
.stock-item-main {
  min-width: 0;
  display: grid;
  gap: 0.28rem;
  color: inherit;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.watch-toggle {
  align-self: start;
  margin-top: 0.12rem;
  padding: 0.22rem 0.4rem;
  color: var(--ink-soft);
  background: #efeae0;
  border: 1px solid var(--line);
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.watch-toggle.is-on,
.stock-item.is-watching .watch-toggle {
  color: #6b4a12;
  background: #f3e3b8;
  border-color: #c9a24a;
}
.stock-item-top, .stock-item-mid {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
}
.stock-item-top strong { font-size: 0.88rem; }
.stock-item-top em {
  font-style: normal;
  font-family: var(--serif);
  font-weight: 800;
  color: var(--red);
}
.stock-item-mid { color: var(--ink-soft); font-size: 0.68rem; font-variant-numeric: tabular-nums; }
.stock-item-badges { display: flex; flex-wrap: wrap; gap: 0.28rem; }
.mini-badge {
  padding: 0.12rem 0.36rem;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid currentColor;
}
.chart-pane { min-width: 0; display: flex; flex-direction: column; background: #fbf8ef; }
.chart-toolbar {
  padding: 1.2rem 1.3rem 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
}
.chart-toolbar h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  letter-spacing: -0.04em;
}
.chart-sub { margin: 0.35rem 0 0; color: var(--ink-soft); font-size: 0.74rem; }
.chart-toolbar-right { display: grid; gap: 0.55rem; justify-items: end; }
.interval-tabs { display: flex; border: 1px solid var(--line); }
.interval-tab {
  min-width: 3.2rem;
  padding: 0.38rem 0.7rem;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.interval-tab.is-active { color: var(--red); background: #efe4cc; }
.legend-row { display: flex; flex-wrap: wrap; gap: 0.7rem; font-size: 0.68rem; font-weight: 700; }
.legend-dot { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-soft); }
.legend-dot::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: currentColor;
}
.legend-dot.social { color: #285d4d; }
.legend-dot.pension { color: var(--gold); }
.legend-dot.fund-up { color: #e3b341; }
.legend-dot.exec-up { color: var(--red); }
.legend-dot.exec-down { color: var(--green-deep); }
.chart-stage {
  position: relative;
  min-height: 28rem;
  margin: 0 1.1rem;
  background:
    linear-gradient(180deg, rgba(255,253,247,0.04), transparent 30%),
    #10241e;
  border: 1px solid rgba(13, 45, 37, 0.55);
}
#kline-chart { width: 100%; height: 28rem; position: relative; z-index: 1; }
.chart-empty, .chart-unavailable {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  text-align: center;
  color: #fffdf7;
  pointer-events: none;
}
.chart-empty[hidden],
.chart-unavailable[hidden],
#kline-chart[hidden] {
  display: none !important;
}
.chart-empty span, .chart-unavailable span {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
}
.chart-empty p, .chart-unavailable p {
  margin: 0.4rem 0 0;
  color: rgba(255,253,247,0.62);
  font-size: 0.78rem;
}
.event-table-wrap { padding: 1.1rem 1.2rem 1.3rem; }
.event-table-wrap th { padding: 0.76rem 0.72rem; }
.section-heading.compact {
  align-items: baseline;
  margin-bottom: 0.55rem;
}
.section-heading.compact h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
}
.section-heading.compact span { color: var(--ink-soft); font-size: 0.72rem; }
.event-table-wrap table { min-width: 48rem; }
.empty-state.compact { padding: 2rem 1rem; }
tbody tr.is-flash { background: rgba(190, 59, 47, 0.16); }

.source-note {
  margin: 1.25rem 0 3rem; padding: 1.5rem; display: grid; grid-template-columns: auto 1fr auto;
  gap: 1.2rem; align-items: center; color: rgba(255, 253, 247, 0.78); background: var(--green-deep);
}
.source-note h2 { color: var(--white); font-size: 1rem; }
.source-note p { max-width: 62rem; margin: 0.35rem 0 0; font-size: 0.72rem; line-height: 1.7; }
.source-note a { color: #e9c98d; font-size: 0.76rem; font-weight: 700; text-decoration: none; }
.source-mark {
  display: grid; width: 3rem; height: 3rem; place-items: center; color: var(--white);
  background: var(--red); font-family: var(--serif); font-size: 1.25rem; font-weight: 900;
}
.toast {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 20; max-width: min(26rem, calc(100vw - 2.5rem));
  padding: 0.9rem 1.05rem; color: var(--white); background: var(--green-deep); box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(150%); transition: transform 240ms ease; font-size: 0.78rem;
}
.toast.is-visible { transform: translateY(0); }
.visually-hidden, .sr-live {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 0.5rem rgba(243, 181, 63, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .lead-card, .metric-card { border-bottom: 1px solid var(--line); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .field-search { grid-column: 1 / -1; }
  .board { grid-template-columns: 1fr; }
  .stock-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .stock-list { max-height: 22rem; }
}
@media (max-width: 720px) {
  .masthead, .masthead-compact { min-height: 18rem; padding: 2rem 1rem 4.2rem; flex-direction: column; justify-content: flex-start; }
  .masthead-actions { width: 100%; display: grid; }
  .update-meta { order: 2; }
  main { width: calc(100% - 1rem); }
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .lead-card, .metric-card { min-height: 9.6rem; padding: 1.1rem; }
  .workspace { padding: 1.2rem 0.75rem; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .view-actions { width: 100%; justify-content: space-between; }
  .category-tabs { overflow-x: auto; }
  .category-tab { flex: 0 0 auto; }
  .filters { grid-template-columns: 1fr; }
  .field-search { grid-column: auto; }
  .scroll-hint { display: block; }
  .source-note { grid-template-columns: auto 1fr; }
  .source-note a { grid-column: 2; }
  .chart-toolbar { flex-direction: column; align-items: flex-start; }
  #kline-chart, .chart-stage { min-height: 22rem; height: 22rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important; animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
  }
}
