:root {
  --paper: #f4efe1;
  --paper-2: #fbf8ef;
  --ink: #151515;
  --muted: #716f68;
  --line: #d8d1bf;
  --sidebar: #111111;
  --sidebar-muted: #a4a39e;
  --pink: #ef91c5;
  --pink-soft: #f7d9e9;
  --yellow: #f3d665;
  --yellow-soft: #f7ecc0;
  --blue: #acc4e8;
  --blue-soft: #dce7f6;
  --violet: #c9b6e8;
  --violet-soft: #e7ddf4;
  --green: #b8d9b3;
  --green-soft: #dfefdc;
  --orange: #edb676;
  --orange-soft: #f6dfc4;
  --teal: #89c9c1;
  --teal-soft: #d9eeeb;
  --shadow: 0 18px 55px rgba(43, 37, 25, 0.12);
  font-family: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: #e8dfcb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  padding: 0;
  background: var(--paper);
  letter-spacing: 0;
}

html { -webkit-text-size-adjust: 100%; }

button, input, select { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }

.app-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: var(--paper-2);
  box-shadow: none;
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  margin: 16px 0 16px 16px;
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 32px);
  min-height: 0;
  overflow-y: auto;
  border-radius: 16px;
  background: var(--sidebar);
  color: #fff;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px 24px;
  font-size: 25px;
  font-weight: 700;
}

.brand small { color: var(--pink); font-size: 11px; font-weight: 600; text-transform: uppercase; }

.main-nav { display: grid; gap: 5px; }

.nav-button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.nav-button:hover { color: #fff; background: #202020; }
.nav-button.active { color: #fff; background: #292424; box-shadow: inset 3px 0 var(--pink); }
.nav-icon { width: 24px; text-align: center; font-size: 16px; }
.nav-count { color: #777; font-size: 11px; font-variant-numeric: tabular-nums; }

.sidebar-foot {
  margin-top: auto;
  padding: 18px 10px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #777;
  font-size: 10px;
  line-height: 1.35;
}

.sync-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--green); }

.workspace { min-width: 0; padding: 28px 30px 34px; }

.topbar { display: flex; align-items: center; gap: 14px; }

.search-field {
  height: 44px;
  flex: 1;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  max-width: 830px;
  padding: 0 12px;
  border: 1px solid #bdb6a6;
  border-radius: 22px;
  background: var(--paper-2);
}

.search-field:focus-within { border-color: var(--ink); box-shadow: 0 0 0 2px var(--pink-soft); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder { color: #918d83; }
.search-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--pink); font-size: 20px; }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; background: #eee8d9; color: var(--muted); font-size: 10px; }

.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 18px; }
.icon-button:hover, .icon-button.active { background: var(--pink); color: var(--ink); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 34px 0 22px;
}

.eyebrow { margin: 0 0 7px; color: #a05a7e; font-size: 11px; font-weight: 700; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 42px); line-height: 1.05; letter-spacing: 0; }
.subtitle { margin: 9px 0 0; color: var(--muted); font-size: 13px; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.filters select {
  width: 146px;
  height: 37px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eee8d9;
  color: var(--ink);
  font-size: 12px;
}

.content { min-height: 500px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  min-height: 104px;
  padding: 16px;
  border: 1px solid rgba(25,25,25,.08);
  border-radius: 8px;
  background: #ebe6da;
}
.stat-card.pink { background: var(--pink-soft); }
.stat-card.yellow { background: var(--yellow-soft); }
.stat-card.blue { background: var(--blue-soft); }
.stat-card.green { background: var(--green-soft); }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { margin-top: 8px; font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { margin-top: 3px; color: var(--muted); font-size: 10px; }

.section-row { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr); gap: 12px; margin-bottom: 20px; }
.section-block { min-width: 0; padding: 17px; border-top: 2px solid var(--ink); background: rgba(255,255,255,.28); }
.section-block h2, .section-heading h2 { margin: 0; font-size: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading span { color: var(--muted); font-size: 11px; }

.trend-chart { height: 190px; display: flex; align-items: end; gap: 8px; padding-top: 18px; overflow: hidden; }
.trend-month { min-width: 34px; height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.trend-stack { width: min(42px, 100%); height: 145px; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 5px 5px 2px 2px; overflow: hidden; background: #e4ded0; }
.trend-segment { width: 100%; min-height: 2px; transition: height .2s ease; }
.trend-label { color: var(--muted); font-size: 10px; white-space: nowrap; }

.topic-list { display: grid; gap: 10px; }
.topic-row { display: grid; grid-template-columns: 95px minmax(0, 1fr) 48px; align-items: center; gap: 9px; font-size: 11px; }
.topic-track { height: 9px; border-radius: 5px; background: #e0dacc; overflow: hidden; }
.topic-fill { height: 100%; border-radius: inherit; }
.topic-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.intel-card, .product-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(30,30,30,.08);
  border-radius: 8px;
  background: #ebe7dc;
}
.intel-card[data-tone="overseas"] { background: var(--yellow-soft); }
.intel-card[data-tone="product"] { background: var(--pink-soft); }
.intel-card[data-tone="growth"] { background: var(--blue-soft); }
.intel-card[data-tone="technology"] { background: var(--violet-soft); }
.intel-card[data-tone="monetization"] { background: var(--green-soft); }
.intel-card[data-tone="method"] { background: var(--orange-soft); }
.intel-card[data-tone="opportunity"] { background: var(--teal-soft); }
.card-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.card-meta strong { color: var(--ink); font-size: 11px; }
.meta-spacer { margin-left: auto; }
.card-title { margin: 11px 0 7px; font-size: 14px; line-height: 1.4; }
.card-copy { margin: 0; color: #494842; font-size: 12px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.card-copy.expanded { display: block; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: 13px; }
.text-button { padding: 0; border: 0; background: transparent; color: #6d4f60; font-size: 11px; font-weight: 600; }
.bookmark-button { margin-left: auto; width: 28px; height: 28px; border: 1px solid rgba(0,0,0,.14); border-radius: 50%; background: rgba(255,255,255,.42); }
.bookmark-button.active { background: var(--ink); color: #fff; }

.tag-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.tag { padding: 3px 6px; border-radius: 4px; background: rgba(255,255,255,.5); color: #4c4a44; font-size: 9px; }
.url-row { display: grid; gap: 5px; margin-top: 9px; }
.url-row a { color: #553848; font-size: 10px; overflow-wrap: anywhere; }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 13px; }
.toolbar .result-count { margin-right: auto; color: var(--muted); font-size: 11px; }
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: #e8e2d4; }
.segmented button { padding: 7px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 10px; }
.segmented button.active { background: var(--ink); color: #fff; }

.load-more { width: 100%; margin-top: 14px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #eee8da; color: var(--ink); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.product-card:nth-child(4n+1) { background: var(--yellow-soft); }
.product-card:nth-child(4n+2) { background: var(--pink-soft); }
.product-card:nth-child(4n+3) { background: var(--blue-soft); }
.product-card:nth-child(4n+4) { background: var(--green-soft); }
.product-domain { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.product-card h3 { margin: 9px 0 7px; font-size: 15px; text-transform: capitalize; overflow-wrap: anywhere; }
.product-card p { margin: 0; color: #4d4a43; font-size: 11px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.product-stats { display: flex; gap: 12px; margin: 12px 0; color: var(--muted); font-size: 10px; }
.product-card a { color: var(--ink); font-size: 11px; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { padding: 9px 8px; border-bottom: 2px solid var(--ink); color: var(--muted); text-align: left; font-size: 10px; font-weight: 500; }
.data-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.data-table .number { width: 74px; text-align: right; font-variant-numeric: tabular-nums; }
.data-table .date { width: 90px; white-space: nowrap; }
.data-table .source { width: 170px; }
.link-cell a { color: var(--ink); font-weight: 600; }
.link-context { margin-top: 4px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.author-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.author-card { padding: 14px; border-top: 2px solid var(--ink); background: rgba(255,255,255,.28); }
.author-head { display: flex; align-items: start; gap: 10px; }
.avatar { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--pink); font-weight: 700; }
.author-card h3 { margin: 0 0 4px; font-size: 14px; }
.author-group { color: var(--muted); font-size: 10px; line-height: 1.35; }
.author-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 13px; }
.author-metric { padding: 7px; border-radius: 6px; background: #ebe5d7; text-align: center; }
.author-metric strong { display: block; font-size: 15px; }
.author-metric span { color: var(--muted); font-size: 9px; }

.keyword-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 11px; }
.keyword-card { padding: 16px; border-top: 5px solid var(--ink); background: #ebe6d9; }
.keyword-card[data-tone="yellow"] { border-color: var(--yellow); }
.keyword-card[data-tone="pink"] { border-color: var(--pink); }
.keyword-card[data-tone="blue"] { border-color: var(--blue); }
.keyword-card[data-tone="violet"] { border-color: var(--violet); }
.keyword-card[data-tone="green"] { border-color: var(--green); }
.keyword-card[data-tone="orange"] { border-color: var(--orange); }
.keyword-card[data-tone="teal"] { border-color: var(--teal); }
.keyword-card h3 { margin: 0 0 10px; font-size: 14px; }
.keyword-list { display: flex; gap: 6px; flex-wrap: wrap; }
.keyword-chip { padding: 5px 7px; border: 1px solid rgba(0,0,0,.12); border-radius: 5px; background: rgba(255,255,255,.43); color: var(--ink); font-size: 10px; }
.keyword-chip:hover { background: var(--ink); color: #fff; }

.empty-state { min-height: 280px; display: grid; place-content: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 16px; }

@media (max-width: 1100px) {
  .stat-grid, .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid, .author-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keyword-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1600px) {
  .workspace { padding-right: 38px; padding-left: 38px; }
  .section-row { grid-template-columns: minmax(0, 1.5fr) minmax(320px, .5fr); }
}

@media (min-width: 2100px) {
  .priority-grid, .intelligence-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  body { padding: 0; }
  .app-shell { min-height: 100vh; display: block; border: 0; border-radius: 0; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    min-height: auto;
    margin: 0;
    padding: max(13px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 13px max(14px, env(safe-area-inset-left));
    overflow: visible;
    border-radius: 0;
  }
  .brand { padding: 0 4px 10px; flex-direction: row; align-items: baseline; gap: 8px; }
  .main-nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .nav-button { width: auto; min-width: max-content; min-height: 44px; grid-template-columns: 18px 1fr; padding: 8px 10px; }
  .nav-count { display: none; }
  .sidebar-foot { display: none; }
  .workspace {
    padding: 18px max(16px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .icon-button { width: 44px; height: 44px; }
  .page-head { align-items: start; flex-direction: column; padding-top: 26px; }
  .filters { width: 100%; justify-content: start; }
  .filters label { flex: 1; min-width: 120px; }
  .filters select { width: 100%; height: 44px; }
  .section-row { grid-template-columns: 1fr; }
  .data-table .source { width: 130px; }
}

@media (max-width: 560px) {
  .topbar { align-items: stretch; }
  .search-field { max-width: none; }
  .search-field kbd { display: none; }
  .top-actions { gap: 6px; }
  .page-head { gap: 18px; padding-top: 22px; }
  h1 { font-size: 28px; }
  .stat-grid, .card-grid, .product-grid, .author-grid, .keyword-board { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-height: 90px; }
  .stat-value { font-size: 22px; }
  .trend-chart { gap: 4px; }
  .trend-label { font-size: 8px; }
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 720px; }
}

@media (display-mode: standalone) and (max-width: 820px) {
  .sidebar { padding-top: max(13px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
