/* MathGao Homepage 样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, .75);
  --card-bg: rgba(22, 28, 66, .42);
  --card-bg-hover: rgba(34, 42, 88, .6);
  --radius: 12px;
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: #242a5e;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* 壁纸与遮罩 */
/* 默认渐变以靛蓝紫为主，暖色只留在右上角一小片。
   注意用 background-image 而非 background 简写：app.js 设置壁纸时靠内联
   backgroundImage 覆盖，清空壁纸时才能回落到这里的渐变。 */
#wallpaper {
  position: fixed; inset: 0; z-index: -2;
  background-color: #343a86;
  background-image:
    radial-gradient(ellipse 55% 45% at 88% 6%,  rgba(235,165,140,.45), transparent 62%),
    radial-gradient(ellipse 60% 50% at 10% 96%, rgba(120,200,170,.18), transparent 60%),
    linear-gradient(160deg, #2b2f6e 0%, #363a8a 45%, #4a3f9f 78%, #55459f 100%);
  background-size: cover; background-position: center;
  transition: filter .3s;
}
#mask { position: fixed; inset: 0; z-index: -1; background: #000; opacity: 0; }

/* 主容器 */
#container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 6vh 24px 40px;
  min-height: 100%;
}

/* 头部：logo / 时钟 / 搜索 */
#header { text-align: center; }
#logo { font-size: 26px; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,.35); margin-bottom: 8px; }

#clock { margin-bottom: 22px; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
#clock-time { font-size: 44px; font-weight: 600; letter-spacing: 2px; }
#clock-date { font-size: 14px; color: var(--text-dim); margin-top: 2px; }

#search {
  position: relative;                 /* 承载引擎菜单和建议词浮层 */
  display: flex; align-items: center;
  max-width: 720px; margin: 0 auto 10px;
  background: var(--search-bg, rgba(22,28,66,.42));
  border: 1px solid var(--search-border, rgba(204,204,204,.35));
  border-radius: 999px;
  padding: 4px 8px 4px 6px;
  backdrop-filter: blur(6px);
  transition: box-shadow .2s, border-color .2s;
}
#search:focus-within { box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
#search input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--search-text, #fff); font-size: 15px; padding: 8px 0;
}
#search input::placeholder { color: color-mix(in srgb, var(--search-text, #fff) 55%, transparent); }
#search button {
  background: transparent; border: none; color: var(--search-text, #fff);
  cursor: pointer; padding: 8px 12px; border-radius: 999px; display: flex;
}
#search button:hover { background: rgba(255,255,255,.12); }

/* 左侧引擎切换按钮 */
#engine-btn {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
  padding: 7px 10px 7px 12px; margin-right: 4px;
  border-radius: 999px; font-size: 13px; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.22);
}
#engine-btn svg { opacity: .7; }

/* 引擎菜单 / 建议词列表：同一套浮层样式，贴在搜索框下沿 */
.search-pop {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: rgba(28, 32, 62, .92);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px; padding: 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  max-height: 52vh; overflow-y: auto;
  text-align: left;
}
#engine-menu { left: 0; right: auto; min-width: 168px; }

.sug-head { font-size: 11px; color: var(--text-dim); padding: 5px 12px 4px; }
.sug-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer;
  font-size: 14px; color: var(--text);
}
.sug-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-item:hover, .sug-item.active { background: rgba(255,255,255,.14); }
.sug-item.current { color: #86c24a; }
.sug-tag { font-size: 11px; color: var(--text-dim); flex: 0 0 auto; }
.sug-del {
  flex: 0 0 auto; width: 20px; height: 20px; line-height: 1;
  border: none; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 15px;
}
.sug-del:hover { background: rgba(255,255,255,.2); color: #fff; }

/* 小组件区域 */
#widgets {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  margin: 18px 0 0;
}
#widgets:empty { display: none; }
.widget-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 18px; backdrop-filter: blur(6px);
  min-width: 180px; box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.widget-card h4 { font-size: 13px; color: var(--text-dim); font-weight: 500; margin-bottom: 6px; }

/* 分组 */
#groups { margin-top: 26px; }
.group { margin-bottom: 26px; }
.group-header {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700;
  text-shadow: 0 1px 6px rgba(0,0,0,.35);
  margin-bottom: 14px;
}
.group-header .g-btn {
  display: none;
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  font-size: 16px; line-height: 1;
}
.group-header .g-btn:hover { background: rgba(255,255,255,.3); }
body.editing .group-header .g-btn { display: inline-block; }

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 18px 10px;
}

/* 卡片 */
.item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  padding: 6px 2px; border-radius: var(--radius);
  transition: transform .15s;
}
.item:hover { transform: translateY(-3px); }
.item.dragging { opacity: .4; }
body.editing .item { outline: 1px dashed rgba(255,255,255,.35); }

.item-icon {
  position: relative;
  width: 64px; height: 64px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--icon-bg, rgba(255,255,255,.9));
  box-shadow: 0 3px 12px rgba(0,0,0,.28);
  font-size: 22px; font-weight: 600; color: #fff;
}
.item-icon img { width: 100%; height: 100%; object-fit: cover; }
.item-title {
  font-size: 13px; color: var(--text);
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 页脚 */
#footer { margin-top: 40px; text-align: center; color: var(--text-dim); font-size: 13px; }
#footer a { color: inherit; }

/* 右下角浮动按钮 */
#fab { position: fixed; right: 22px; bottom: 22px; z-index: 50; }
#fab-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(30,30,30,.65); color: #fff;
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 14px rgba(0,0,0,.35);
  transition: transform .2s;
}
#fab-btn:hover { transform: rotate(45deg); }

/* 右上角 PC/手机 模式切换 */
#mode-switch {
  position: fixed; top: 18px; right: 18px; z-index: 50;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: none; border-radius: 999px;
  background: rgba(30, 30, 30, .55); color: #fff;
  backdrop-filter: blur(8px); cursor: pointer;
  font-size: 13px; font-family: inherit;
  box-shadow: 0 3px 14px rgba(0,0,0,.3);
  transition: background .2s;
}
#mode-switch:hover { background: rgba(30, 30, 30, .8); }
body.hide-mode-switch #mode-switch { display: none; }

/* 手机模式下，填了手机版地址的卡片右上角标一个绿点 */
body.mode-mobile .item.has-mobile .item-icon::after {
  content: ''; position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}

/* 右键菜单 */
#ctx-menu {
  position: fixed; z-index: 100;
  background: rgba(255,255,255,.97); color: #333;
  border-radius: 10px; padding: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  min-width: 150px; font-size: 13px;
}
#ctx-menu .ctx-label { padding: 6px 10px 2px; color: #999; font-size: 11px; }
#ctx-menu .ctx-item {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
#ctx-menu .ctx-item:hover { background: #f0f0f0; }
#ctx-menu .ctx-item.danger { color: #d33; }
#ctx-menu hr { border: none; border-top: 1px solid #eee; margin: 4px 0; }

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; color: #333;
  border-radius: 14px; padding: 22px;
  width: 100%; max-width: 520px;
  max-height: 86vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .form-row { margin-bottom: 13px; }
.modal label { display: block; font-size: 13px; color: #666; margin-bottom: 5px; }
.modal input[type=text], .modal input[type=password], .modal input[type=number],
.modal select, .modal textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; outline: none; background: #fff; color: #333;
  font-family: inherit;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: #7b5ea7; }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .row-inline { display: flex; gap: 8px; align-items: center; }
.modal .row-inline > * { flex: 1; }
.modal .row-inline > .fixed { flex: 0 0 auto; }
.modal .modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px;
}
.btn {
  padding: 8px 18px; border-radius: 8px; border: none;
  cursor: pointer; font-size: 14px;
}
.btn-primary { background: #18a058; color: #fff; }
.btn-primary:hover { background: #139050; }
.btn-default { background: #f0f0f0; color: #333; }
.btn-default:hover { background: #e4e4e4; }
.btn-danger { background: #d03050; color: #fff; }
.btn-danger:hover { background: #b82843; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* 开关 */
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: #ccc; transition: .2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s;
}
.switch input:checked + .slider { background: #18a058; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch-row { display: flex; justify-content: space-between; align-items: center; }

/* 图标类型切换 */
.seg { display: inline-flex; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
.seg button {
  padding: 6px 14px; border: none; background: #fff; cursor: pointer; font-size: 13px; color: #333;
}
.seg button.active { background: #18a058; color: #fff; }

/* 分组管理列表 */
.group-manage-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.group-manage-row input { flex: 1; }

/* 提示条 */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; background: rgba(30,30,30,.9); color: #fff;
  padding: 10px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  transition: opacity .3s;
}

/* 图标候选选择器 */
.icon-candidates {
  background: #f7f8fa; border: 1px solid #e6e8ec; border-radius: 10px;
  padding: 12px; margin-bottom: 13px;
}
.icon-candidates .cand-head { display: flex; gap: 8px; align-items: center; }
.icon-candidates .cand-head input { flex: 1; }
.icon-candidates .cand-tip { font-size: 12px; color: #888; margin: 9px 0; }
.cand-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px;
}
.cand-grid:empty { display: none; }
.icon-cand {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; cursor: pointer;
  background: #fff; border: 2px solid transparent; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: transform .15s, border-color .15s;
}
.icon-cand:hover { transform: translateY(-2px); border-color: #18a058; }
.icon-cand.best { border-color: #18a058; }
.icon-cand.saving { opacity: .5; pointer-events: none; }
/* 缩略图垫一层和壁纸同色的底：图标最终就是显示在这个颜色上，
   这样纯黑和纯白的品牌 logo 在挑选时就能看出实际效果 */
.icon-cand img {
  width: 44px; height: 44px; object-fit: contain;
  background: #3a3a8c; border-radius: 8px; padding: 3px;
}
.icon-cand small { font-size: 11px; color: #999; text-align: center; line-height: 1.2; }

/* 图标预览 */
.icon-preview {
  width: 56px; height: 56px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 20px; font-weight: 600; color: #fff;
  background: #2a2a2a; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 600px) {
  #clock-time { font-size: 34px; }
  .items { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 6px; }
  .item-icon { width: 54px; height: 54px; }
  #container { padding-top: 4vh; }
}
