/* 全局重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.6;
}

/* 亮色主题 */
body[data-theme="light"] {
  background: #ffffff;
  color: #111111;
}

body[data-theme="light"] .filter-bar {
  background: #ffffff;
  border-bottom: 1px solid #111111;
}

body[data-theme="light"] select,
body[data-theme="light"] button,
body[data-theme="light"] input[type="text"] {
  background: #ffffff;
  color: #111111;
  border: 1px solid #111111;
}

body[data-theme="light"] button:hover {
  background: #111111;
  color: #ffffff;
}

body[data-theme="light"] input[type="text"]:focus {
  outline: 2px solid #111111;
  outline-offset: -2px;
}

body[data-theme="light"] .result-list li {
  border-bottom: 1px solid #cccccc;
}

/* 暗色主题 */
body[data-theme="dark"] {
  background: #000000;
  color: #f0f0f0;
}

body[data-theme="dark"] .filter-bar {
  background: #000000;
  border-bottom: 1px solid #f0f0f0;
}

body[data-theme="dark"] select,
body[data-theme="dark"] button,
body[data-theme="dark"] input[type="text"] {
  background: #000000;
  color: #f0f0f0;
  border: 1px solid #f0f0f0;
}

body[data-theme="dark"] button:hover {
  background: #f0f0f0;
  color: #000000;
}

body[data-theme="dark"] input[type="text"]:focus {
  outline: 2px solid #f0f0f0;
  outline-offset: -2px;
}

body[data-theme="dark"] .result-list li {
  border-bottom: 1px solid #444444;
}

/* 顶部悬浮筛选区 */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px;
}

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

.filter-row.top-row {
  margin-top: 0;
  justify-content: space-between;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 2px;
  font-family: inherit;
}

.search-select {
  flex: 0 0 auto;
}

.site-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

select,
button,
input[type="text"] {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 2px;
  font-family: inherit;
}

select,
button {
  cursor: pointer;
}

.btn-query {
  min-width: 80px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 收藏 / 历史快捷区 */
.quick-bar {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* 让 hidden 覆盖 flex 显式 display */
.quick-bar[hidden],
.quick-row[hidden],
[hidden] {
  display: none !important;
}

.quick-label {
  font-size: 12px;
  opacity: 0.7;
  flex: 0 0 auto;
}

.quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
}

.chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}

.chip-x {
  font-size: 12px;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 2px;
}

.chip-x:hover {
  opacity: 1;
}

body[data-theme="light"] .chip {
  background: #ffffff;
  color: #111111;
  border: 1px solid #111111;
}

body[data-theme="light"] .chip:hover {
  background: #111111;
  color: #ffffff;
}

body[data-theme="dark"] .chip {
  background: #000000;
  color: #f0f0f0;
  border: 1px solid #f0f0f0;
}

body[data-theme="dark"] .chip:hover {
  background: #f0f0f0;
  color: #000000;
}

.btn-link {
  font-size: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
  font-family: inherit;
  color: inherit;
}

body[data-theme="light"] .btn-link,
body[data-theme="dark"] .btn-link {
  background: transparent;
  border: none;
}

body[data-theme="light"] .btn-link:hover,
body[data-theme="dark"] .btn-link:hover {
  background: transparent;
  color: inherit;
  opacity: 0.6;
}

#favorite-btn {
  min-width: 32px;
}

#favorite-btn[data-saved="1"] {
  font-weight: 700;
}

/* 结果区域 */
.result-area {
  padding: 16px;
  min-height: 180px;
}

.status-text {
  font-size: 14px;
  padding: 8px 0;
}

.result-list {
  list-style: none;
}

.result-list li {
  padding: 12px 0;
  font-size: 15px;
  word-break: break-word;
}

.item-meta {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.item-body {
  font-size: 15px;
  line-height: 1.6;
}

/* 移动端适配 */
@media (max-width: 480px) {
  .search-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .search-input {
    flex: 1 1 100%;
  }

  .result-list li {
    font-size: 14px;
  }
}

/* 底部 API 使用方法（在 modal 中使用） */
.api-doc {
  font-size: 13px;
  line-height: 1.6;
}

.api-doc-title {
  font-size: 15px;
  font-weight: 600;
}

.api-doc-desc,
.api-doc-fields {
  font-size: 13px;
  margin: 8px 0;
}

.api-doc-resp-label {
  font-size: 13px;
  margin: 12px 0 6px;
  opacity: 0.7;
}

.api-doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 1px 4px;
  border: 1px solid currentColor;
  border-radius: 2px;
}

.api-doc-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 10px 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  white-space: pre;
  overflow-x: auto;
}

/* 简易 modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-panel {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  border-radius: 2px;
  overflow: hidden;
}

body[data-theme="light"] .modal-panel {
  background: #ffffff;
  color: #111111;
  border: 1px solid #111111;
}

body[data-theme="dark"] .modal-panel {
  background: #000000;
  color: #f0f0f0;
  border: 1px solid #f0f0f0;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid currentColor;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
}

#api-doc-close {
  min-width: 32px;
  font-size: 16px;
  line-height: 1;
}
