/* Shared UI foundation. Reading layouts extend this sheet in report.css. */
:root {
  /* Declaring dark support keeps phone browsers from force-darkening the page; the app has its own dark theme. */
  color-scheme: light dark;
  --text: #202b35; --muted: #53616b; --accent: #235a7b;
  --page: #fafaf8; --surface: #fff; --soft: #edf1f2; --border: #d5dbde;
  --error: #8a2525; --radius: 6px;
  --control-border: #aab3ba; --disabled-text: #616971; --disabled-bg: #f0f1ef;
  --youtube-mark: #f00; --youtube-play: #fff;
  /* Evidence kinds (borders, charts) and their soft backgrounds. */
  --c-video: #235a7b; --c-opinion: #7a5000; --c-external: #2f6b3a; --c-check: #8a2525; --c-screen: #5a4a8a; --c-forecast: #1f6a6a; --c-series3: #6b4f8a;
  --bg-video: #eef4f8; --bg-opinion: #faf3e3; --bg-external: #ebf5ee; --bg-check: #fbeeee; --bg-screen: #f2effa; --bg-forecast: #e9f4f4;
  --bar: #7fa6bd; --bar-negative: #a85454; --warn: #705438; --rail-active: #b9c6cf; --term-hover: #dce8ee; --search-mark: #fff0a6;
  --hl-yellow: #ffe98a; --hl-green: #c9efc1; --hl-blue: #cfe2ff;
  --hl-yellow-bar: #d39e00; --hl-green-bar: #2e9e4f; --hl-blue-bar: #2f6fd6;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
}
/* An explicit choice also forbids the browser's own forced dark mode ("only"): Samsung Internet repainted the
   light theme dark even after the reader chose 라이트 (user's phone, 2026-10-14). */
:root[data-theme="light"] { color-scheme: only light; }
/* Dark theme: the device setting (자동) or the reader's choice (theme.js). Screen only, so printing stays light. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #e3e8ec; --muted: #a2adb6; --accent: #8cc1e3;
    --page: #111518; --surface: #1a2025; --soft: #243039; --border: #35414b; --error: #f19a9a;
    --control-border: #5b6873; --disabled-text: #8b959d; --disabled-bg: #20272c;
    --c-video: #6aa9d0; --c-opinion: #d3a54a; --c-external: #6fbd7c; --c-check: #e07f7f; --c-screen: #a796dc; --c-forecast: #5fc0c0; --c-series3: #b39ad6;
    --bg-video: #18242c; --bg-opinion: #2a2416; --bg-external: #18261c; --bg-check: #2d1d1d; --bg-screen: #221f33; --bg-forecast: #162828;
    --bar: #5f8ba5; --bar-negative: #c27070; --warn: #d8b98f; --rail-active: #5b6873; --term-hover: #2c3a44; --search-mark: #6b5a12;
    --hl-yellow: rgb(255 210 40 / .30); --hl-green: rgb(90 190 100 / .30); --hl-blue: rgb(90 150 255 / .34);
    --hl-yellow-bar: #f0c040; --hl-green-bar: #5fd07a; --hl-blue-bar: #6ea8ff;
  }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme: only dark;
    --text: #e3e8ec; --muted: #a2adb6; --accent: #8cc1e3;
    --page: #111518; --surface: #1a2025; --soft: #243039; --border: #35414b; --error: #f19a9a;
    --control-border: #5b6873; --disabled-text: #8b959d; --disabled-bg: #20272c;
    --c-video: #6aa9d0; --c-opinion: #d3a54a; --c-external: #6fbd7c; --c-check: #e07f7f; --c-screen: #a796dc; --c-forecast: #5fc0c0; --c-series3: #b39ad6;
    --bg-video: #18242c; --bg-opinion: #2a2416; --bg-external: #18261c; --bg-check: #2d1d1d; --bg-screen: #221f33; --bg-forecast: #162828;
    --bar: #5f8ba5; --bar-negative: #c27070; --warn: #d8b98f; --rail-active: #5b6873; --term-hover: #2c3a44; --search-mark: #6b5a12;
    --hl-yellow: rgb(255 210 40 / .30); --hl-green: rgb(90 190 100 / .30); --hl-blue: rgb(90 150 255 / .34);
    --hl-yellow-bar: #f0c040; --hl-green-bar: #5fd07a; --hl-blue-bar: #6ea8ff;
  }
}
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: var(--text); background: var(--page); margin: 0; line-height: 1.6; }
dialog { color: var(--text); background: var(--surface); }
main { max-width: 1000px; margin: auto; padding: 24px 24px 48px; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.35; margin: 24px 0; }
h2 { font-size: 1.375rem; line-height: 1.45; margin: 0 0 16px; }
h3 { font-size: 1.125rem; line-height: 1.5; margin: 0 0 8px; }
p { margin: 8px 0 16px; }
a { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; color: var(--accent); text-underline-offset: 4px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
nav a, .actions a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; }
main > nav { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
main > nav a:first-child { padding-left: 0; }
section { margin: 32px 0; }
input, select, button { font: inherit; min-height: 44px; padding: 8px 12px; max-width: 100%; border: 1px solid var(--control-border); border-radius: var(--radius); }
input, select { width: 100%; min-width: 0; background: var(--surface); color: var(--text); }
button { cursor: pointer; background: var(--surface); color: var(--accent); }
button:disabled { cursor: default; color: var(--disabled-text); background: var(--disabled-bg); border-color: var(--border); }
form { display: grid; gap: 12px; max-width: 650px; }
label { min-width: 0; font-size: .9375rem; }
label input, label select { display: block; margin-top: 4px; }
#access { display: flex; margin-top: 24px; }
#login-form { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
#login-form label { grid-column: 1 / -1; }
.hint, .metadata { color: var(--muted); font-size: .9375rem; }
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
article { min-width: 0; }
#recent-reports article { border-bottom: 1px solid var(--border); padding: 8px 0; }
#recent-reports a { font-weight: 650; }
#recent-reports p { margin: 0; }
#categories article { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 8px 16px; }
#categories article > a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; font-weight: 650; }
#categories p { margin: 0; color: var(--muted); font-size: .9375rem; }
#categories details { grid-column: 1 / -1; margin: 0; }
details { margin: 8px 0; }
summary { cursor: pointer; min-height: 44px; padding: 8px 0; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
#counts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; }
#counts article { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
#counts h3 { font-size: .9375rem; font-weight: 400; margin: 0; color: var(--muted); }
#counts p { margin: 0; font-variant-numeric: tabular-nums; font-weight: 650; }
#channels { grid-template-columns: minmax(0, 1fr); gap: 0; }
#channels article { padding: 12px 0; border-top: 1px solid var(--border); }
#channels p { margin: 4px 0; color: var(--muted); font-size: .9375rem; }
#channels article p:first-of-type { font-size: .8125rem; }
.filters { max-width: none; margin: 8px 0 16px; }
.filter-details { border-bottom: 1px solid var(--border); }
#sources { grid-template-columns: minmax(0, 1fr); gap: 0; }
#sources article { padding: 20px 0; border-top: 1px solid var(--border); }
#sources p { margin: 4px 0; }
#sources .job-history { font-size: .875rem; color: var(--muted); }
.status { font-weight: 650; }
#sources article > a { display: inline-flex; align-items: center; min-height: 44px; margin-right: 16px; }
#message { color: var(--error); white-space: pre-line; }
#message:empty, #url-result:empty, #queue-empty:empty, #waiting-empty:empty { display: none; }
[hidden] { display: none !important; }
/* Screen theme choice (theme.js), at the end of the main navigation. */
.theme-choice { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: .875rem; }
.theme-choice select { display: inline-block; width: auto; min-height: 36px; margin: 0; padding: 2px 8px; font-size: .875rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) {
  a:hover { text-decoration-thickness: 2px; }
  button:not(:disabled):hover { background: var(--soft); border-color: var(--accent); }
  summary:hover { text-decoration: underline; text-underline-offset: 4px; }
}
@media (min-width: 800px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-page="home"] #content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; }
  [data-page="home"] #content > section { margin: 24px 0; }
  #categories { grid-template-columns: minmax(0, 1fr); }
  [data-page="home"] #content > section:first-child { grid-column: 1 / -1; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
}
@media (max-width: 600px) {
  main { padding: 16px 16px 32px; }
  #login-form { grid-template-columns: minmax(0, 1fr); }
  #counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Monitored channel detection days (D-059): seven inline checkboxes, 44px touch targets. */
fieldset.days { border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px 8px; margin: 0; min-width: 0; }
fieldset.days legend { font-size: .9375rem; padding: 0 4px; }
fieldset.days label { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; min-width: 44px; margin-right: 4px; }
fieldset.days label input { display: inline-block; margin: 0; width: 20px; height: 20px; }
/* URL tools: compact thumbnail rows; selection and actions stay reachable on phones. */
.url-tools { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.url-tools #playlist-settings { margin-bottom: 16px; }
.url-tools #playlist-items { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.url-tools .playlist-card { position: relative; display: grid; grid-template-columns: 176px minmax(0, 1fr); align-items: start; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; background: var(--surface); }
.url-tools .playlist-card.selected { border-color: var(--accent); border-width: 2px; padding: 3px; background: var(--soft); }
.url-tools .playlist-choice { display: block; min-height: 44px; cursor: pointer; }
.url-tools .playlist-choice::after { content: ''; position: absolute; inset: 0; cursor: pointer; }
.url-tools .playlist-card:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.url-tools .playlist-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; color: var(--muted); font-size: 10px; line-height: 1.3; margin-top: 2px; }
.url-tools .playlist-body { min-width: 0; }
.url-tools .playlist-text { display: block; min-height: 44px; cursor: pointer; }
.url-tools .playlist-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; color: var(--muted); font-size: .875rem; }
.url-tools .playlist-thumbnail { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; background: var(--page); border-radius: 4px; overflow: hidden; color: var(--muted); font-size: .75rem; }
.url-tools .playlist-thumbnail > span:first-child { padding: 4px; }
.url-tools .playlist-thumbnail img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.url-tools .playlist-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; clip-path: inset(50%); overflow: hidden; }
.url-tools .playlist-duration { position: absolute; bottom: 4px; right: 4px; padding: 0 4px; background: var(--surface); color: var(--text); border-radius: 2px; font-size: .75rem; font-variant-numeric: tabular-nums; }
.url-tools .playlist-heading { position: relative; }
.url-tools .playlist-title { display: block; font-size: 1.0625rem; line-height: 1.45; font-weight: 650; max-height: 4.35em; overflow: hidden; }
.url-tools .playlist-heading.expanded .playlist-title { max-height: none; }
.url-tools .playlist-title-toggle { position: absolute; z-index: 2; bottom: 0; right: 0; width: 24px; height: 20px; min-height: 20px; border: 0; border-radius: 0; padding: 0; background: var(--surface); line-height: 1; }
.url-tools .playlist-card.selected .playlist-title-toggle { background: var(--soft); }
.url-tools .playlist-channel-row { display: flex; align-items: center; gap: 4px; }
.url-tools .playlist-youtube, .url-tools .playlist-meta a, .url-tools .playlist-meta button { position: relative; z-index: 2; }
.url-tools .playlist-youtube { justify-content: center; width: 28px; flex: 0 0 28px; text-decoration: none; }
.url-tools .youtube-mark { display: grid; place-items: center; width: 22px; height: 16px; border-radius: 4px; background: var(--youtube-mark); color: var(--youtube-play); font: 10px/1 system-ui,sans-serif; }
.url-tools .playlist-meta:empty { display: none; }
.url-tools .playlist-channel { display: block; margin-top: 2px; color: var(--muted); font-size: .875rem; }
.url-tools .playlist-card p { margin: 6px 0 0; color: var(--muted); font-size: .875rem; }
.url-tools .playlist-card a { font-size: .875rem; }
.url-tools #selection-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 12px 0; }
.url-tools #selection { margin: 0; }
.url-tools #notebook-open { border: 1px solid var(--control-border); border-radius: var(--radius); padding: 8px 12px; text-decoration: none; justify-content: center; }
.url-tools #copy-text { width: 100%; max-width: 100%; font: inherit; }
@media (max-width: 600px) {
  .url-tools { font-size: 14px; padding-bottom: calc(max(110px, var(--url-actions-height, 0px)) + 24px); }
  .url-tools h1 { font-size: 24px; }
  .url-tools h2 { font-size: 20px; }
  .url-tools label { font-size: 14px; }
  .url-tools .hint, .url-tools summary { font-size: 13px; }
  .url-tools .playlist-title { font-size: 12px; line-height: 1.3; font-weight: 500; max-height: 3.9em; }
  .url-tools .playlist-channel, .url-tools .playlist-card p, .url-tools .playlist-card a, .url-tools .playlist-meta { font-size: 11px; }
  .url-tools .playlist-card { padding: 4px; gap: 8px; line-height: 1.3; }
  .url-tools .playlist-channel { margin-top: 0; }
  .url-tools .playlist-card a { min-height: 24px; }
  .url-tools .playlist-duration { font-size: 11px; }
  .url-tools #playlist-items { gap: 4px; }
  .url-tools .playlist-meta { gap: 0 6px; }
  .url-tools .playlist-card { grid-template-columns: clamp(90px, 40%, 144px) minmax(0, 1fr); }
  .url-tools #selection-bar { position: fixed; z-index: 20; bottom: 0; left: 0; right: 0; margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .url-tools #selection { flex: 1 1 100%; font-size: 13px; }
  .url-tools #selection-bar button, .url-tools #notebook-open { flex: 1 1 140px; font-weight: 650; }
}
