:root {
  /* HP 디자인 문서 기반: 흰 종이 바탕, 니어 블랙 잉크, HP 일렉트릭 블루 하나만 포인트 */
  --bg: #f7f7f7;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink2: #3d3d3d;
  --ink3: #636363;
  --line: #e8e8e8;
  --line-strong: #c2c2c2;
  --accent: #024ad8;
  --accent-ink: #ffffff;
  --accent-soft: #c9e0fc;
  --accent-press: #0e3191;
  --signal: #024ad8;
  --star: #024ad8;
  --foot-bg: #1a1a1a;
  --foot-ink: #c2c2c2;
  --radius: 0;
  /* 주제 태그와 이미지 없는 카드의 색: 주제마다 색상(h)만 다르고 밝기는 테마가 정합니다 */
  --tag-bg: 85% 93%;
  --tag-fg: 55% 34%;
  --ph-a: 40% 90%;
  --ph-b: 45% 82%;
  --ph-fg: 45% 32%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --surface: #1a1a1a; --ink: #ffffff; --ink2: #c2c2c2; --ink3: #8e8e8e;
    --line: #292929; --line-strong: #3d3d3d; --accent: #296ef9; --accent-ink: #ffffff; --accent-soft: #0e3191; --accent-press: #024ad8; --star: #296ef9;
    --signal: #296ef9; --foot-bg: #000000; --foot-ink: #8e8e8e;
    --tag-bg: 40% 22%; --tag-fg: 90% 80%; --ph-a: 35% 19%; --ph-b: 40% 26%; --ph-fg: 80% 76%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1a1a1a; --ink: #ffffff; --ink2: #c2c2c2; --ink3: #8e8e8e;
  --line: #292929; --line-strong: #3d3d3d; --accent: #296ef9; --accent-ink: #ffffff; --accent-soft: #0e3191; --accent-press: #024ad8; --star: #296ef9;
  --signal: #296ef9; --foot-bg: #000000; --foot-ink: #8e8e8e;
  --tag-bg: 40% 22%; --tag-fg: 90% 80%; --ph-a: 35% 19%; --ph-b: 40% 26%; --ph-fg: 80% 76%;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.4; padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 0; }

.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }

/* ---------- 상단 영역 ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line);
}
.head {
  display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand actions" "tabs tabs" "search search";
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 6px 0 2px; color: var(--accent); }
.brand .mark { width: 28px; height: 28px; flex: none; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.actions { grid-area: actions; display: flex; gap: 0; margin-right: -10px; padding-top: 2px; }
.icon { background: none; border: 0; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 0; color: var(--ink); }
.icon:active, .icon:hover { background: var(--line); }

.tabbar { grid-area: tabs; position: relative; margin-inline: -16px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px 16px 6px; scrollbar-width: none; scroll-behavior: smooth; }
/* 넘칠 때 양 끝을 흐리게 하고 화살표를 띄워 좌우로 더 있다는 것을 보여 줍니다 */
.tabbar::before, .tabbar::after {
  content: ""; position: absolute; top: 0; bottom: 4px; width: 56px; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 1;
}
.tabbar::before { left: 0; background: linear-gradient(90deg, var(--bg) 30%, transparent); }
.tabbar::after { right: 0; background: linear-gradient(270deg, var(--bg) 30%, transparent); }
.tabbar.can-l::before, .tabbar.can-r::after { opacity: 1; }
.tscroll {
  position: absolute; top: 4px; z-index: 2; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 22px; line-height: 1; display: none; place-items: center;
}
.tscroll.prev { left: 6px; } .tscroll.next { right: 6px; }
.tabbar.can-l .prev, .tabbar.can-r .next { display: grid; }
.tscroll:hover { border-color: var(--ink); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; height: 32px; padding: 0 11px; border-radius: 0; border: 1px solid var(--line);
  background: transparent; color: var(--ink2); font-size: 14px; font-weight: 500; letter-spacing: -0.02em;
}
.tab:hover { border-color: var(--line-strong); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.search { grid-area: search; padding: 0 0 6px; }
.search input {
  width: 100%; height: 44px; border-radius: 0; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 0 14px; font-size: 16px; outline: none;
}
.search input:focus { border-color: var(--line-strong); }

/* 키워드 순위 탭 */
.tab .rk { font-style: normal; font-size: 11px; font-weight: 700; margin-right: 6px; color: var(--accent); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .rk { color: var(--accent-ink); opacity: .8; }
.kwnote { margin: 6px 0 0; font-size: 11.5px; color: var(--ink3); }
.kwnote::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: var(--accent); vertical-align: 0; }
body.reading .kwbar { display: none; }

.tab.more-kw { color: var(--accent); border-color: var(--accent); }
.tab.more-kw[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.sheet-head small { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--ink3); }
.kw-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; overflow-y: auto; max-height: 56vh; padding: 4px 16px 8px; }
.kw-item { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.kw-item input { position: absolute; opacity: 0; pointer-events: none; }
.kw-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-item .rk { font-style: normal; width: 18px; font-size: 12px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.kw-item:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kw-item:has(input:checked) .rk { color: var(--accent-ink); }
.kw-item:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 640px) { .kw-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- 도구 줄 ---------- */
.toolbar { display: flex; align-items: center; gap: 6px; padding-block: 6px 0; flex-wrap: wrap; }
.grow { flex: 1; }
.chip {
  height: 30px; padding: 0 10px; border-radius: 0; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; color: var(--ink);
}
.chip:hover { border-color: var(--ink3); }
.chip.on, .chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.muted { font-size: 12px; color: var(--ink3); }

.notice { margin: 10px 0 0; padding: 10px 12px; border-radius: 0; background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* ---------- 기사 카드 ---------- */
.grid { display: grid; gap: 8px; padding-block: 8px 0; grid-template-columns: minmax(0, 1fr); }
.card {
  --h: 220;
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.card[data-cat="생성형AI"] { --h: 228; }
.card[data-cat="반도체"] { --h: 188; }
.card[data-cat="로봇"] { --h: 150; }
.card[data-cat="정책"] { --h: 32; }
.card[data-cat="기업"] { --h: 338; }
.card[data-cat="연구"] { --h: 268; }
.card[data-cat="보안/윤리"] { --h: 6; }
.card[data-cat="일반"] { --h: 215; }
@media (hover: hover) { .card:hover { border-color: var(--line-strong); } }
/* 터치 기기용 누름 피드백 (이전 버전에서 가져옴) */
.card a.body:active { background: color-mix(in srgb, var(--line) 40%, transparent); }

.card a.body { display: flex; flex: 1; gap: 12px; padding: 10px 12px 2px; color: inherit; text-decoration: none; }
.media { order: 2; flex: none; }
.media img { display: block; width: 84px; height: 63px; border-radius: 0; object-fit: cover; background: var(--line); }
.ph { display: none; }
.media:has(> .ph) { display: none; }
.txt { flex: 1; min-width: 0; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--ink3);
}
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 0; background: hsl(var(--h) 55% 62%); }
.card h2 {
  margin: 4px 0 2px; font-size: 15.5px; line-height: 1.35; font-weight: 600; letter-spacing: -0.01em; word-break: keep-all;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card p {
  margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink2); word-break: keep-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cfoot { display: flex; align-items: center; gap: 6px; padding: 0 4px 0 12px; font-size: 12px; color: var(--ink3); min-height: 34px; }
.cfoot .src { color: var(--ink2); font-weight: 700; }
.bm { margin-left: auto; width: 40px; height: 34px; border: 0; background: none; display: grid; place-items: center; color: var(--ink3); }
.bm svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.bm[aria-pressed="true"] { color: var(--star); }
.bm[aria-pressed="true"] svg { fill: currentColor; }

.empty { text-align: center; color: var(--ink3); padding: 56px 16px; font-size: 14px; grid-column: 1 / -1; }
.skeleton { height: 118px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line), transparent, var(--line)); background-size: 200% 100%; animation: sk 1.2s linear infinite; opacity: .6; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .card { transition: none; } }

.more-wrap { display: grid; place-items: center; padding: 12px 0 4px; }
.more { height: 44px; padding: 0 28px; border-radius: 0; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 500; font-size: 14px; }
.more:hover, .more:active { background: var(--accent-press); }
.foot { margin-top: 24px; padding: 24px 20px calc(56px + env(safe-area-inset-bottom)); text-align: center; font-size: 13px; background: var(--foot-bg); color: var(--foot-ink); }

.foot-links { margin-top: 10px; display: flex; justify-content: center; gap: 16px; }
.foot-links a { color: inherit; }

/* ---------- 매체 선택 시트 ---------- */
dialog#sheet, dialog#kwSheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 80vh;
  border-radius: 0; background: var(--surface); color: var(--ink);
}
dialog#kwSheet::backdrop, dialog#sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.link { background: none; border: 0; color: var(--signal); font-size: 14px; padding: 8px; }
.sheet-list { overflow-y: auto; max-height: 56vh; padding: 0 12px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); font-size: 15px; }
.row input { width: 20px; height: 20px; accent-color: var(--accent); }
.row span.n { margin-left: auto; color: var(--ink3); font-size: 13px; }
.done { display: block; width: calc(100% - 32px); margin: 12px 16px calc(16px + env(safe-area-inset-bottom)); height: 48px; border: 0; border-radius: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px; }

/* ---------- 오늘의 AI 브리핑 한 줄 ---------- */
.brief { margin-top: 8px; }
.brief a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--ink); text-decoration: none; }
.brief b { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); }
.brief span { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brief i { flex: none; font-style: normal; color: var(--ink3); }

/* ---------- 상단 전광판: 많이 보도되는 소식 5건 ---------- */
.hot { margin-top: 8px; background: var(--foot-bg); color: #fff; }
.hot h2 { margin: 0; padding: 8px 14px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hot h2 span { font-weight: 400; font-size: 11.5px; color: rgba(255,255,255,.55); }
.hot ol { list-style: none; margin: 0; padding: 0; }
.hot li { --h: 220; border-bottom: 1px solid rgba(255,255,255,.08); }
.hot li:last-child { border-bottom: 0; }
.hot li[data-cat="생성형AI"] { --h: 228; } .hot li[data-cat="반도체"] { --h: 188; } .hot li[data-cat="로봇"] { --h: 150; }
.hot li[data-cat="정책"] { --h: 32; } .hot li[data-cat="기업"] { --h: 338; } .hot li[data-cat="연구"] { --h: 268; } .hot li[data-cat="보안/윤리"] { --h: 6; }
.hot a { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 14px; color: inherit; text-decoration: none; }
.hot a:hover, .hot a:active { background: rgba(255,255,255,.06); }
.hot .rk { flex: none; width: 22px; font-size: 18px; font-weight: 700; color: rgba(255,255,255,.45); font-variant-numeric: tabular-nums; }
.hot li:first-child .rk { color: #fff; }
.hot .tag { flex: none; color: rgba(255,255,255,.6); }
.hot .ht { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hot .hn { flex: none; font-size: 12px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  .hot a { gap: 10px; padding: 0 12px; }
  .hot .tag { display: none; }
  .hot .ht { font-size: 14.5px; }
}
@media (min-width: 960px) { .hot .ht { font-size: 15.5px; } .hot a { min-height: 44px; } }

/* ---------- 뉴스웨이브 정리 기사 ---------- */
.points { margin-top: 20px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); }
.points h2 { margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); }
.points ul { margin: 0; padding: 0; list-style: none; }
.points li { position: relative; padding-left: 16px; font-size: 15.5px; line-height: 1.6; font-weight: 500; color: var(--ink); word-break: keep-all; }
.points li + li { margin-top: 6px; }
.points li::before { content: ""; position: absolute; left: 0; top: .65em; width: 6px; height: 6px; background: var(--accent); }
.story-body { margin-top: 22px; }
.story-body p { margin: 0 0 18px; font-size: 17px; line-height: 1.8; color: var(--ink); word-break: keep-all; }
.rel.src .ext { color: var(--ink3); font-size: 13px; }
.story > .note { margin-top: 20px; font-size: 12.5px; color: var(--ink3); line-height: 1.6; }
.story-link { display: block; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14.5px; line-height: 1.5; }

/* ---------- 기사 상세 ---------- */
body.reading .toolbar, body.reading .listwrap { display: none; }
.detail { max-width: 720px; margin: 0 auto; padding: 16px 0 8px; }
.read { --h: 220; }
.read[data-cat="생성형AI"] { --h: 228; } .read[data-cat="반도체"] { --h: 188; } .read[data-cat="로봇"] { --h: 150; }
.read[data-cat="정책"] { --h: 32; } .read[data-cat="기업"] { --h: 338; } .read[data-cat="연구"] { --h: 268; }
.read[data-cat="보안/윤리"] { --h: 6; }
.back { display: block; background: none; border: 0; padding: 8px 0; margin-bottom: 12px; color: var(--ink2); font-size: 14px; font-weight: 500; }
.back:hover { color: var(--ink); }
.read h1 { margin: 10px 0 12px; font-size: 26px; line-height: 1.3; font-weight: 500; letter-spacing: -0.015em; word-break: keep-all; }
.meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink3); padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.meta b { color: var(--ink); font-weight: 600; }
.meta time { font-size: 12px; }
.hero { margin: 20px 0 0; }
.hero img { display: block; width: 100%; max-height: 420px; object-fit: cover; background: var(--line); }
.sum { margin-top: 20px; padding: 20px; background: var(--surface); border: 1px solid var(--line); }
.sum h2, .rel h2 { margin: 0 0 10px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink3); }
.sum p { margin: 0; font-size: 17px; line-height: 1.7; color: var(--ink); word-break: keep-all; }
.sum p.note { margin-top: 14px; font-size: 12.5px; line-height: 1.5; color: var(--ink3); }
.cta {
  display: flex; align-items: center; justify-content: center; min-height: 48px; margin-top: 16px; padding: 12px 20px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; font-size: 15px; font-weight: 500;
}
.cta:hover, .cta:active { background: var(--accent-press); }
.rel { margin-top: 36px; }
.rel h2 span { color: var(--accent); }
.rel ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rel li a { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: baseline; padding: 14px 2px; border-bottom: 1px solid var(--line); text-decoration: none; }
.rel li a:hover .r-title { text-decoration: underline; }
.r-src { font-size: 12px; font-weight: 600; color: var(--ink2); min-width: 72px; }
.r-title { font-size: 14.5px; line-height: 1.45; color: var(--ink); word-break: keep-all; }
.rel time { font-size: 11.5px; color: var(--ink3); white-space: nowrap; }
@media (max-width: 639px) {
  .read h1 { font-size: 22px; }
  .rel li a { grid-template-columns: 1fr auto; }
  .r-title { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- 태블릿: 2열 세로 카드 ---------- */
@media (min-width: 640px) {
  .wrap { padding-inline: 24px; }
  .tabbar { margin-inline: -24px; } .tabs { padding-inline: 24px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 10px; }
  .card a.body { flex-direction: column; gap: 0; padding: 0; }
  .media { order: 0; width: 100%; }
  .media:has(> .ph) { display: block; }
  .media img { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 0; }
  .ph {
    display: flex; align-items: flex-end; aspect-ratio: 16 / 6; padding: 10px 12px;
    background: linear-gradient(135deg, hsl(var(--h) var(--ph-a)), hsl(var(--h) var(--ph-b)));
    color: hsl(var(--h) var(--ph-fg)); font-size: 22px; font-weight: 500; letter-spacing: -0.02em;
  }
  .txt { padding: 10px 12px 0; }
  .cfoot { padding-left: 12px; }
  dialog#sheet, dialog#kwSheet { max-width: 480px; margin: auto; border-radius: 0; }
}

/* ---------- PC: 한 줄 헤더, 3열, 첫 기사는 크게 ---------- */
@media (min-width: 960px) {
  .head {
    grid-template-columns: auto minmax(0, 1fr) 300px auto;
    grid-template-areas: "brand . search actions" "tabs tabs tabs tabs"; column-gap: 16px; padding-top: 6px;
  }
  .brand { padding: 0; }
  .tabbar { margin: 0; }
  .tabs { padding: 4px 0 6px; }
  .tscroll { top: 4px; }
  .tscroll.prev { left: 0; } .tscroll.next { right: 0; }
  .search, .search[hidden] { display: block; padding: 0; }
  .search input { height: 34px; font-size: 14px; }
  .actions { padding-top: 0; margin-right: -10px; }
  #btnSearch { display: none; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card.feature { grid-column: span 2; }
  .card.feature a.body { flex-direction: row; }
  .card.feature .media { width: 56%; }
  .card.feature .media img, .card.feature .ph { height: 100%; min-height: 200px; aspect-ratio: auto; }
  .card.feature .txt { padding: 16px 16px 0; }
  .card.feature h2 { font-size: 24px; font-weight: 500; letter-spacing: -0.01em; -webkit-line-clamp: 4; }
  .card.feature p { font-size: 14.5px; -webkit-line-clamp: 4; }
  .card.feature .cfoot { padding-left: 16px; }
}
