/*
 * MB 资产面板样式。不依赖任何框架。
 *
 *   1. 设计变量(深色 / 浅色主题)
 *   2. 基础与页面骨架
 *   3. 通用组件:按钮、输入框、标签、卡片、提示、对话框
 *   4. 面板首页:概览条、工具栏、资产小块网格、管理面板、批量操作条
 *   5. 表单(资产表单与设置页共用一套 12 列网格)
 *   6. 窄屏适配
 *   7. 动效
 *
 * 设计原则:
 *   - 内容自适应:小块网格按可用宽度自动决定列数,从手机的 1 列到超宽屏的 6 列,没有固定断点的"两套界面";
 *   - 不截断:长域名、长备注一律换行显示,同一排的小块等高对齐;
 *   - 少用颜色:只有需要处理的(即将到期、已过期)才上色,其余信息用灰度区分层级;
 *   - 动效只改 transform / opacity / 颜色,不改变排版;时长在 0.3 秒以内,不让人等。
 *
 * 字号统一用像素值:正文 14px,次要信息 12-12.5px,标签 11-11.5px。
 * 页面的 CSP 禁止内联样式,所有样式都必须写在这里。
 */

/* ---------- 1. 设计变量 ---------- */

:root {
  --bg: #0b0b0d;
  --surface: #141418;
  --surface-2: #1c1c22;
  --surface-3: #26262f;
  --field: #0f0f13;
  --border: #282831;
  --border-strong: #3a3a47;

  --text: #ececf1;
  --text-2: #a9a9b7;
  --text-3: #7b7b8a;

  --accent: #7c6cff;
  --accent-strong: #9082ff;
  --accent-soft: rgba(124, 108, 255, .16);
  --accent-text: #c4bbff;

  --ok: #3ccb8f;
  --warn: #f0b545;
  --warn-soft: rgba(240, 181, 69, .15);
  --danger: #f37272;
  --danger-soft: rgba(243, 114, 114, .15);
  --danger-solid: #cf4545;

  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --radius: 12px;
  --radius-sm: 8px;

  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* 动效:出现、移动用"快出慢停"的曲线,消失用渐快的曲线 */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --dur-fast: .14s;
  --dur: .24s;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #f2f2f6;
  --surface-3: #e7e7ee;
  --field: #ffffff;
  --border: #e2e2ea;
  --border-strong: #cbcbd7;

  --text: #18181d;
  --text-2: #53535e;
  --text-3: #787885;

  --accent: #5b4be0;
  --accent-strong: #4a3bcb;
  --accent-soft: rgba(91, 75, 224, .1);
  --accent-text: #4b3cc9;

  --ok: #0f8455;
  --warn: #946000;
  --warn-soft: rgba(176, 116, 0, .13);
  --danger: #c63636;
  --danger-soft: rgba(198, 54, 54, .1);
  --danger-solid: #c63636;

  --shadow: 0 12px 32px rgba(24, 24, 40, .16);

  color-scheme: light;
}

/* ---------- 2. 基础与页面骨架 ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable; /* 筛选后页面变短、滚动条消失时,内容宽度不变,小块不会整体跳一下 */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ul {
  margin: 0;
}

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

a:hover {
  text-decoration: underline;
}

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

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

.mono { font-family: var(--mono); }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }

/* 页面最宽 1920px:再宽的屏幕上小块已经能排 7 列,继续拉宽只会让视线来回移动得太远 */
.container {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding-left: clamp(12px, 2vw, 28px);
  padding-right: clamp(12px, 2vw, 28px);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 40px;
}

/* 表单、设置等以阅读和填写为主的页面:限制宽度并居中,避免输入框被拉得又宽又扁 */
.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}

.page-narrow { max-width: 720px; }
.page-tiny { max-width: 400px; margin-top: 24px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-title {
  font-size: 19px;
  font-weight: 700;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 48px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-actions form {
  margin: 0;
}

.footer {
  padding-bottom: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------- 3. 通用组件 ---------- */

/* 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast),
    border-color var(--dur-fast),
    color var(--dur-fast),
    scale var(--dur-fast) var(--ease);
}

.btn:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.btn:active:not(:disabled) {
  scale: .97;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

/* 处于"已开启"状态的开关按钮(如批量模式) */
.btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* 输入框 */

.input,
.select {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--field);
  color: var(--text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled {
  opacity: .5;
}

textarea.input {
  resize: vertical;
}

.select {
  padding-right: 28px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238a8a98' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px;
}

.select-sm {
  width: auto;
  min-height: 30px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.input-narrow {
  width: 96px;
}

/* 并排的输入框 + 下拉框 / 按钮 */
.input-group {
  display: flex;
  gap: 6px;
}

.input-group .input {
  flex: 1;
  min-width: 0;
}

.input-group .select,
.input-group .btn {
  flex: none;
  width: auto;
}

.check,
.radio-row input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

/* 小标签:地区、"对访客隐藏"等 */
.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.65;
  white-space: nowrap;
  vertical-align: middle;
}

.tag-accent { background: var(--accent-soft); color: var(--accent-text); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }

/* 卡片与提示 */

.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-title {
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 650;
}

.card-desc {
  margin: -8px 0 14px;
  color: var(--text-2);
  font-size: 13px;
}

.alert {
  padding: 10px 14px;
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-wrap: anywhere;
  animation: drop-in .32s var(--ease);
}

.alert-ok { border-left-color: var(--ok); }
.alert-error { border-left-color: var(--danger); background: var(--danger-soft); }

.info-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.info-line {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
}

.error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.error-status {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-3);
}

/* 分段按钮:设置页的分类切换 */

.segments {
  display: flex;
  flex-wrap: wrap;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.segment {
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--text-2);
  font-weight: 600;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.segment:hover {
  color: var(--text);
  text-decoration: none;
}

.segment.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* 对话框 */

.dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;

  /* 关闭状态(也是退场动画的终点) */
  opacity: 0;
  translate: 0 8px;
  scale: .97;
  transition-property: opacity, translate, scale;
  transition-duration: var(--dur-fast);
  transition-timing-function: var(--ease-in);
}

.dialog[open] {
  opacity: 1;
  translate: 0 0;
  scale: 1;
  transition-duration: var(--dur);
  transition-timing-function: var(--ease);
}

/* 打开时的起点 */
@starting-style {
  .dialog[open] {
    opacity: 0;
    translate: 0 8px;
    scale: .97;
  }
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0);
  transition-property: background-color;
  transition-duration: var(--dur-fast);
}

.dialog[open]::backdrop {
  background: rgba(0, 0, 0, .55);
  transition-duration: var(--dur);
}

@starting-style {
  .dialog[open]::backdrop {
    background: rgba(0, 0, 0, 0);
  }
}

/* 关闭时的退场动画:需要对话框在动画期间留在顶层(overlay)、不立即隐藏(display)。
   不支持 overlay 的浏览器只播放打开动画,关闭时直接消失,而不是在页面里闪一下。 */
@supports (overlay: auto) {
  .dialog,
  .dialog::backdrop {
    transition-property: opacity, translate, scale, background-color, overlay, display;
    transition-behavior: allow-discrete;
  }
}

.dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.dialog-title {
  font-size: 15px;
  font-weight: 650;
}

.dialog-message {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.dialog-indent {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 26px;
}

.dialog-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.dialog-group legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--text-3);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 底部的轻提示 */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(480px, calc(100vw - 24px));
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind="error"] {
  border-color: var(--danger);
}

/* 复制文本时临时插入的输入框(见 app.js 的 copyText) */
.clipboard-helper {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ---------- 4. 面板首页 ---------- */

.board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 概览条:几个数字排成一行,而不是几张大卡片 */

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 32px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: inherit;
}

.stat:hover {
  text-decoration: none;
}

a.stat:hover .stat-value {
  color: var(--accent-text);
}

.stat-label {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.stat-value small {
  margin-left: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.stat-control {
  margin-left: auto;
  gap: 2px;
}

.summary-note {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: 0 16px;
  color: var(--text-3);
  font-size: 11.5px;
}

/* 工具栏:高度够用时吸附在顶部,滚动长列表时随时可以搜索和筛选 */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  z-index: 15;
  padding: 6px 0;
  background: var(--bg);
}

/* 屏幕太小(手机、横屏手机)时不吸顶,免得工具栏占掉大半个屏幕 */
@media (min-width: 641px) and (min-height: 560px) {
  .toolbar {
    position: sticky;
    top: 0;
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 到期状态:数字本身就是筛选按钮 */
.filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-fast),
    border-color var(--dur-fast),
    color var(--dur-fast),
    scale var(--dur-fast) var(--ease);
}

.filter:active {
  scale: .96;
}

.filter b {
  color: var(--text);
  font-weight: 700;
}

.filter-expired b,
.filter-danger b { color: var(--danger); }
.filter-warn b { color: var(--warn); }

.filter:hover {
  border-color: var(--accent);
}

.filter.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.toolbar-search {
  flex: 1 1 200px;
  max-width: 400px;
}

.toolbar-sort {
  flex: 0 1 auto;
  width: auto;
}

.toolbar-end {
  margin-left: auto;
}

/* 一类资产(域名 / VPS) */

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-margin-top: 64px; /* 从锚点跳转过来时,不被吸顶的工具栏挡住 */
}

.group + .group {
  margin-top: 10px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}

.group-title {
  font-size: 15px;
  font-weight: 700;
}

.group-actions {
  display: flex;
  gap: 6px;
}

.group-count {
  margin-left: 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}

.group-empty,
.group-note {
  color: var(--text-3);
}

.group-empty {
  padding: 18px 0;
  text-align: center;
  animation: fade-in var(--dur) var(--ease);
}

.group-note {
  font-size: 12px;
}

/*
 * 小块网格。所有小块一样宽、一样高:同一排不会有谁被撑高,也不会有谁被加宽。
 *
 * 列数由内容决定:app.js 的 fitColumns 从能排下的最多列数开始尝试,找出所有小块都保持
 * 同样高度(内容不换行到第三行)的最多列数,写到 data-cols 上。换句话说,列宽取决于最长的那条内容。
 * 下面的 auto-fill 只是脚本运行之前(或没有脚本时)的初始排法。
 */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr));
  gap: 6px;
  padding: 0;
  list-style: none;
}

.tiles-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

.tiles[data-cols="1"] { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.tiles[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles[data-cols="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tiles[data-cols="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.tiles[data-cols="8"] { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.tiles[data-cols="9"] { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.tiles[data-cols="10"] { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.tiles[data-cols="11"] { grid-template-columns: repeat(11, minmax(0, 1fr)); }
.tiles[data-cols="12"] { grid-template-columns: repeat(12, minmax(0, 1fr)); }

/* fitColumns 测量时:不拉伸(读到的是内容本身的高度),筛选掉的小块也临时参与测量,
   这样列数不会随搜索、筛选来回变化。整个测量在同一帧内完成,页面上看不到。 */
.tiles.is-measuring > .tile {
  align-self: start;
}

.tiles.is-measuring > .tile[hidden] {
  display: flex !important;
}

.tile {
  align-self: start;
}

.tiles-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition:
    background-color var(--dur-fast),
    border-color var(--dur-fast),
    opacity var(--dur-fast),
    scale var(--dur-fast) var(--ease);
}

/* 刚被操作过的小块短暂高亮,方便找到它(例如置顶后移到了最前面) */
@keyframes tile-updated {
  from {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
}

.tile.is-updated {
  animation: tile-updated 1.6s ease-out;
}

/* 置顶:左侧一条强调色 */
.tile.is-pinned {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tile[role="button"] {
  cursor: pointer;
}

.tile[role="button"]:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.tile[role="button"]:active {
  scale: .985;
}

.tile[draggable="true"] {
  cursor: grab;
}

.tile.is-dragging {
  opacity: .4;
}

.tile-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.tile-name {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere; /* 长域名换行显示,不截断 */
}

.tile-name .tag {
  font-family: var(--font);
}

a.tile-name:hover {
  color: var(--accent-text);
  text-decoration: none;
}

/* 到期标签:普通状态只是一段灰字,需要留意的才有底色 */
.due {
  flex: none;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}

.due-normal,
.due-invalid { padding: 0; color: var(--text-3); font-weight: 500; }
.due-permanent { padding: 0; color: var(--ok); }
.due-warn { background: var(--warn-soft); color: var(--warn); }
.due-danger { background: var(--danger-soft); color: var(--danger); }
.due-expired { background: var(--danger-solid); color: #fff; }

/* 第二行:到期日期在左,价格在右。两者长度固定,不会换行 */
.tile-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 1.55em; /* 永久且免费等情况下这一行内容很少,也保持一行高 */
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
}

/* 第三行:注册商(VPS 是 IP 和配置)及备注。长度不定,所以单独占一行、用满整个宽度 */
.tile-sub {
  min-height: 1.55em; /* 没有注册商、备注的记录也保持一行高,和其它小块一致 */
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tile-sub > span {
  margin-right: 5px; /* 各项之间除了一个空格再多留一点间距 */
}

.tile-note {
  color: var(--text-3);
  white-space: pre-line; /* 保留备注里的换行 */
}

.tile-cost {
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.tile-cost > span + span {
  margin-left: 8px;
}

/*
 * 只有一列时(手机竖屏)没有并排的小块需要对齐,不必固定三行:把第二、三行合成一行
 * ——左边日期,中间注册商 / 配置 / 备注(可换行),右边价格——列表短很多。
 * 第二行的容器用 display: contents 拆开,日期和价格直接参与小块的排版。
 */
.tiles[data-cols="1"] > .tile {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.tiles[data-cols="1"] > .tile > .tile-top {
  flex: 0 0 100%;
}

.tiles[data-cols="1"] > .tile > .tile-row {
  display: contents;
}

.tiles[data-cols="1"] .tile-row > :empty {
  display: none; /* 永久有效的记录没有日期,不留空位 */
}

.tiles[data-cols="1"] > .tile > .tile-sub {
  flex: 1 1 0;
  min-width: 0;
  order: 1;
}

.tiles[data-cols="1"] .tile-row > .tile-cost {
  order: 2;
  margin-left: auto;
}

/* 只在管理面板里显示的补充信息(折算金额、年化价格) */
.detail-only {
  display: none;
}

/* VPS 的配置标签:和 IP、备注排在第三行的同一段文字里 */
.spec {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.65;
}

/* 批量模式:小块左上角出现勾选框,点击小块即选中 */

.tile-check {
  display: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--field);
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}

html[data-selecting] .tile-check {
  display: block;
}

.tile.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tile.is-selected .tile-check {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

html[data-selecting] .main {
  padding-bottom: 170px; /* 给底部的操作条让位 */
}

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  transition-property: opacity, translate, display;
  transition-duration: var(--dur);
  transition-timing-function: var(--ease);
  transition-behavior: allow-discrete;
}

/* 进入批量模式时从下方滑入,退出时滑出(用 translate,和定位用的 transform 互不影响) */
.selection-bar[hidden] {
  opacity: 0;
  translate: 0 16px;
  transition-timing-function: var(--ease-in);
}

@starting-style {
  .selection-bar {
    opacity: 0;
    translate: 0 16px;
  }
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

/* 点击小块后弹出的管理面板 */

.sheet {
  width: min(560px, calc(100vw - 24px));
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sheet-info .tile-name {
  font-size: 16px;
}

.sheet-info .tile-row,
.sheet-info .tile-sub {
  font-size: 13.5px;
}

.sheet-info .tile-check {
  display: none;
}

.sheet-info .detail-only {
  display: inline;
}

/* 面板里价格后面还跟着折算金额,宽度不定:放不下时整体换行 */
.sheet-info .tile-row {
  flex-wrap: wrap;
}

.sheet-info .tile-cost {
  white-space: normal;
}

.sheet-row {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr);
  gap: 8px;
}

.sheet-label {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  line-height: 30px;
}

.sheet-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- 5. 表单 ---------- */

/*
 * 12 列网格。字段默认占满一行,用 .col-N 指定跨几列;
 * 窄屏时全部改为占满一行,带 .half 的短字段两两并排。
 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  gap: 14px 16px;
}

.form-grid + .form-grid {
  margin-top: 16px;
}

.form-grid > * {
  grid-column: 1 / -1;
  min-width: 0;
}

.form-grid > .col-2 { grid-column: span 2; }
.form-grid > .col-3 { grid-column: span 3; }
.form-grid > .col-4 { grid-column: span 4; }
.form-grid > .col-5 { grid-column: span 5; }
.form-grid > .col-6 { grid-column: span 6; }
.form-grid > .col-8 { grid-column: span 8; }

.field,
.form-grid > div,
.form-grid > form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
}

.field-label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}

.field-help {
  color: var(--text-3);
  font-size: 12px;
}

.field-button {
  align-self: flex-start;
}

/* 分组小标题 */
.form-section {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
}

.form-grid > .form-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.form-delete {
  margin-left: auto;
}

.disk-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.rate-row {
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(110px, 170px) minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
}

/* 设置页:有脚本时一次只显示一个面板;没有脚本时全部依次排开 */
.js .settings-panel:not(.is-active) {
  display: none;
}

.js .settings-panel.is-active {
  animation: rise-in var(--dur) var(--ease);
}

/* ---------- 6. 窄屏适配 ---------- */

@media (max-width: 640px) {
  /* 触屏需要更大的点击区域;16px 的输入框字号可避免 iOS 聚焦时自动放大页面 */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }

  .input,
  .select {
    min-height: 40px;
    font-size: 16px;
  }

  .select-sm {
    min-height: 34px;
    font-size: 14px;
  }

  .summary {
    gap: 8px 22px;
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 17px;
  }

  /* 小计换到数字下面,这样几项统计和币种选择能排在同一行 */
  .stat-value small {
    display: block;
    margin-left: 0;
  }

  .summary {
    align-items: flex-start;
  }

  .summary-note .mono {
    display: none; /* 手机上只保留汇率来源,具体汇率在设置页查看 */
  }

  .toolbar-search {
    flex-basis: 100%;
    max-width: none;
    order: -1; /* 手机上搜索框放在最上面,独占一行 */
  }

  /* 四个状态按钮平分一行 */
  .filters {
    flex-basis: 100%;
    flex-wrap: nowrap;
    gap: 5px;
  }

  .filter {
    flex: 1;
    justify-content: center;
    gap: 4px;
    padding: 0 4px;
  }

  .toolbar-sort {
    flex: 1;
  }

  .toolbar-end {
    margin-left: 0;
  }

  .card {
    padding: 14px;
  }

  .form-grid > [class*="col-"] {
    grid-column: 1 / -1;
  }

  .form-grid > .half {
    grid-column: span 6;
  }

  .form-delete {
    margin-left: 0;
  }

  .rate-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .rate-row > .field-help {
    grid-column: 1 / -1;
  }

  /* 对话框从底部升起,占满宽度,拇指够得着 */
  .dialog {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    margin: auto 0 0;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    translate: 0 100%;
    scale: 1;
  }

  @starting-style {
    .dialog[open] {
      translate: 0 100%;
      scale: 1;
    }
  }

  .selection-bar {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    transform: none;
  }
}

/* ---------- 7. 动效 ---------- */

/*
 * 需要知道"之前在哪儿"的位移动画(排序、筛选、置顶、删除时小块滑到新位置,
 * 进出批量模式时名称让出勾选框的位置)由 app.js 的 flip 完成,这里是公用的关键帧。
 */
@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes rise-in {
  from { opacity: 0; translate: 0 6px; }
}

@keyframes drop-in {
  from { opacity: 0; translate: 0 -6px; }
}

/* 页面之间跳转(打开设置、提交表单后回到面板等)时新旧页面交叉淡入,而不是白屏一闪。
   不支持跨页面 View Transitions 的浏览器照常跳转。 */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .2s;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
    animation-duration: 1ms !important;
  }
}
