/* Base Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue','Noto Sans SC','PingFang SC','Hiragino Sans GB','Microsoft YaHei',Arial,sans-serif;
  background: linear-gradient(135deg, #ebf5ff 0%, #f7fbff 100%);
  color: #0f172a;
}
:root {
  --primary: #1e90ff;
  --primary-600: #1c7fe0;
  --primary-700: #1766b3;
  --surface: #ffffff;
  --muted: #64748b;
  --ring: rgba(30,144,255,0.35);
  --shadow: 0 10px 30px rgba(30,144,255,0.15);
}

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; position: sticky; top:0; backdrop-filter: saturate(120%) blur(8px);
  background: rgba(255,255,255,0.75); border-bottom: 1px solid #e6eef9; z-index: 10;
}
.brand { display:flex; align-items:center; gap:14px; }
.logo { width:36px; height:36px; }
.brand-text h1 { margin:0; font-size: 18px; }
.brand-text p { margin:2px 0 0; color: var(--muted); font-size: 12px; }

.actions { display:flex; align-items:center; gap:8px; }
.chip { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px; border:1px solid #dce7f7; color:#0f172a; text-decoration:none; background:#fff; box-shadow: 0 1px 0 rgba(2,6,23,0.03); }
.chip input { margin-right:6px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 语言下拉菜单样式 */
.lang-dropdown { position: relative; }
.language-select {
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  background-size: 16px;
  border: 1px solid #dce7f7;
  border-radius: 999px;
  color: #0f172a;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 30px 6px 12px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 0 rgba(2,6,23,0.03);
}
.language-select:hover {
  border-color: var(--primary-600);
}
.language-select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.container { max-width: 1000px; margin: 28px auto; padding: 0 16px; }
.card { background: var(--surface); border: 1px solid #e6eef9; border-radius: 16px; box-shadow: var(--shadow); }

.search-card { padding: 22px; }

/* 时间日期显示样式 */
.datetime-display {
  text-align: center;
  margin-bottom: 20px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.datetime-display .time {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.datetime-display .date {
  font-size: 18px;
  color: var(--muted);
  margin-top: 5px;
}

.timezone-selector {
  margin-top: 10px;
}

.timezone-selector select {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid #dce7f7;
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--primary-700);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timezone-selector select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.search-form .input-wrap { display:flex; gap:10px; }
.search-form input[type="search"] {
  flex:1; padding: 14px 16px; border:1px solid #dbe7f7; border-radius: 12px; font-size:16px;
  outline:none; transition: box-shadow .2s ease, border-color .2s ease;
}
.search-form input[type="search"]:focus { border-color: var(--primary); box-shadow: 0 0 0 5px var(--ring); }

.btn { border:none; padding: 12px 16px; border-radius: 12px; cursor:pointer; font-weight:600; }
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: #eaf3ff; color: var(--primary-700); }
.btn-secondary:hover { background: #ddecff; }

.engine-section { margin-top: 16px; }
.engine-header { display:flex; align-items:center; justify-content: space-between; margin-bottom: 10px; }
.engine-header .label { color: var(--muted); font-size: 14px; }
.toggle { display:flex; align-items:center; gap:8px; color: var(--primary-700); cursor: pointer; }

.engine-groups { display:grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.engine-group { padding: 12px; border:1px dashed #e0ecff; border-radius: 12px; }
.group-title { font-weight: 600; margin-bottom: 8px; color: #0f172a; }

/* Collapsible groups */
.engine-group.collapsible .group-title {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.engine-group.collapsible .group-title::before {
  content: '▶';
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.engine-group.collapsible.expanded .group-title::before {
  transform: rotate(90deg);
}
.engine-group.collapsible .chips {
  display: none;
  margin-top: 8px;
}
.engine-group.collapsible.expanded .chips {
  display: flex;
}

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

.buttons { margin-top: 12px; display:flex; gap:10px; }

.links-card { margin-top: 18px; padding: 18px; }
.links-wrap { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 8px; }
.engine-link { display:flex; flex-direction:column; gap:4px; padding:10px 12px; border:1px solid #e6eef9; border-radius: 12px; text-decoration:none; color:#0f172a; background:#fff; }
.engine-link:hover { border-color: var(--primary); box-shadow: 0 0 0 5px var(--ring); }
.engine-name { font-weight: 600; }
.engine-url { color: var(--muted); font-size: 12px; }

.disclaimer { margin-top: 12px; color: var(--muted); font-size: 12px; }

.app-footer { text-align:center; color:#8aa0bd; padding: 24px; font-size:12px; }

/* 设置按钮样式 */
.settings-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* 模态框样式 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

.modal-content {
  background-color: var(--surface);
  margin: 50px auto;
  max-width: 600px;
  width: 90%;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e6eef9;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: #0f172a;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e6eef9;
  display: flex;
  justify-content: flex-end;
}

/* 设置项样式 */
.setting-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e6eef9;
}

.setting-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.setting-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
}

/* 开关按钮样式 */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* 自定义引擎表单样式 */
.custom-engines-section h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 16px;
}

.custom-engine-form {
  margin-top: 15px;
  padding: 15px;
  background-color: #f8fafc;
  border-radius: 8px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dce7f7;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.custom-engine-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin-bottom: 8px;
  background-color: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e6eef9;
}

.custom-engine-info {
  flex: 1;
}

.custom-engine-name {
  font-weight: 500;
  margin-bottom: 3px;
}

.custom-engine-url {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

/* 深色模式样式 */
body.dark-mode {
  background: linear-gradient(135deg, #1a1f36 0%, #111827 100%);
  color: #e2e8f0;
}

body.dark-mode :root {
  --surface: #1e293b;
  --muted: #94a3b8;
  --ring: rgba(56, 189, 248, 0.35);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body.dark-mode .app-header {
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid #334155;
}

body.dark-mode .language-select {
  background-color: #1e293b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .language-select {
  background-color: #1e293b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .card,
body.dark-mode .engine-link,
body.dark-mode .chip {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .search-form input[type="search"] {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

body.dark-mode .datetime-display {
  background: rgba(30, 41, 59, 0.7);
}

body.dark-mode .timezone-selector select {
  background-color: rgba(30, 41, 59, 0.8);
  border-color: #334155;
  color: #94a3b8;
}

body.dark-mode .engine-group {
  border-color: #334155;
}

body.dark-mode .group-title,
body.dark-mode .engine-name {
  color: #e2e8f0;
}

body.dark-mode .btn-secondary {
  background: #334155;
  color: #94a3b8;
}

body.dark-mode .engine-url {
  color: #94a3b8;
}

body.dark-mode .btn-secondary:hover {
  background: #475569;
}

body.dark-mode .modal-content,
body.dark-mode .quick-jump-menu {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  border-color: #334155;
}

body.dark-mode .custom-engine-form,
body.dark-mode .custom-engine-item {
  background-color: #0f172a;
  border-color: #334155;
}

body.dark-mode .form-control {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

/* Quick jump dropdown */
.quick-jump {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
}
.quick-jump-btn {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30,144,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s ease;
}
.quick-jump-btn:hover {
  background: var(--primary-600);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(30,144,255,0.5);
}
.quick-jump-menu {
  position: absolute;
  bottom: 56px;
  right: 0;
  background: white;
  border: 1px solid #e6eef9;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
  min-width: 160px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.2s ease;
}
.quick-jump.active .quick-jump-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.quick-jump-item {
  display: block;
  padding: 10px 14px;
  color: #0f172a;
  text-decoration: none;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  cursor: pointer;
}
.quick-jump-item:hover {
  background: #f8fafc;
}
.quick-jump-item:last-child {
  border-bottom: none;
}

/* Responsive */
@media (max-width: 520px) {
  .search-form .input-wrap { flex-direction: column; }
  .btn { width: 100%; }
  .quick-jump {
    bottom: 16px;
    right: 16px;
  }
  .modal-body,
  .modal-header,
  .modal-footer {
    padding: 15px;
  }
  .custom-engine-form {
    padding: 12px;
  }
}

/* 搜索历史 */
.search-history {
  position: relative;
  margin-top: 8px;
  background: var(--card-bg, #fafafa);
  border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 10px;
  padding: 10px 12px 12px;
}
.search-history .history-label {
  font-size: 12px;
  color: var(--muted-fg, #888);
  margin-bottom: 6px;
}
.search-history .history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.search-history .chip,
.search-history .history-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--chip-bg, #fff);
  border: 1px solid var(--border-color, #e5e5e5);
  border-radius: 999px;
  font-size: 14px;
  color: var(--fg, #333);
  cursor: pointer;
  transition: all .2s ease;
}
.search-history .history-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.search-history .history-tag .remove {
  margin-left: 6px;
  font-size: 12px;
  color: var(--muted-fg, #999);
}
.search-history .clear-history {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--muted-fg, #999);
  cursor: pointer;
  font-size: 14px;
}

@media (prefers-color-scheme: dark) {
  .search-history {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.12);
  }
  .search-history .history-tag {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.16);
    color: #ddd;
  }
  .search-history .clear-history { color: #aaa; }
}