/* ========== 设计令牌：深色是第一套，JS 还没跑起来时页面也已经是深色 ========== */

:root {
  color-scheme: dark;

  --accent: #7c8cff;
  --accent-soft: color-mix(in srgb, var(--accent) 20%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --bg: #0a0d13;
  --bg-deep: #06080d;

  /* 表面分三层：主页面板最薄，弹层更实，菜单最实；模糊与压暗同步递增，层次才分得开 */
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(255, 255, 255, 0.085);
  --panel-top: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  --hairline: color-mix(in srgb, var(--text) 7%, transparent);
  --inset: rgba(0, 0, 0, 0.24);
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.11);
  --menu: rgba(17, 21, 29, 0.88);
  --modal: rgba(13, 17, 24, 0.86);
  --scrim: rgba(4, 6, 11, 0.62);
  --tile: rgba(255, 255, 255, 0.05);
  --tile-hover: rgba(255, 255, 255, 0.09);
  --text: #eef2f8;
  --text-dim: rgba(238, 242, 248, 0.76);
  --text-faint: rgba(238, 242, 248, 0.5);
  --on-accent: #0a0d13;
  --field: rgba(255, 255, 255, 0.055);
  --field-border: rgba(255, 255, 255, 0.12);
  --shadow: 0 24px 52px -26px rgba(0, 0, 0, 0.8);
  --shadow-sm: 0 4px 14px -6px rgba(0, 0, 0, 0.6);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 22px 44px -30px rgba(0, 0, 0, 0.7);
  /* 只有还直接坐在壁纸上的字才需要这层影子（时钟、顶栏芯片、页脚） */
  --on-bg: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 28px rgba(0, 0, 0, 0.36);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --blur-panel: 20px;
  --blur-tile: 14px;
  --blur-pop: 30px;
  /* 一套间距刻度：面板内边距、面板之间、面板之内，全从这里取 */
  --pad-panel: 16px 20px 20px;
  --gap-panel: 18px;
  --spring: cubic-bezier(0.2, 0.8, 0.3, 1.15);
  --ease-out: cubic-bezier(0.22, 0.9, 0.28, 1);
  --stack: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  /* 字号 / 行距由「设置 → 外观」写在 html 上，这里只给兜底值 */
  --title-fs: 12.5px;
  --row-gap: 12px;
  --icon-size: 44px;
}

/* 浅色档沿用同一套深色玻璃，只是更薄更透、白字不变（用户明确要过：不做白底两套皮） */
[data-resolved="light"] {
  color-scheme: light dark;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-border: rgba(255, 255, 255, 0.14);
  --card: rgba(255, 255, 255, 0.09);
  --card-hover: rgba(255, 255, 255, 0.16);
  --card-border: rgba(255, 255, 255, 0.16);
  --menu: rgba(24, 28, 37, 0.84);
  --modal: rgba(18, 22, 30, 0.8);
  --tile: rgba(255, 255, 255, 0.07);
  --tile-hover: rgba(255, 255, 255, 0.12);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 18px 36px -26px rgba(0, 0, 0, 0.6);
  --blur-panel: 14px;
  --blur-pop: 24px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--stack);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-line); color: #fff; }

/* 滚动条：所有容器共用一套细轨，别露出系统那副宽滚条 */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.26); }

:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }


/* 文字始终画在最上层：玻璃、壁纸、遮罩都不许盖过它 */
.clock-time, .clock-meta, .search-input, .icon-pop,
.tile-title, .card-head h2, .card-hint, .notes, .todo-list li, .foot, .muted {
  position: relative;
  z-index: 1;
}

/* 只剩还坐在壁纸上的那几处需要影子压底；进了玻璃面板的文字一律不加，加了就糊 */
.clock-time, .clock-meta, .chip, .foot {
  text-shadow: var(--on-bg);
}

.bg, .bg-veil {
  position: fixed;
  inset: -40px;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.bg { transition: filter 0.3s ease, background-color 0.3s ease; background-size: var(--wp-size, cover); }
/* 压暗层做成上轻下重的暗角：壁纸上半部照常透气，下面的玻璃面板才有东西可衬 */
.bg-veil {
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(130% 100% at 50% -10%, rgba(6, 8, 13, 0.12) 0%, var(--bg-deep) 82%);
  opacity: 0.32;
  transition: opacity 0.3s ease;
}

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  z-index: 5;
  animation: boot-pulse 1.8s ease-in-out infinite;
}

@keyframes boot-pulse {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.9; }
}

.boot.error { display: block; padding: 12vh 8vw; line-height: 1.9; text-align: left; letter-spacing: 0; animation: none; opacity: 1; }

.app {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 30px 44px;
}

/* 顶栏不再有标题，只剩右侧组件芯片 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  /* 右侧留给固定在最右上角的小工具区 */
  padding: 4px 72px 10px 2px;
}

/* 天气关掉时顶栏就没别的东西了：整行撤掉不占位，时钟、搜索框和下面的内容一起顶上去。
   判据用设置里那个开关（`applyAppearance` 写在 html 上），不看芯片自己的 hidden——芯片加载中也是 hidden，会先塌后弹跳一下版 */
html[data-weather="off"] .topbar { display: none; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--panel-top);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(140%);
  backdrop-filter: blur(var(--blur-panel)) saturate(140%);
  transition: transform 0.16s var(--spring), background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover { transform: translateY(-1px); background: var(--card-hover); border-color: var(--card-border); }

.chip {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: transform 0.16s var(--spring), background 0.18s ease;
}

.chip:hover { transform: translateY(-1px); background: var(--card-hover); color: var(--text); }

/* 右上角工具区：内外网切换 + 设置，平时很淡，指针靠近才清晰 */
.corner-tools {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 22;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 13px;
  opacity: 0.34;
  transition: opacity 0.22s ease;
}
.corner-tools:hover, .corner-tools:focus-within { opacity: 1; }

.corner-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.corner-btn:hover { background: var(--card); border-color: var(--panel-border); }
.corner-btn svg { width: 15px; height: 15px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.hero { padding: 5.5vh 0 8px; text-align: center; }
.clock[hidden], .panels[hidden] { display: none; }
.search[hidden] { display: none; }
/* 搜索栏关掉后时钟下方不再留 30px 空当 */
.search[hidden] ~ * { margin-top: 0 !important; }
.clock-time { font-size: clamp(44px, 8.4vw, 74px); font-weight: 300; letter-spacing: -0.5px; line-height: 1.04; font-variant-numeric: tabular-nums; }
.clock-meta { margin-top: 8px; font-size: 13.5px; font-weight: 400; color: var(--text-dim); letter-spacing: 0.02em; }
.clock-sep { margin: 0 6px; opacity: 0.5; }

.search {
  position: relative;
  z-index: 30;
  margin: 30px auto 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  max-width: 860px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  box-shadow: var(--shadow), var(--panel-top);
  overflow: visible;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search:focus-within {
  border-color: var(--accent-line);
  background: var(--card);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
}

.engine-picker { position: relative; }
/* 引擎位与输入之间只留一道发丝分割线，不画块、不做胶囊 */
.engine-picker::after {
  content: '';
  position: absolute;
  right: 0;
  top: 24%;
  height: 52%;
  width: 1px;
  background: var(--panel-border);
  pointer-events: none;
}
.engine-btn {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
  padding: 0 4px 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: calc(var(--radius-sm) - 2px) 0 0 calc(var(--radius-sm) - 2px);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.engine-ico { font-size: 17px; line-height: 1; flex: none; }

/* 引擎官方图标容器：随上下文取字号，img 失败时换成首字母 */
.eng-ico { width: 1.2em; height: 1.2em; display: inline-grid; place-items: center; flex: none; line-height: 1; overflow: hidden; }
.eng-ico img { width: 100%; height: 100%; object-fit: contain; border-radius: 3px; }
.eng-ico.letter { font-weight: 700; font-size: 0.78em; }

/* 隐藏式引擎名：静止时只留图标，悬停 / 聚焦 / 展开菜单时撑开 */
.engine-reveal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-width 0.22s ease, opacity 0.16s ease, margin-left 0.22s ease;
}
.engine-picker:hover .engine-reveal,
.engine-picker.open .engine-reveal,
.engine-btn:focus-visible .engine-reveal {
  max-width: 120px;
  opacity: 1;
  margin-left: 7px;
}

.caret { font-size: 9px; opacity: 0.55; }
.search-input { flex: 1; min-width: 0; height: 52px; border: 0; background: transparent; padding: 0 14px; font-size: 15px; }
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus { outline: none; }

/* 放大镜按钮：不要实心圆底，白色描边图标直接坐在玻璃上 */
.search-go {
  flex: none;
  width: 46px;
  height: 40px;
  margin: 6px 8px 6px 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
  transition: background 0.16s ease, transform 0.16s var(--spring), opacity 0.16s ease;
}
.search-go svg { width: 17px; height: 17px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.search-go:hover { background: var(--tile-hover); }
.search-go:active { transform: scale(0.95); transition-duration: 0.08s; }

.menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 190px;
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  margin: 0;
  list-style: none;
  background: var(--menu);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow), var(--panel-top);
  z-index: 20;
  -webkit-backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  animation: pop-in 0.18s var(--ease-out);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.menu.inline { position: static; margin-top: 6px; }
.menu li button, .menu li { display: flex; width: 100%; }
.menu li button {
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  color: var(--text-dim);
  transition: background 0.14s ease, color 0.14s ease;
}
.menu li button:hover { background: var(--tile-hover); color: var(--text); }
.menu li button[aria-checked="true"] { background: var(--accent-soft); color: var(--text); }

/* ---------- 卡片右键菜单 ---------- */

.ctx-menu {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 45;
  min-width: 186px;
  max-width: min(340px, calc(100vw - 16px));
  padding: 6px;
  background: var(--menu);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow), var(--panel-top);
  -webkit-backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  animation: pop-in 0.16s var(--ease-out);
}

.ctx-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.ctx-menu button:hover { background: var(--tile-hover); color: var(--text); }
.ctx-menu button.danger { color: #ff8080; }
.ctx-menu button.danger:hover { background: rgba(160, 46, 46, 0.28); color: #ffb3b3; }
.ctx-menu button:disabled { opacity: 0.32; cursor: default; }
.ctx-menu button:disabled:hover { background: transparent; color: var(--text-dim); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-panel); margin: 30px 0 0; }

/* 面板配方：一层薄玻璃 + 发丝描边 + 顶部一道高光 + 柔和外投影。
   主页上所有成块的东西（小组件、分组）都走这一套，层次靠同一份配方拉开，不各写各的。
   容器组件那一层不在这儿：窗口撤掉以后每张卡只是块暗凹槽，见下面 .dk-tile。 */
.card, .group {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(150%);
  backdrop-filter: blur(var(--blur-panel)) saturate(150%);
}

.card { padding: var(--pad-panel); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 9px; border-bottom: 1px solid var(--hairline); }
.card-head h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.card-hint { font-size: 11.5px; color: var(--text-faint); min-height: 14px; font-variant-numeric: tabular-nums; }

.notes {
  width: 100%;
  min-height: 108px;
  margin-top: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  padding: 2px;
  resize: vertical;
  line-height: 1.75;
  font-size: 14px;
  color: var(--text);
  transition: background 0.18s ease, border-color 0.18s ease, padding 0.18s ease;
}
.notes::placeholder { color: var(--text-faint); }
.notes:focus { outline: none; padding: 8px 10px; margin-top: 10px; background: var(--inset); border-color: var(--panel-border); }

.todo-add { display: flex; gap: 8px; margin-top: 12px; }
.todo-add input { flex: 1; min-width: 0; border: 1px solid var(--panel-border); border-radius: var(--radius-xs); background: var(--field); padding: 8px 11px; font-size: 14px; }
.todo-add input::placeholder { color: var(--text-faint); }
.todo-add input:focus { outline: none; border-color: var(--accent-line); background: var(--inset); }
.todo-add button { width: 36px; border-radius: var(--radius-xs); border: 1px solid var(--panel-border); background: var(--field); cursor: pointer; transition: background 0.16s ease, border-color 0.16s ease; }
.todo-add button:hover { background: var(--tile-hover); border-color: var(--card-border); }

.todo-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 210px; overflow: auto; }
.todo-list li { display: flex; align-items: center; gap: 9px; padding: 6px 2px; font-size: 14px; border-bottom: 1px solid color-mix(in srgb, var(--text) 4%, transparent); }
.todo-list li:last-child { border-bottom: 0; }
.todo-list li.done span { text-decoration: line-through; color: var(--text-faint); }
.todo-list li span { flex: 1; word-break: break-word; }
.todo-list li button { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 14px; }
.todo-list li button:hover { color: #ff8080; }

.groups { margin-top: var(--gap-panel); display: grid; gap: var(--gap-panel); }
.group { position: relative; scroll-margin-top: 16px; padding: 6px 20px 20px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 8px 0 10px; border-bottom: 1px solid var(--hairline); }
.group-head .grow { flex: 1; }

/* 一键打开本组全部网页 */
.group-open-all {
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.group-open-all:hover { background: var(--tile-hover); color: var(--accent-line); }
.group-open-all:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.group.folded .group-open-all { display: none; }

.group-actions { display: none; gap: 6px; }
[data-edit="on"] .group-actions { display: flex; }

/* 头上不画三角：点分组名称本身就折叠 / 展开，所以名称要做得一眼就想点 */
.group-name {
  /* 可以收缩换行：标题字号固定 20px 以后，长分组名不能把整页撑出横向滚动 */
  flex: 0 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 2px 9px 2px 2px;
  color: var(--text);
  font: inherit;
  /* 固定大字号：不跟「设置 → 外观」的卡片字号滑块走，标题永远比卡片文字大一截 */
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, opacity 0.16s ease;
}
.group-name:hover { background: var(--tile-hover); }
.group-name:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
/* 折起来以后整组没了内容，标题压暗一档表示「这组还收着东西」 */
.group.folded .group-name { opacity: 0.62; }
/* 折叠时分组的头部面板自成一块，那条分割线就没东西可分了 */
.group.folded .group-head { margin-bottom: 6px; padding-bottom: 8px; border-bottom-color: transparent; }
.group.folded { padding-bottom: 8px; }

/* 长按拖拽分组：整块抬起来跟手指走 */
.group-dragging { opacity: 0.88; z-index: 5; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42); cursor: grabbing; }
body.holding-drag .group-dragging:hover { transform: none; }

/* 名称弹层现在只有左侧导航在用：贴屏幕边缘，所以往右展开而不是居中在图标下方 */
.icon-pop {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  z-index: 6;
  max-width: 230px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 4px 9px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: var(--menu);
  -webkit-backdrop-filter: blur(var(--blur-pop)) saturate(140%);
  backdrop-filter: blur(var(--blur-pop)) saturate(140%);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-5px, -50%);
  transition: opacity 0.16s ease, transform 0.16s var(--ease-out), visibility 0.16s;
}
.side-dot:hover > .icon-pop,
.side-dot:focus-visible > .icon-pop {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

/* 磁贴三件套互相独立：图标档位给图标框与列宽（只管网址应用，Docker 组件自己定长宽），字号与行距由设置写在 html 上 */
/* 撤掉框以后，图标之间的空当全是列宽撑出来的：列宽贴紧图标，横向间隔再收一档（纵向仍然跟「卡片行距」滑块） */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 84px), 1fr)); gap: var(--row-gap, 12px) calc(var(--row-gap, 12px) * 0.6); }

[data-size="small"] { --tile-min: 64px; --icon-size: 34px; }
[data-size="medium"] { --tile-min: 84px; --icon-size: 44px; }
[data-size="large"] { --tile-min: 108px; --icon-size: 60px; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--title-fs, 12.5px) * 0.5);
  min-height: calc(var(--icon-size, 44px) + var(--title-fs, 12.5px) * 2.6);
  padding: calc(var(--title-fs, 12.5px) * 0.7) calc(var(--title-fs, 12.5px) * 0.5);
  font-size: var(--title-fs, 12.5px);
  border-radius: var(--radius-sm);
  /* 面板已经提供了表面，图标本身仍不画框：一屏几十张卡，框一多就扫不动了。悬停落一层淡底是唯一反馈 */
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s var(--ease-out), background 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tile:hover { transform: translateY(-2px); background: var(--tile-hover); }
.tile:active { transform: translateY(-1px) scale(0.99); transition-duration: 0.09s; }
.tile-title { font-size: 1em; font-weight: 500; line-height: 1.35; max-width: 100%; word-break: break-word; }

/* 当前网络模式下没填网址：整卡压暗，点击只提示不跳转 */
.tile.no-href { opacity: 0.5; cursor: default; }
.tile.no-href:hover { transform: none; background: transparent; box-shadow: none; }
.tile.no-href:hover .tile-icon { transform: none; }
[data-edit="on"] .tile.no-href { opacity: 1; cursor: pointer; }

.tile-icon {
  width: var(--icon-size, 44px);
  height: var(--icon-size, 44px);
  display: grid;
  place-items: center;
  border-radius: 26%;
  /* 图标本身永远不叠底色，屏幕上看到的就是图标那一张图 */
  background: transparent;
  font-size: calc(var(--icon-size, 44px) * 0.55);
  line-height: 1;
  overflow: hidden;
  flex: none;
  transition: transform 0.18s var(--ease-out);
}
.tile:hover .tile-icon { transform: scale(1.05); }
.tile-icon img { width: 100%; height: 100%; object-fit: contain; }
.tile-icon.letter { font-size: calc(var(--icon-size, 44px) * 0.45); font-weight: 650; color: var(--accent); }

/* 图标在左：磁贴改为图标占左列、文字靠右两行，整卡更扁更宽 */
[data-layout="left"] .tiles { grid-template-columns: repeat(auto-fill, minmax(calc(var(--tile-min, 104px) * 2.15), 1fr)); }
[data-layout="left"] .tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "icon title";
  gap: 0.18em 0.9em;
  align-content: center;
  min-height: calc(var(--icon-size, 44px) + var(--title-fs, 12.5px) * 0.9);
  padding: calc(var(--title-fs, 12.5px) * 0.5) calc(var(--title-fs, 12.5px) * 0.75);
  text-align: left;
}
[data-layout="left"] .tile-icon { grid-area: icon; align-self: center; justify-self: start; }
[data-layout="left"] .tile-title { grid-area: title; align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
[data-layout="left"] .tile-x { top: 50%; right: 5px; transform: translateY(-50%); }

/* 图标档位调到「小」：不分「图在上 / 图在左」，都收成竖排卡片 */
[data-layout="left"] [data-size="small"] .tiles { grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 84px), 1fr)); }
[data-layout="left"] [data-size="small"] .tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--title-fs, 12.5px) * 0.35);
  padding: calc(var(--title-fs, 12.5px) * 0.55) 4px;
  text-align: center;
}
[data-layout="left"] [data-size="small"] .tile-icon { align-self: center; }
[data-layout="left"] [data-size="small"] .tile-title { white-space: normal; }

/* 小档的应用卡片＝正方形圆角：宽由列宽定，高用 aspect-ratio 跟着等宽，名称排在图标下方、最多两行。
   这里既不写 min-height: 0 也不写 overflow: hidden：两者都会让「按内容自动撑高」失效，
   名称两行时就会被 flex 压成 12px 高，字看着像被切掉半截。 */
[data-size="small"] .tile {
  aspect-ratio: 1 / 1;
  min-height: auto;
}
[data-size="small"] .tile-icon { border-radius: 22%; }
[data-size="small"] .tile-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: clip;
  line-height: 1.3;
}
/* 小档卡片的编辑模式版式写在「卡片上的左右移动按钮」那一节：它要盖住那节里两条按布局留白的规则，只能排在后面 */

/* ---------- 容器组件的共用小件：状态点 + 实时数据 + 启停（版式写在文件末尾「Docker 窗口」那一节） ---------- */

/* data-dstate 挂在 Docker 窗口里的组件和设置那一栏的行上，两处共用同一套状态色 */
.stat-dot { width: 8px; height: 8px; display: inline-block; flex: none; border-radius: 50%; background: var(--text-faint); }
[data-state="running"] > .stat-dot,
[data-dstate="running"] .stat-dot { background: #4ade80; }
[data-state="paused"] > .stat-dot,
[data-state="restarting"] > .stat-dot,
[data-dstate="paused"] .stat-dot,
[data-dstate="restarting"] .stat-dot { background: #fbbf24; }
[data-state="exited"] > .stat-dot,
[data-state="created"] > .stat-dot,
[data-state="dead"] > .stat-dot,
[data-state="missing"] > .stat-dot,
[data-dstate="exited"] .stat-dot,
[data-dstate="created"] .stat-dot,
[data-dstate="dead"] .stat-dot,
[data-dstate="missing"] .stat-dot { background: #f87171; }

.tile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  max-width: 100%;
  font-size: 0.76em;
  line-height: 1.32;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.stat-line { display: flex; align-items: center; gap: 0.45em; white-space: nowrap; }
.tile-stat b { font-weight: 500; color: var(--text-dim); }

.docker-list { display: grid; gap: 6px; max-height: min(52vh, 420px); overflow: auto; margin: 4px 0 10px; padding-right: 2px; }
.docker-list.compact { max-height: min(34vh, 260px); }
.docker-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--tile);
  color: var(--text);
  font-size: 0.95em;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s var(--ease-out);
}
.docker-row:hover { background: var(--tile-hover); border-color: var(--accent-line); }
/* 换绑时被别的组件占着的那些：整行按下去点不动，别再做出「两张组件对一个容器」 */
.docker-row:disabled { opacity: 0.4; cursor: default; }
.docker-row:disabled:hover { background: var(--tile); border-color: var(--panel-border); transform: none; }
.docker-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 状态写在容器名后面，宽度先给足，镜像名靠右弹性截断 */
.docker-state { flex: none; min-width: 4em; color: var(--text-dim); font-size: 0.86em; }
.docker-image { margin-left: auto; flex: 0 1 auto; min-width: 0; max-width: 45%; color: var(--text-faint); font-size: 0.86em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docker-mark { flex: none; font-size: 0.84em; color: var(--accent); }
/* 已经挂过组件的：压暗一档，右侧标「已在窗口里」，点它是去编辑那张组件而不是再加一张 */
.docker-row.bound { opacity: 0.62; }
.docker-row.bound .docker-mark { color: var(--text-faint); }
.docker-row.picked { border-color: var(--accent); background: var(--accent-soft); opacity: 1; }
.docker-bind { display: flex; align-items: center; gap: 8px; }
.docker-bind code {
  flex: none;
  max-width: 55%;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--inset);
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.docker-bind code.unset { color: var(--text-faint); background: transparent; border-style: dashed; }

.tile-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 11px;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.16s ease, background 0.16s ease;
}
[data-edit="on"] .tile { cursor: grab; }
[data-edit="on"] .tile .tile-x { display: grid; }
.tile .tile-x:hover { opacity: 1; background: rgba(160, 46, 46, 0.9); }
.tile.dragging { opacity: 0.5; transform: rotate(1.5deg) scale(0.97); }
/* 长按拖拽中：按住的那张跟着指针走，整页别选中文字、光标也别显示成文本态 */
body.holding-drag { user-select: none; -webkit-user-select: none; cursor: grabbing; }
body.holding-drag .tile { cursor: grabbing; }
body.holding-drag .tile.dragging { opacity: 0.85; z-index: 5; }
/* ⇄ 配对中：选中那张描边，其余卡片悬停时给出「点我互换」的反馈 */
.tile.swap-pick { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 80%, transparent), 0 12px 28px rgba(0, 0, 0, 0.3); }
[data-swap="on"] .tile:not(.swap-pick):hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent), 0 12px 28px rgba(0, 0, 0, 0.3); }
[data-swap="on"] .tile { cursor: copy; }
.tile.drop-before, .tile.drop-after { background: var(--tile-hover); }
.tile.drop-before { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
.tile.drop-after { box-shadow: inset -2px 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
.tiles.drop-empty { outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 6px; border-radius: var(--radius-sm); }

.editbar { display: flex; align-items: center; gap: 14px; margin-top: var(--gap-panel); flex-wrap: wrap; }
/* 署名跟着内容走：排在分组列表（编辑模式下还有「＋ 新建分组」）的最后头，不再钉在窗口底部 */
.foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 40px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
}
#saveState:empty { display: none; }
.foot-credit { letter-spacing: 0.3px; }
.muted { color: var(--text-dim); font-size: 12.5px; line-height: 1.7; }
.error { color: #ff8080; font-size: 13px; margin: 8px 0 0; }
.sub { font-size: 12px; margin: 22px 0 6px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
code {
  padding: 1px 5px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background: var(--inset);
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.spacer { flex: 1; }
[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(22px) saturate(120%);
  backdrop-filter: blur(22px) saturate(120%);
}

.modal-card {
  width: min(700px, 100%);
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: 22px 24px 24px;
  border-radius: 22px;
  background: var(--modal);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow), var(--panel-top);
  color: var(--text);
  -webkit-backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  backdrop-filter: blur(var(--blur-pop)) saturate(150%);
  animation: modal-in 0.22s var(--ease-out);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.modal-card.narrow { width: min(440px, 100%); }
.modal-card h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--hairline); }

.tabs { display: flex; gap: 4px; margin: 16px 0 4px; flex-wrap: wrap; border-bottom: 1px solid var(--hairline); padding-bottom: 10px; }
.tab { border: 1px solid transparent; background: transparent; padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--text-dim); transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease; }
.tab:hover { color: var(--text); background: var(--tile); }
.tab.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); font-weight: 600; }
.tab-body { padding-top: 16px; display: grid; gap: 13px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 14px; }
.row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.row > span { color: var(--text-dim); }
.row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.row input[type="range"] { accent-color: var(--accent); }

.field {
  border: 1px solid var(--field-border);
  background: var(--field);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  font-size: 14px;
  min-width: 0;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { outline: none; border-color: var(--accent-line); background: var(--inset); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.wide, .row.col .field { width: 100%; }
.field.color { padding: 2px; width: 56px; height: 34px; }
select.field { max-width: 220px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 4px; border-radius: 12px; background: var(--inset); border: 1px solid var(--panel-border); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--text-dim); transition: background 0.16s ease, color 0.16s ease; }
.seg button:hover { color: var(--text); background: var(--tile-hover); }
.seg button.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent-line); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  border-radius: var(--radius-xs);
  padding: 9px 15px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.14s var(--ease-out);
}
.btn:hover { background: var(--tile-hover); border-color: var(--card-border); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); font-weight: 650; box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--accent) 85%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.danger { border-color: rgba(255, 100, 100, 0.32); color: #ff8080; background: transparent; }
.btn.danger:hover { background: rgba(160, 46, 46, 0.22); border-color: rgba(255, 100, 100, 0.45); }
.btn.ghost {
  background: transparent;
  border-style: dashed;
  color: var(--text-dim);
  opacity: 0.7;
  height: 30px;
  padding: 0 13px;
  font-size: 12.5px;
  transition: opacity 0.18s ease, color 0.18s ease, background 0.18s ease, transform 0.16s var(--ease-out);
}
.btn.ghost:hover { opacity: 1; color: var(--text); background: var(--tile); transform: translateY(-1px); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* 编辑态小按钮：无底无框，平时只是淡字，悬停才亮 */
.icon-btn.mini {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-color: transparent;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  color: var(--text-faint);
  font-size: 13px;
  border-radius: 8px;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s var(--spring);
}
.icon-btn.mini:hover { color: var(--text); background: var(--tile); transform: translateY(-1px); }
/* 排头排尾时的 ◀ ▶ 就让它灰着：禁用键照样会触发 :hover，所以两条都要压住 */
.icon-btn.mini:disabled,
.icon-btn.mini:disabled:hover { color: var(--text-faint); background: transparent; transform: none; opacity: 0.32; cursor: default; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.swatch {
  height: 52px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), box-shadow 0.16s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent), 0 10px 22px -12px rgba(0, 0, 0, 0.8); }

.engine-list, .group-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.engine-list li { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--panel-border); border-radius: var(--radius-sm); background: var(--inset); font-size: 13.5px; }
.engine-list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engine-list li input[type="radio"] { accent-color: var(--accent); }
.engine-form { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 8px; align-items: center; }
.engine-form .field { width: 100%; }
.engine-form .btn { grid-column: 1 / -1; justify-self: start; }

/* 编辑应用一览：按分组分段，行里直接标出容器绑定还是网址 */
#appNewBtn { justify-self: start; }
.app-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.app-head { padding: 10px 2px 2px; color: var(--text-faint); font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.app-row { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid var(--panel-border); border-radius: var(--radius-sm); background: var(--inset); font-size: 13.5px; transition: border-color 0.16s ease, background 0.16s ease; }
.app-row:hover { border-color: var(--card-border); background: var(--tile) }
.app-row strong { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.app-row .grow { flex: 1; min-width: 0; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row .btn-row { flex: none; gap: 2px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); margin-top: 10px; }
.pw-form { display: grid; gap: 12px; }

.city-picker { position: relative; display: grid; gap: 6px; }
.upload-drop { display: grid; gap: 8px; padding: 16px; border: 1px dashed var(--field-border); border-radius: var(--radius-sm); text-align: center; font-size: 13px; color: var(--text-dim); background: var(--inset); }
.icon-preview { display: flex; align-items: center; gap: 12px; }
.icon-preview .tile-icon { width: 46px; height: 46px; font-size: 24px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--menu);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow), var(--panel-top);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  animation: toast-in 0.2s var(--ease-out);
}
.toast.bad { background: rgba(64, 24, 28, 0.9); border-color: rgba(255, 120, 120, 0.28); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 左侧分组导航 ---------- */

.side-nav {
  position: fixed;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: grid;
  gap: 11px;
  /* 显现方式与右上角工具区一致：整列平时压到 32%，指针靠近或键盘聚焦进去才整体清晰 */
  opacity: 0.32;
  transition: opacity 0.22s ease;
}
.side-nav[hidden] { display: none; }
.side-nav:hover, .side-nav:focus-within { opacity: 1; }

.side-dot {
  position: relative;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  /* 白色透明：不描边、不铺玻璃块，显现全靠整列的淡入淡出 */
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: transform 0.18s var(--spring);
}
.side-dot-icon {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  overflow: hidden;
  /* 一律染成白色剪影：Emoji、图片、首字母都不留彩色 */
  filter: brightness(0) invert(1);
}
.side-dot-icon img { width: 100%; height: 100%; object-fit: contain; }
.side-dot-icon.letter { font-size: 13px; font-weight: 700; }
.side-dot:hover { transform: scale(1.18); }
.side-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 图标被统一染白了，当前分组只能靠右下角这枚强调色点 */
.side-dot.active::after {
  content: '';
  position: absolute;
  right: 1px;
  bottom: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
/* 折叠的分组在整列里再淡一档，和展开的区分开 */
.side-dot.folded { opacity: 0.55; }

/* ---------- 右侧滚动轨：鼠标移到页面右缘才出现，可拖动跳转 ---------- */

.scroll-zone {
  position: fixed;
  right: 2px;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 15;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.scroll-zone[hidden] { display: none; }
.scroll-zone.dragging { cursor: grabbing; }

.scroll-rail {
  width: 4px;
  height: calc(100% - 52px);
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.scroll-zone:hover .scroll-rail, .scroll-zone.dragging .scroll-rail { opacity: 1; }

.scroll-thumb {
  display: block;
  width: 4px;
  min-height: 34px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 34%, transparent);
  will-change: transform;
  transition: background 0.16s ease;
}
.scroll-zone.dragging .scroll-thumb { background: var(--accent); }

/* ---------- 卡片上的左右移动按钮（编辑模式） ---------- */

.tile-move {
  position: absolute;
  left: 5px;
  top: 5px;
  display: none;
  gap: 3px;
}
[data-edit="on"] .tile-move { display: flex; }

.tile-move button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.16s ease, background 0.16s ease, transform 0.16s var(--spring);
}
.tile-move button:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 78%, #000); transform: scale(1.12); }
.tile-move button:active { transform: scale(0.94); transition-duration: 0.08s; }
.tile-move button:disabled { opacity: 0.22; cursor: not-allowed; transform: none; }

[data-layout="left"] .tile-move { left: auto; right: 29px; top: 50%; transform: translateY(-50%); }
/* 左右键 + 互换键 + 删除键一共占到右侧 95px，给文字留出空间 */
[data-edit="on"][data-layout="left"] .tile { padding-right: 95px; }
/* 图在上时顶部整条留给左右键和删除键，免得压到图标 */
[data-edit="on"][data-layout="top"] .tile { padding-top: calc(var(--title-fs, 12.5px) * 2.4); }

/* 「小」档卡片只有 71–88px 宽，放不下默认的 ◀ ▶ ⇄（60px）加 ✕（18px）：编辑模式统一在顶部留一条
   横幅，移动键改小一号和 ✕ 一头一尾，图标和名称整排往下挪，谁也不压谁；卡片放弃 1:1 会长高一点。 */
[data-edit="on"] [data-size="small"] .tile {
  aspect-ratio: auto;
  padding: calc(var(--title-fs, 12.5px) * 2.4) 4px calc(var(--title-fs, 12.5px) * 0.7);
}
[data-edit="on"] [data-size="small"] .tile-title { -webkit-line-clamp: 1; text-overflow: ellipsis; }
[data-edit="on"] [data-size="small"] .tile-move { left: 4px; right: auto; top: 5px; bottom: auto; gap: 2px; transform: none; }
[data-edit="on"] [data-size="small"] .tile-move button { width: 14px; height: 14px; font-size: 8px; }
/* ✕ 在图在左时本来竖直居中压着数字，小档卡片太窄，统一挪回右上角；
   两处都小一号才塞得进 71px 宽的卡片（移动键 48px + ✕ 15px） */
[data-edit="on"] [data-size="small"] .tile .tile-x { top: 5px; right: 4px; width: 15px; height: 15px; font-size: 9px; transform: none; }

/* ---------- 容器组件的摆放区：不再有窗口这块玻璃，每张组件按配置里的 x/y 直接摆在页面上 ---------- */

.dk-layer {
  position: relative;
  /* 高度由 app.js 按最下面那张组件算：绝对定位不撑页面，不自己拉出来就滚不到下面那截 */
  margin-top: var(--gap-panel);
}

/* 一张容器组件：图标在左，右边三行——名称 / 状态·镜像 / 实时数字。
   图标档位（--icon-size）不参与，这里按自己的字号算，所以一张卡不受「小/中/大」影响。
   启停全部在右键菜单里，卡片底下不再常年留一条按钮的位置；挪位置是长按拖，也不用 ◀ ▶。 */
.dk-tile {
  /* 位置与尺寸都由 app.js 写成 --dk-* 变量。left 再跟「摆放区宽 − 自身宽」取小：
     窄屏上配置里那 900px 摆不下，夹一下就不至于把整页撑出横向滚动，配置里的数字一个都不动。 */
  position: absolute;
  left: min(var(--dk-x, 0px), calc(100% - min(var(--dk-tile-w, 250px), 100%)));
  top: var(--dk-y, 0px);
  box-sizing: border-box;
  width: min(var(--dk-tile-w, 250px), 100%);
  height: var(--dk-tile-h, 118px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon meta"
    "icon stat";
  align-content: center;
  justify-items: start;
  gap: 2px 11px;
  padding: calc(var(--title-fs, 12.5px) * 0.6) calc(var(--title-fs, 12.5px) * 0.85);
  font-size: var(--title-fs, 12.5px);
  /* 这是带实时数字的服务卡，给一层凹槽底 + 发丝边，跟窗口那层玻璃分出上下级 */
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: var(--inset);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.18s var(--ease-out), background 0.18s ease, border-color 0.18s ease, opacity 0.24s ease;
  --icon-size: calc(var(--title-fs, 12.5px) * 2.6);
}
.dk-tile:hover { transform: translateY(-2px); background: var(--tile); border-color: var(--card-border); }
.dk-tile:hover .tile-icon { transform: scale(1.05); }
.dk-tile .tile-icon { grid-area: icon; align-self: center; justify-self: start; }
/* 名称最重，状态那行次之，数字最轻：三层轻重分明，扫一眼就知道看哪个 */
.dk-tile .tile-title { grid-area: title; align-self: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dk-tile .tile-stat { grid-area: stat; align-self: start; align-items: flex-start; min-width: 0; max-width: 100%; overflow: hidden; font-size: 0.8em; }
.dk-meta { grid-area: meta; align-self: start; display: flex; align-items: center; gap: 0.4em; min-width: 0; max-width: 100%; font-size: 0.84em; line-height: 1.35; }
.dk-state { flex: none; font-weight: 600; }
/* 镜像名等宽小字：跟容器名区分开，也方便一眼比对同一个镜像起的多个容器 */
.dk-image { min-width: 0; color: var(--text-faint); font-family: ui-monospace, monospace; font-size: 0.92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-tile .stat-line { gap: 0.4em; }
.dk-tile .stat-line .k { color: var(--text-faint); font-weight: 400; }
.dk-tile .stat-line .sep { margin-left: 0.9em; }
.dk-tile .stat-line b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dk-tile [data-net] { color: var(--text-dim); }
/* 状态那行跟着状态点同一套颜色：点只有 8px，光靠它在壁纸上不够显眼 */
.dk-tile[data-dstate="running"] .dk-state { color: #4ade80; }
.dk-tile[data-dstate="paused"] .dk-state,
.dk-tile[data-dstate="restarting"] .dk-state { color: #fbbf24; }
.dk-tile[data-dstate="exited"] .dk-state,
.dk-tile[data-dstate="created"] .dk-state,
.dk-tile[data-dstate="dead"] .dk-state,
.dk-tile[data-dstate="missing"] .dk-state,
.dk-tile[data-dstate="unreachable"] .dk-state { color: #f87171; }
/* 停着 / 查不到的整张压暗一档，一屏里先看亮着的那些 */
.dk-tile[data-dstate="exited"],
.dk-tile[data-dstate="created"],
.dk-tile[data-dstate="dead"],
.dk-tile[data-dstate="missing"],
.dk-tile[data-dstate="unreachable"] { opacity: 0.68; }
/* 跑着的那枚点轻轻呼吸一下，表示这串数字是活的（系统要求减少动效时全局那条规则会关掉它） */
.dk-tile[data-dstate="running"] .stat-dot { animation: dk-live 2.6s ease-in-out infinite; }
@keyframes dk-live {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  55% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
/* 容器组件允许不填网址（点开只报一句状态），所以不像网址卡片那样整卡压暗 */
.dk-no-href { cursor: default; }
.dk-no-href:hover { transform: none; background: var(--inset); border-color: var(--panel-border); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03); }
.dk-no-href:hover .tile-icon { transform: none; }

/* 编辑模式：右上角一颗 ✕，跟分组卡片那套一致。顶部留一条是给 ✕ 让开名称，
   挪位置不需要 ◀ ▶ ——长按这张卡拖到任意坐标就行。 */
[data-edit="on"] .dk-tile { padding-top: calc(var(--title-fs, 12.5px) * 2); cursor: grab; }
[data-edit="on"] .dk-tile .tile-x { display: grid; top: 5px; right: 5px; width: 15px; height: 15px; font-size: 9px; transform: none; }

/* 长按起拖的那张抬起来：位置是绝对定位算出来的，抬升只能靠 z-index，别再跟着 transform 走 */
.dk-tile.dragging { z-index: 6; opacity: 0.9; cursor: grabbing; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42); }
body.holding-drag .dk-tile { cursor: grabbing; }
body.holding-drag .dk-tile.dragging:hover { transform: none; }

/* 设置里那一行的两个宽高滑块 */
.dk-row { flex-wrap: wrap; }
.dk-row .size-set {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  font-size: 12px;
  color: var(--text-faint);
}
.dk-row .size-set label { display: flex; align-items: center; gap: 7px; }
.dk-row .size-set input[type="range"] { width: 128px; accent-color: var(--accent); }
.dk-row .size-set b { min-width: 44px; font-weight: 550; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */

.modal.login {
  overflow: hidden;
  /* 登录页底色保持克制：顶部一小片强调色光晕 + 深底，不做高饱和大渐变 */
  background:
    radial-gradient(1200px 660px at 50% -20%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* 登录页背景 = 主页那张壁纸，铺在上面那套底色之上；没设壁纸时这两层是空的，露出原底 */
.login-bg, .login-veil {
  position: absolute;
  inset: -40px;
  z-index: -2;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: var(--wp-size, cover);
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.login-veil { z-index: -1; background: radial-gradient(130% 100% at 50% -10%, rgba(6, 8, 13, 0.12) 0%, var(--bg-deep) 82%); opacity: 0; }

.login-inner {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 22px;
  justify-items: center;
  text-align: center;
  color: var(--text-dim);
  animation: login-in 0.34s var(--ease-out);
}

/* 品牌锁版：标在左、「设置 → 外观」里那个页面标题在右，两个一起当登录页的 logo */
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 88vw;
  min-width: 0;
}
/* 品牌标是定稿的渐变图（青→蓝→紫），颜色跟着图走、不吃强调色；只留一层投影把它从壁纸里托出来 */
.login-mark {
  flex: none;
  width: auto;
  height: 34px;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.45));
}

.login-logo {
  margin: 0;
  min-width: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-card {
  display: grid;
  gap: 11px;
  width: min(368px, 100%);
  padding: 24px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: var(--modal);
  box-shadow: var(--shadow), var(--panel-top);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  transition: box-shadow 0.24s ease, border-color 0.24s ease;
}

.login-card:focus-within {
  border-color: var(--accent-line);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}

.login-card .field {
  border-color: var(--panel-border);
  background: var(--inset);
  color: var(--text);
  font-size: 15px;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
}
.login-card .field:focus { outline: none; background: var(--field); border-color: var(--accent-line); box-shadow: none; }
.login-card .field::placeholder { color: var(--text-faint); }

.login-card .btn { width: 100%; margin-top: 4px; padding: 12px 14px; font-size: 14.5px; }
.login-card .btn:disabled { cursor: progress; opacity: 0.6; }

.login-card.shake { animation: login-shake 0.36s ease; }

@keyframes login-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
  88% { transform: translateX(2px); }
}

/* ---------- 手机浏览器：窄屏版式 ---------- */

@media (max-width: 720px) {
  :root { --gap-panel: 12px; --pad-panel: 14px 15px 16px; --radius: 16px; }
  .app {
    padding: 12px calc(14px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  .panels { grid-template-columns: 1fr; }
  .hero { padding-top: 3vh; }
  .search { margin-top: 18px; }
  .group { padding: 4px 14px 14px; }
  .group-head { padding: 6px 0 9px; margin-bottom: 11px; }
  .engine-form { grid-template-columns: 1fr; }
  .engine-form .field.wide, .engine-form .btn { grid-column: 1 / -1; }
  select.field { max-width: 100%; }
  /* 窄屏只把列宽收一点点：档位本身已经贴紧图标了，再砍 18px 名称就会被裁成两行还装不下 */
  .tiles { grid-template-columns: repeat(auto-fill, minmax(calc(var(--tile-min, 104px) - 8px), 1fr)); }
  .modal { padding: 14px calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
  .modal-card { max-height: min(86dvh, 780px); }
  .modal.login { padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  /* 提示条抬高一点，别压在手机底部那条返回横杠上 */
  .toast { bottom: calc(34px + env(safe-area-inset-bottom)); }
  /* 登录框是撑内容宽的，不给它宽度就只有名片那么大 */
  .login-inner { width: 100%; }

  /* 容器组件在手机上不再照配置里的坐标摆：坐标是桌面那块画布上的，夹进屏宽只会互相叠住。
     一律改成竖排静态流，顺序就是数组顺序（＝主页上叠放的上下级），配置里的 x/y / w / h 一个数字都不动，
     回到桌面还是照你排好的样子。height 是 app.js 按坐标算的，这一档要 !important 才压得住。 */
  .dk-layer { display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-panel); height: auto !important; }
  .dk-tile { position: static; width: min(var(--dk-tile-w, 250px), 100%); }

  /* 那列分组圆点是浮在内容上的，窄屏给第一个图标让开它的宽度；内核不认 :has 就只是少留一点白 */
  .side-nav { left: calc(4px + env(safe-area-inset-left)); }
  body:has(.side-nav:not([hidden])) .app { padding-left: calc(40px + env(safe-area-inset-left)); }
}

/* ---------- 手机浏览器：没有悬停这件事 ---------- */

@media (hover: none) {
  /* 平时靠 :hover 才显现的，一律直接摊开：不摊手指永远点不到 */
  .corner-tools {
    opacity: 1;
    top: calc(6px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
  }
  .side-nav { opacity: 0.72; }
  .side-nav:focus-within { opacity: 1; }
  .scroll-zone { display: none; }
  .engine-reveal { max-width: 120px; opacity: 1; margin-left: 7px; }

  /* 长按手势已经归「拖拽 / 菜单」了，别给系统留出弹链接预览、选中文字的口子 */
  .tile, .dk-tile, .side-dot, .group-name, .tile-title, .tile-stat, .dk-meta {
    -webkit-touch-callout: none;
  }
  /* 点完没有第二次移动去解除悬停，卡片会一直抬着：把这些抬起/缩放的效果在触摸设备上全压掉，淡底留着当按下反馈 */
  .tile:hover, .dk-tile:hover, .tile.no-href:hover, .dk-no-href:hover { transform: none; }
  .tile:hover .tile-icon, .dk-tile:hover .tile-icon, .no-href:hover .tile-icon { transform: none; }
  .icon-btn:hover, .chip:hover, .btn.ghost:hover, .side-dot:hover, .search-go:hover,
  .tile-move button:hover, .corner-btn:hover { transform: none; box-shadow: none; }

  /* 触摸目标：能点的东西都放大到指头尺寸 */
  .corner-btn { width: 34px; height: 34px; }
  .corner-btn svg { width: 18px; height: 18px; }
  .side-dot { width: 32px; height: 32px; }
  .tile-x { width: 24px; height: 24px; font-size: 13px; }
  .tile-move button { width: 20px; height: 20px; font-size: 11px; }
  [data-edit="on"] [data-size="small"] .tile .tile-x { width: 24px; height: 24px; font-size: 12px; }
  [data-edit="on"] [data-size="small"] .tile-move button { width: 20px; height: 20px; font-size: 10px; }
  [data-edit="on"] .dk-tile .tile-x { width: 24px; height: 24px; font-size: 12px; }
  .icon-btn.mini { min-width: 34px; height: 34px; }
  .tab { padding: 10px 13px; }
  .btn { padding: 11px 14px; }
  .ctx-menu button, .menu li button { padding: 12px 13px; font-size: 15px; }
  .todo-add button { width: 42px; }

  /* 小档卡片窄到 56px，触摸尺寸的 ◀ ▶ ✕ 三个键塞不下：编辑模式下这一档的列宽让开一点 */
  [data-edit="on"] [data-size="small"] .tiles { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }

  /* 输入框不到 16px，iOS 一聚焦就把整页放大且缩不回去 */
  .field { font-size: 16px; }
  .search-input { height: 46px; font-size: 16px; }
  .search-go { width: 46px; height: 34px; }
  .login-card .field { font-size: 16px; }
  .notes { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
