:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-hover: #fafaf8;
  --border: #e6e5e1;
  --text: #1c1c1a;
  --muted: #74736e;
  --faint: #a3a29c;
  --accent: #1c1c1a;
  --accent-text: #ffffff;
  --pin: #e0a100;
  --warn: #b4531d;
  --selected: #1c1c1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --avatar-s: 42%;
  --avatar-l: 92%;
  --avatar-text-l: 34%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #212120;
    --surface-hover: #292927;
    --border: #33332f;
    --text: #ededea;
    --muted: #a09f99;
    --faint: #6f6e69;
    --accent: #ededea;
    --accent-text: #161615;
    --pin: #f0b72f;
    --warn: #f08a4b;
    --selected: #ededea;
    --shadow: none;
    --avatar-s: 28%;
    --avatar-l: 24%;
    --avatar-text-l: 80%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ── 머리 ─────────────────────────────── */

.wrap { max-width: 1120px; margin: 0 auto; padding: 48px 24px 64px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.today { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.search { position: relative; margin-bottom: 32px; }
.search input {
  width: 100%;
  height: 52px;
  padding: 0 52px 0 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  box-shadow: var(--shadow);
  outline: none;
}
.search input:focus { border-color: var(--muted); }
.search input::placeholder { color: var(--faint); }
.search input:not(:placeholder-shown) + kbd { display: none; }
.search kbd {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; line-height: 1;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--faint); font-size: 12px; font-family: inherit;
}

/* ── 구역 ─────────────────────────────── */

.section { margin-bottom: 28px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.count { color: var(--faint); font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }

/* ── 카드 ─────────────────────────────── */

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: background .12s, border-color .12s;
}
.card:hover { background: var(--surface-hover); border-color: var(--muted); }
.card.is-selected { border-color: var(--selected); box-shadow: 0 0 0 1px var(--selected); }
.card.is-disabled { opacity: .6; }

.card-main { display: flex; align-items: center; gap: 12px; padding: 14px 44px 14px 14px; min-width: 0; }
.avatar {
  flex: none;
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; line-height: 1;
  border-radius: 10px;
  background: hsl(var(--h) var(--avatar-s) var(--avatar-l));
  color: hsl(var(--h) 45% var(--avatar-text-l));
  font-weight: 700; font-size: 16px;
}
.card-text { display: flex; flex-direction: column; min-width: 0; }
.card-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.card-host, .card-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-host { color: var(--muted); font-size: 12px; }
.card-meta { color: var(--faint); font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 18px; padding: 0 6px; line-height: 1;
  border-radius: 5px; background: var(--bg); color: var(--warn);
  font-size: 11px; font-weight: 600;
}

.card-links { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px 64px; margin-top: -4px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px; padding: 0 10px; line-height: 1;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 12px;
}
.chip:hover { color: var(--text); border-color: var(--muted); }

.pin {
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; line-height: 1;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--faint); font-size: 16px; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.card:hover .pin, .pin:focus-visible, .pin.is-on { opacity: 1; }
.pin.is-on { color: var(--pin); }
.pin:hover { background: var(--bg); }
@media (hover: none) { .pin { opacity: 1; } }

/* ── 상태 ─────────────────────────────── */

.status { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; flex-wrap: wrap; justify-content: flex-end; }
.warn { color: var(--warn); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; padding: 0 10px; line-height: 1;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-size: 12px;
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-text); height: 34px; padding: 0 16px; font-size: 13px; font-weight: 600; }

.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 64px 16px; color: var(--muted); text-align: center; }
.empty-state p { margin: 0; }

@media (max-width: 640px) {
  .wrap { padding: 24px 16px 48px; }
  .top { flex-direction: column; align-items: flex-start; }
  .status { justify-content: flex-start; }
}

/* ── 팝업(툴바 아이콘) ───────────────────── */

body.popup { width: 380px; }
.popup .wrap { padding: 14px 12px 10px; }
.popup .top { flex-direction: row; align-items: center; margin-bottom: 10px; }
.popup .brand { font-size: 15px; }
.popup .today { display: none; }
.popup .search { margin-bottom: 14px; }
.popup .search input { height: 40px; font-size: 14px; border-radius: 10px; padding-left: 14px; }
.popup .search kbd { display: none; }
.popup .section { margin-bottom: 14px; }
.popup .section-title { font-size: 12px; margin-bottom: 6px; }
.popup .grid { grid-template-columns: 1fr; gap: 4px; }
.popup .card { border-radius: 10px; box-shadow: none; }
.popup .card-main { padding: 8px 40px 8px 8px; gap: 10px; }
.popup .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.popup .card-title { font-size: 14px; }
.popup .card-links { padding: 0 8px 8px 48px; margin-top: -2px; }
.popup .pin { top: 50%; transform: translateY(-50%); right: 6px; }
.popup .card:has(.card-links) .pin { top: 6px; transform: none; }
.popup .status { justify-content: flex-start; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.popup .empty-state { padding: 32px 8px; }
