/* ===== 테마 변수 ===== */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #3d4147;
  --text-sub: #8a8f98;
  --border: #e6e3de;
  --accent: #5b7a9d;
  --accent-soft: #eef2f6;
  --alert-bg: #f7f4ec;
  --danger: #b0736e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e2124;
    --surface: #26292d;
    --text: #c9cdd2;
    --text-sub: #82878e;
    --border: #383c41;
    --accent: #8aa8c7;
    --accent-soft: #2c3239;
    --alert-bg: #2b2d28;
    --danger: #c08d88;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
}

/* 수동 토글이 자동 감지보다 우선 */
:root[data-theme="light"] {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #3d4147;
  --text-sub: #8a8f98;
  --border: #e6e3de;
  --accent: #5b7a9d;
  --accent-soft: #eef2f6;
  --alert-bg: #f7f4ec;
  --danger: #b0736e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

:root[data-theme="dark"] {
  --bg: #1e2124;
  --surface: #26292d;
  --text: #c9cdd2;
  --text-sub: #82878e;
  --border: #383c41;
  --accent: #8aa8c7;
  --accent-soft: #2c3239;
  --alert-bg: #2b2d28;
  --danger: #c08d88;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ===== 기본 레이아웃 ===== */
* {
  box-sizing: border-box;
}

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ===== 헤더 ===== */
header {
  margin-bottom: 40px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

header p {
  margin: 8px 0 0;
  color: var(--text-sub);
  font-size: 0.9rem;
}

#theme-toggle {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

#theme-toggle:hover {
  background-color: var(--accent-soft);
}

/* ===== 섹션 카드 ===== */
section {
  margin-bottom: 28px;
  padding: 24px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

/* ===== 리스트 공통 ===== */
ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

li:last-child {
  border-bottom: none;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

time {
  color: var(--text-sub);
  font-size: 0.8rem;
  margin-left: 6px;
}

.empty-state {
  color: var(--text-sub);
  font-size: 0.88rem;
  padding: 14px 4px;
}

/* ===== 키워드 등록 폼 ===== */
#keyword-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#keyword-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

#keyword-input:focus {
  border-color: var(--accent);
}

#keyword-input::placeholder {
  color: var(--text-sub);
}

#keyword-form button[type="submit"] {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#keyword-form button[type="submit"]:hover {
  opacity: 0.88;
}

/* ===== 키워드 목록 ===== */
#keyword-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#keyword-list li span {
  display: inline-block;
  padding: 3px 12px;
  background-color: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* 빈 상태 li에는 span이 없으므로 안전 */
.del-btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--danger);
  background-color: transparent;
  border: 1px solid var(--danger);
  border-radius: 6px;
  cursor: pointer;
}

.del-btn:hover {
  color: #ffffff;
  background-color: var(--danger);
}

/* ===== 실시간 알림 ===== */
#alert-list li {
  background-color: var(--alert-bg);
  border-radius: 8px;
  border-bottom: none;
  padding: 10px 14px;
  margin-bottom: 8px;
  animation: fade-in 0.4s ease;
}

#alert-list li:last-child {
  margin-bottom: 0;
}

#alert-list li.empty-state {
  background-color: transparent;
  animation: none;
}

#alert-list strong {
  color: var(--accent);
  font-weight: 600;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #alert-list li {
    animation: none;
  }
  body {
    transition: none;
  }
}

/* ===== 푸터 ===== */
footer {
  margin-top: 8px;
  text-align: center;
  color: var(--text-sub);
}

/* ===== 모바일 대응 ===== */
@media (max-width: 480px) {
  body {
    padding: 20px 14px 36px;
  }
  section {
    padding: 18px 16px;
  }
  header h1 {
    font-size: 1.25rem;
  }
}
