/* 메랜스피커(메이플랜드 확성기 검색) — 외부 글꼴·CDN 없음 */

:root {
  color-scheme: light dark;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b2130;
  --text-muted: #5a6374;
  --border: #dadee6;
  --accent: #2f6fe4;
  --accent-contrast: #ffffff;
  --focus: #2f6fe4;
  --mark-bg: #ffe57a;
  --mark-text: #1b2130;
  --premium: #e0559b;
  --premium-bg: #ffe1ef;
  --premium-text: #8a1c54;
  --item: #d9a300;
  --item-bg: #fff0bd;
  --item-text: #694a00;
  --triple: #7b5ae0;
  --triple-bg: #ebe4ff;
  --triple-text: #4a2e9d;
  --unknown: #8b94a3;
  --unknown-bg: #eceef2;
  --unknown-text: #4a5261;
  --ok: #1f9d55;
  --ok-bg: #dcf4e6;
  --ok-text: #0f6337;
  --warn: #c77600;
  --warn-bg: #fff0d4;
  --warn-text: #774600;
  --error: #d43c3c;
  --error-bg: #ffe2e2;
  --error-text: #8e1e1e;
  --muted-bg: #eceef2;
  --channel-text: #cf1d1d;
  --channel-bg: #ffffff;
  --item-link: #2459cc;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 12px rgb(15 23 42 / 4%);
  --radius: 12px;
  --header-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #e6e9ef;
    --text-muted: #9ba4b4;
    --border: #2b313c;
    --accent: #6f9dff;
    --accent-contrast: #0b1020;
    --focus: #8fb3ff;
    --mark-bg: #6a5600;
    --mark-text: #fff7cc;
    --premium: #ff80c0;
    --premium-bg: #43203a;
    --premium-text: #ffc4e1;
    --item: #efbf2c;
    --item-bg: #40340c;
    --item-text: #ffd966;
    --triple: #a68cff;
    --triple-bg: #2d2551;
    --triple-text: #d3c7ff;
    --unknown: #7d8594;
    --unknown-bg: #262b35;
    --unknown-text: #b9c0cc;
    --ok: #3ccf7f;
    --ok-bg: #123a26;
    --ok-text: #8fe3b4;
    --warn: #f0a73a;
    --warn-bg: #42300c;
    --warn-text: #ffd27d;
    --error: #ff6b6b;
    --error-bg: #4a1c1c;
    --error-text: #ffb4b4;
    --muted-bg: #242933;
    --channel-text: #ff7070;
    --channel-bg: #232833;
    --item-link: #85abff;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
}

.skip-link:focus {
  top: 8px;
}

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

/* ---- 머리글 ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .site-header {
    background: var(--bg);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
}

.site-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  min-width: 0;
}

.site-title a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.site-tagline {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.intro {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.intro strong {
  color: var(--text);
  font-weight: 600;
}

.logo {
  width: 26px;
  height: 26px;
  padding: 4px;
  border-radius: 8px;
  background: var(--premium);
  fill: #ffffff;
  flex: none;
}

.status {
  position: relative;
  flex: none;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unknown);
}

.status-badge[data-state="ok"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent);
}

.status-badge[data-state="delayed"] .status-dot,
.status-badge[data-state="stalled"] .status-dot,
.status-badge[data-state="waiting"] .status-dot,
.status-badge[data-state="stopped"] .status-dot {
  background: var(--warn);
}

.status-badge[data-state="offline"] .status-dot {
  background: var(--error);
}

.status-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(15 23 42 / 18%);
  font-size: 13px;
}

.status-summary {
  margin: 0 0 8px;
  font-weight: 600;
}

.status-collectors {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.status-collectors li {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.collector-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.collector-meta {
  color: var(--text-muted);
}

.status-legend {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---- 검색 조건 ---- */

.controls {
  display: grid;
  gap: 12px;
  padding: 16px 0 8px;
}

.search {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: var(--text-muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px 10px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px; /* iOS 확대 방지 */
  box-shadow: var(--shadow);
}

.search input::placeholder,
.field input::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.chip-premium[aria-pressed="true"] {
  border-color: var(--premium);
  background: var(--premium-bg);
  color: var(--premium-text);
}

.chip-item[aria-pressed="true"] {
  border-color: var(--item);
  background: var(--item-bg);
  color: var(--item-text);
}

.chip-triple[aria-pressed="true"] {
  border-color: var(--triple);
  background: var(--triple-bg);
  color: var(--triple-text);
}

.fields {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px;
}

.switch {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--border);
  transition: background-color 0.15s ease;
}

.switch-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--ok);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch-label {
  font-size: 14px;
  font-weight: 600;
}

@media (min-width: 640px) {
  .fields {
    grid-template-columns: 92px minmax(0, 1fr) auto;
  }

  .switch {
    grid-column: auto;
  }
}

/* ---- 결과 ---- */

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.live-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unknown);
}

.live-button[aria-pressed="true"] {
  color: var(--text);
}

.live-button[aria-pressed="true"] .live-dot {
  background: var(--error);
  animation: pulse 1.6s ease-in-out infinite;
}

.live-button[data-paused="true"] .live-dot {
  background: var(--warn);
  animation: none;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.notice {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 14px;
}

.notice[data-kind="error"] {
  background: var(--error-bg);
  color: var(--error-text);
}

.new-items {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 50%;
  z-index: 25;
  transform: translateX(-50%);
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgb(15 23 42 / 25%);
}

.results {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.results:focus {
  outline: none;
}

.card {
  position: relative;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--unknown);
}

.card.type-premium::before {
  background: var(--premium);
}

.card.type-item::before {
  background: var(--item);
}

.card.type-triple::before {
  background: var(--triple);
}

.card.is-new {
  animation: arrive 1.6s ease-out;
}

.card.is-updated {
  animation: refresh 1.6s ease-out;
}

@keyframes arrive {
  from {
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  }
}

@keyframes refresh {
  from {
    background: color-mix(in srgb, var(--ok) 16%, var(--surface));
  }
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.badge,
.flag,
.channel {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-premium {
  background: var(--premium-bg);
  color: var(--premium-text);
}

.badge-item {
  background: var(--item-bg);
  color: var(--item-text);
}

.badge-triple {
  background: var(--triple-bg);
  color: var(--triple-text);
}

.badge-unknown {
  background: var(--unknown-bg);
  color: var(--unknown-text);
}

.channel {
  border: 1px solid var(--border);
  background: var(--channel-bg);
  color: var(--channel-text);
  font-variant-numeric: tabular-nums;
}

.flag-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.flag-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.flag-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.flag-muted {
  background: var(--muted-bg);
  color: var(--text-muted);
  font-weight: 600;
}

.time {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.speaker {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  margin: 0 0 4px;
  font-size: 14px;
}

.medal {
  color: var(--text-muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.nickname {
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.nickname:hover {
  text-decoration: underline;
}

.nickname-filter {
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: -2px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
}

.nickname-filter svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.nickname-filter:hover {
  background: var(--surface-2);
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(92vw, 520px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 20px rgb(15 23 42 / 25%);
  transform: translateX(-50%);
}

.toast[data-kind="warn"] {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.toast[data-kind="error"] {
  background: var(--error-bg);
  color: var(--error-text);
}

.copy-buffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.content {
  margin: 0;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
}

.content-raw::before {
  content: "원문 ";
  margin-right: 4px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--muted-bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.content-missing {
  color: var(--text-muted);
  font-style: italic;
}

mark {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--mark-bg);
  color: var(--mark-text);
}

.item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.item-chip {
  padding: 2px 10px;
  border: 1px solid color-mix(in srgb, var(--item-link) 35%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--item-link) 8%, var(--surface));
  color: var(--item-link);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}

.link-button {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- 툴팁 수치 ---- */

.stats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

@media (min-width: 520px) {
  .stats.has-thumb {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

.stats-title {
  margin: 0 0 6px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 2px 14px;
  margin: 0;
  font-size: 13px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 2px 0;
  border-bottom: 1px dashed var(--border);
}

.stat dt {
  color: var(--text-muted);
}

.stat dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

.stats-note {
  margin: 6px 0 0;
  color: var(--warn-text);
  font-size: 12px;
}

.stats-extra {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.stats-extra summary {
  cursor: pointer;
}

.stats-extra ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.thumb {
  justify-self: start;
  align-self: start;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #11151c;
  overflow: hidden;
  line-height: 0;
}

.thumb img {
  display: block;
  max-width: 160px;
  max-height: 200px;
  width: auto;
  height: auto;
}

/* ---- 목록 끝 ---- */

.list-footer {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 16px 0 32px;
}

.empty,
.list-end {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.load-more {
  min-height: 40px;
  padding: 8px 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
}

.load-more[aria-busy="true"] {
  opacity: 0.6;
  cursor: progress;
}

.sentinel {
  width: 100%;
  height: 1px;
}

.site-footer {
  padding: 16px 0 32px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.site-footer p {
  margin: 4px 0;
}

.noscript {
  margin: 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

/* ---- 이미지 크게 보기 ---- */

.image-dialog {
  width: min(94vw, 760px);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.image-dialog::backdrop {
  background: rgb(0 0 0 / 60%);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-title {
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.dialog-close {
  flex: none;
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
}

.dialog-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 60px);
  margin: 0 auto;
  padding: 12px;
  object-fit: contain;
}

/* 좁은 화면: 헤더에는 이름과 상태만(소개 문구는 본문 첫 줄에 있다) */
@media (max-width: 560px) {
  .site-tagline {
    display: none;
  }
}

@media (max-width: 380px) {
  body {
    font-size: 14px;
  }

  .site-title {
    font-size: 15px;
  }

  .status-badge,
  .live-button {
    padding: 4px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* 툴팁 원본 이미지(글자 파싱 없이 그대로 표시) */
.tooltip-shot {
  display: block;
  margin: 10px 0 2px;
  padding: 0;
  border: 1px solid var(--border, rgba(127, 127, 127, 0.3));
  border-radius: 8px;
  background: #1c1b3a;
  overflow: hidden;
  cursor: zoom-in;
  max-width: min(100%, 360px);
}
.tooltip-shot img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
