:root {
  --canvas: #ffffff;
  --surface-soft: #f5f5f5;
  --ink: #111111;
  --muted: #6f6f6f;
  --subtle: #a0a0a0;
  --border: #e6e6e6;
  --accent: #e60023;
  --accent-hover: #ad081b;
  --radius-card: 16px;
  --radius-pill: 999px;
  --topbar-height: 76px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Arial, "Noto Sans KR", sans-serif; line-height: 1.45; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar { position: sticky; top: 0; z-index: 100; min-height: var(--topbar-height); padding: 12px 24px; display: grid; grid-template-columns: auto auto minmax(240px, 1fr) auto; align-items: center; gap: 16px; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid rgba(230, 230, 230, 0.8); backdrop-filter: blur(16px); }
.wordmark { color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 900; }
.primary-nav { display: flex; align-items: center; gap: 4px; }
.nav-item { min-height: 44px; padding: 0 15px; display: inline-flex; align-items: center; gap: 7px; color: #4b4b4b; background: transparent; border: 0; border-radius: var(--radius-pill); font-weight: 700; }
.nav-item:hover, .nav-item:focus-visible { background: var(--surface-soft); }
.nav-item.is-active { color: #fff; background: var(--ink); }
.nav-item span { min-width: 20px; font-size: 11px; text-align: center; }
.global-search { position: relative; display: block; }
.search-icon { position: absolute; left: 18px; top: 50%; width: 15px; height: 15px; border: 2px solid #6f6f6f; border-radius: 50%; transform: translateY(-58%); pointer-events: none; }
.search-icon::after { content: ""; position: absolute; right: -5px; bottom: -3px; width: 7px; height: 2px; background: #6f6f6f; transform: rotate(45deg); border-radius: 2px; }
.global-search input { width: 100%; min-height: 50px; padding: 0 20px 0 46px; color: var(--ink); background: #f1f1f1; border: 0; border-radius: var(--radius-pill); outline: none; font-size: 15px; }
.global-search input:focus { background: #fff; box-shadow: 0 0 0 3px #8ab4f8; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.quiet-button { min-height: 42px; padding: 0 14px; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-pill); font-weight: 700; }
.quiet-button:hover, .quiet-button:focus-visible { background: var(--surface-soft); }
.agent-button { min-height: 42px; padding: 0 16px; color: #fff; background: var(--ink); border: 0; border-radius: var(--radius-pill); font-weight: 800; }
.agent-button:hover, .agent-button:focus-visible { background: #333; }
.profile-chip { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: #2f6f63; border-radius: 50%; font-weight: 800; }

.main-content { width: min(100%, 1880px); margin: 0 auto; padding: 42px 24px 80px; }
.discovery-header { padding: 16px 0 28px; text-align: center; }
.date-line { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.discovery-header h1 { margin-bottom: 8px; font-size: 38px; line-height: 1.15; }
.discovery-header > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.filter-dock { position: sticky; top: var(--topbar-height); z-index: 80; margin: 0 -8px 28px; padding: 10px 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(14px); }
.source-tabs, .period-control { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.source-tabs::-webkit-scrollbar, .period-control::-webkit-scrollbar { display: none; }
.source-tab, .period-control button { min-height: 40px; padding: 0 15px; flex: 0 0 auto; white-space: nowrap; color: #3d3d3d; background: var(--surface-soft); border: 0; border-radius: var(--radius-pill); font-size: 13px; font-weight: 700; }
.source-tab:hover, .source-tab:focus-visible, .period-control button:hover, .period-control button:focus-visible { background: #e8e8e8; }
.source-tab.is-active, .period-control button.is-active { color: #fff; background: var(--ink); }
.source-tab span { margin-left: 3px; opacity: 0.65; }

.view-panel[hidden], .empty-state[hidden], .sample-notice[hidden] { display: none; }
.section-heading { margin-bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin-bottom: 0; font-size: 18px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.trend-grid { column-count: 6; column-gap: 16px; }
.trend-card { position: relative; width: 100%; margin: 0 0 26px; display: inline-block; break-inside: avoid; vertical-align: top; }
.trend-media { position: relative; overflow: hidden; background: var(--surface-soft); border-radius: var(--radius-card); }
.trend-media::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0); transition: background 160ms ease; pointer-events: none; }
.trend-card:hover .trend-media::after, .trend-card:focus-within .trend-media::after { background: rgba(0, 0, 0, 0.12); }
.trend-media img { width: 100%; height: auto; min-height: 160px; display: block; object-fit: cover; }
.trend-media-fallback { min-height: 210px; padding: 22px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; color: #fff; background: #252525; }
.trend-media-fallback strong { font-size: 16px; }
.trend-media-fallback span { color: #c7c7c7; font-size: 11px; }
.source-badge { position: absolute; left: 12px; bottom: 12px; z-index: 2; padding: 5px 9px; color: #fff; background: rgba(0, 0, 0, 0.68); border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; opacity: 0; transform: translateY(4px); transition: opacity 160ms ease, transform 160ms ease; }
.trend-card:hover .source-badge, .trend-card:focus-within .source-badge { opacity: 1; transform: translateY(0); }
.save-action { position: absolute; top: 12px; right: 12px; z-index: 3; min-height: 42px; padding: 0 16px; color: #fff; background: var(--accent); border: 0; border-radius: var(--radius-pill); font-size: 13px; font-weight: 800; opacity: 0; transform: translateY(-4px); transition: opacity 160ms ease, transform 160ms ease, background 160ms ease; }
.trend-card:hover .save-action, .trend-card:focus-within .save-action, .save-action.is-saved { opacity: 1; transform: translateY(0); }
.save-action:hover, .save-action:focus-visible { background: var(--accent-hover); }
.save-action.is-saved { color: var(--ink); background: #fff; }
.trend-body { padding: 10px 8px 0; }
.trend-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.trend-card h3 { margin: 5px 0 8px; font-size: 14px; line-height: 1.4; }
.tag-list, .keyword-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list span { color: var(--muted); font-size: 10px; }
.card-actions { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
.card-actions button, .card-actions a { min-height: 30px; padding: 0; color: var(--muted); text-decoration: none; background: transparent; border: 0; font-size: 11px; font-weight: 700; }
.card-actions button:hover, .card-actions a:hover { color: var(--ink); text-decoration: underline; }

.empty-state { min-height: 480px; display: grid; place-items: center; align-content: center; text-align: center; padding: 36px; }
.empty-symbol { width: 58px; height: 58px; margin-bottom: 18px; display: grid; place-items: center; color: #fff; background: var(--ink); border-radius: 50%; font-size: 22px; font-weight: 900; }
.empty-state h3 { margin-bottom: 6px; font-size: 20px; }
.empty-state p { max-width: 440px; margin-bottom: 20px; color: var(--muted); font-size: 14px; }
.button-primary { min-height: 44px; padding: 0 18px; color: #fff; background: var(--ink); border: 0; border-radius: var(--radius-pill); font-weight: 800; }
.button-primary:hover, .button-primary:focus-visible { background: #333; }
.sample-notice { position: fixed; right: 20px; bottom: 20px; z-index: 120; padding: 10px 14px; color: #fff; background: var(--ink); border-radius: var(--radius-pill); font-size: 12px; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16); }

.report-view { padding-top: 8px; }
.report-heading { margin-bottom: 26px; align-items: flex-end; }
.report-heading h2 { max-width: 680px; font-size: 30px; line-height: 1.2; }
.report-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
.report-lead, .report-panel { min-height: 280px; padding: 26px; border: 1px solid var(--border); border-radius: var(--radius-card); background: #fff; }
.report-lead { display: flex; flex-direction: column; justify-content: flex-end; color: #fff; background: var(--ink); border-color: var(--ink); }
.report-index { display: block; margin-bottom: auto; color: var(--subtle); font-size: 11px; font-weight: 800; }
.report-lead h3 { max-width: 650px; margin-bottom: 10px; font-size: 28px; line-height: 1.25; }
.report-lead p { margin-bottom: 0; color: #c7c7c7; }
.report-panel h3 { margin-bottom: 18px; font-size: 18px; }
.keyword-list span { padding: 7px 10px; color: #333; background: var(--surface-soft); border-radius: var(--radius-pill); font-size: 11px; }
.source-breakdown { display: grid; gap: 12px; }
.source-row { display: grid; grid-template-columns: 64px 1fr 22px; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.source-bar { height: 6px; overflow: hidden; background: #ededed; border-radius: var(--radius-pill); }
.source-bar i { display: block; height: 100%; background: var(--ink); border-radius: inherit; }

.agent-backdrop { position: fixed; inset: 0; z-index: 180; background: rgba(0, 0, 0, 0.28); backdrop-filter: blur(2px); }
.agent-panel { position: fixed; top: 0; right: 0; z-index: 190; width: min(440px, 100%); height: 100dvh; padding: 22px; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto auto; gap: 14px; background: #fff; border-left: 1px solid var(--border); box-shadow: -18px 0 48px rgba(0, 0, 0, 0.12); }
.agent-panel[hidden], .agent-backdrop[hidden] { display: none; }
body.agent-open { overflow: hidden; }
.agent-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.agent-kicker { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.agent-header h2 { margin-bottom: 0; font-size: 23px; }
.agent-close { width: 44px; height: 44px; flex: 0 0 44px; color: var(--ink); background: var(--surface-soft); border: 0; border-radius: 50%; font-size: 24px; line-height: 1; }
.agent-close:hover, .agent-close:focus-visible { background: #e8e8e8; }
.agent-status { padding: 9px 12px; color: #7a5c00; background: #fff7d6; border-radius: 8px; font-size: 12px; }
.agent-status.is-ready { color: #17613a; background: #e8f6ee; }
.agent-messages { min-height: 0; padding: 8px 2px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.agent-message { max-width: 88%; padding: 12px 14px; white-space: pre-wrap; border-radius: 14px; font-size: 14px; line-height: 1.55; }
.agent-message.is-agent { align-self: flex-start; background: var(--surface-soft); border-bottom-left-radius: 4px; }
.agent-message.is-user { align-self: flex-end; color: #fff; background: var(--ink); border-bottom-right-radius: 4px; }
.agent-suggestions { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.agent-suggestions::-webkit-scrollbar { display: none; }
.agent-suggestions button { min-height: 38px; padding: 0 12px; flex: 0 0 auto; color: #333; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.agent-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.agent-form textarea { width: 100%; min-height: 52px; max-height: 140px; resize: vertical; padding: 12px 14px; color: var(--ink); background: #fff; border: 1px solid #cfcfcf; border-radius: 14px; outline: none; }
.agent-form textarea:focus { border-color: #111; box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.08); }
.agent-form button { min-width: 72px; min-height: 48px; padding: 0 14px; color: #fff; background: var(--accent); border: 0; border-radius: 14px; font-weight: 800; }
.agent-form button:disabled { cursor: wait; opacity: 0.55; }
.agent-note { margin-bottom: 0; color: var(--muted); font-size: 10px; }

@media (max-width: 1500px) { .trend-grid { column-count: 5; } }
@media (max-width: 1180px) { .trend-grid { column-count: 4; } .report-grid { grid-template-columns: 1fr 1fr; } .report-lead { grid-column: 1 / -1; } }
@media (max-width: 860px) {
  :root { --topbar-height: 132px; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 10px 16px; gap: 8px 12px; }
  .wordmark { font-size: 20px; }
  .primary-nav { justify-self: center; }
  .global-search { grid-column: 1 / -1; grid-row: 2; }
  .global-search input { min-height: 46px; }
  .quiet-button { display: none; }
  .agent-button { min-height: 40px; padding: 0 12px; font-size: 12px; }
  .profile-chip { width: 38px; height: 38px; }
  .main-content { padding: 28px 16px 64px; }
  .discovery-header h1 { font-size: 32px; }
  .filter-dock { align-items: stretch; flex-direction: column; margin-bottom: 20px; }
  .period-control { padding-bottom: 2px; }
  .trend-grid { column-count: 3; column-gap: 12px; }
  .trend-card { margin-bottom: 20px; }
}
@media (max-width: 620px) {
  :root { --topbar-height: 132px; }
  .topbar { padding: 8px 12px; }
  .wordmark { font-size: 19px; }
  .nav-item { min-height: 44px; padding: 0 10px; font-size: 12px; }
  .profile-chip { width: 34px; height: 34px; font-size: 12px; }
  .agent-panel { width: 100%; padding: 18px 14px max(14px, env(safe-area-inset-bottom)); }
  .global-search input { min-height: 44px; font-size: 14px; }
  .main-content { padding: 22px 10px 52px; }
  .discovery-header { padding: 8px 8px 22px; }
  .discovery-header h1 { font-size: 27px; }
  .discovery-header > p:last-child { font-size: 13px; }
  .filter-dock { margin-left: -2px; margin-right: -2px; padding-left: 2px; padding-right: 2px; }
  .source-tab, .period-control button { min-height: 44px; padding: 0 13px; font-size: 12px; }
  .section-heading { padding: 0 4px; }
  .trend-grid { column-count: 2; column-gap: 10px; }
  .trend-card { margin-bottom: 18px; }
  .trend-media { border-radius: 13px; }
  .trend-body { padding: 8px 4px 0; }
  .trend-card h3 { font-size: 12px; }
  .trend-meta { font-size: 9px; }
  .tag-list { display: none; }
  .save-action { min-height: 44px; padding: 0 13px; opacity: 1; transform: none; }
  .source-badge { display: none; }
  .card-actions { margin-top: 5px; }
  .card-actions button, .card-actions a { font-size: 10px; }
  .report-heading h2 { font-size: 24px; }
  .report-grid { grid-template-columns: 1fr; }
  .report-lead { grid-column: auto; min-height: 260px; }
  .report-lead h3 { font-size: 24px; }
  .report-panel { min-height: 220px; }
}
