/* Admin page: login card, editable grid, editor drawer. */

.admin-wrap {
  padding-bottom: 80px;
}

/* ------------------------------------------------------------------- login */

.login-card {
  width: min(400px, 100%);
  margin: 64px auto;
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--ink-700) 88%, transparent);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.login-card__logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.login-card__error {
  margin-top: 14px;
  color: #ffb4b6;
}

/* 抽屉里的互斥选项：并排两个按钮，选中的那个点亮，下面的内容面板跟着切 */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-900);
}

.segmented__btn {
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.segmented__btn:hover {
  color: var(--text);
}

.segmented__btn.is-on {
  background: color-mix(in srgb, var(--accent) 30%, var(--ink-700));
  color: var(--text);
}

.action-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 登录卡底部的「返回主页」 */
.login-card__back {
  margin: 16px 0 0;
}

/* ------------------------------------------------------------------ topbar */

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

.dirty-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  font-size: 12.5px;
  color: color-mix(in srgb, var(--accent) 25%, white);
}

.dirty-flag::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ------------------------------------------------------------ site settings */

.panel {
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ink-700) 70%, transparent);
}

.panel > summary {
  padding: 13px 18px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-dim);
  user-select: none;
}

.panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.panel__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 18px;
}

.panel__body .field--wide {
  grid-column: 1 / -1;
}

/* ---------------------------------------------------------------- files */

.files {
  padding: 18px;
}

.file-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.file-tab {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.file-tab[aria-selected='true'] {
  background: color-mix(in srgb, var(--accent) 22%, var(--ink-700));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}

.file-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink-900) 55%, transparent);
  font-size: 13px;
}

.file-row__thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ink-800);
}

.file-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-row__thumb--text {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.file-row__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-row__meta {
  flex: none;
  color: var(--text-dim);
  font-size: 12px;
}

.file-row__badge {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, var(--ink-700));
  font-size: 11.5px;
}

.file-row__acts {
  flex: none;
  display: flex;
  gap: 4px;
}

.file-row__del {
  color: var(--danger);
}

.file-empty {
  padding: 18px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

/* ------------------------------------------------------------------ board */

/*
 * The board is its own fixed-scale canvas: 1 unit = --cell-size (set by the JS
 * layout pass), the empty units drawn as a lattice so it is obvious what can be
 * aimed at. It scrolls sideways when the panel is too narrow for all columns.
 *
 * The lattice is a pseudo-element rather than the element's own background: it
 * has to cover exactly the tracks. Zoomed out, the tracks sit in the middle of
 * the panel and the sides are left empty — a background would tile all the way
 * across and there would be no telling where the board ends.
 */
.admin-board {
  /* fallbacks only: the JS sets --gap and --cell-size from the site and the zoom */
  --gap: 6px;
  --rows: 6;
  --board-w: 100%;
  --board-x: 0px;
  --board-y: 0px;
  --board-h: calc(var(--rows) * var(--cell-size, 48px) + (var(--rows) - 1) * var(--gap, 6px));
  position: relative;
  /* the height below is the tracks' height, so the padding must not be part of
     it: with border-box the last rows — the empty ones you draw into — would
     fall outside the element and be unreachable with the pointer */
  box-sizing: content-box;
  /* `safe` keeps a board that is wider than the panel scrollable: plain center
     would push the left columns out of reach */
  justify-content: safe center;
  min-height: var(--board-h);
  padding: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: color-mix(in srgb, var(--ink-900) 55%, transparent);
}

/* scrolls with the tracks, unlike a background the element would keep in place */
.admin-board::before {
  --pitch: calc(var(--cell-size, 48px) + var(--gap));
  content: '';
  position: absolute;
  /* the padding box is the origin, the tracks start one padding further in */
  top: var(--board-y);
  left: var(--board-x);
  width: var(--board-w);
  height: var(--board-h);
  pointer-events: none;
  /*
   * The tiled layers draw a line at the *start* of each cell, which covers every
   * column's left edge and every row's top edge — the board's own top and left
   * come free — but the last column's right edge and the last row's bottom edge
   * land in the middle of a tile and stay open. The two full-size layers close
   * the rectangle; at 100% they sit under the panel's border and go unnoticed.
   */
  background-image: linear-gradient(to right, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to left, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to top, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px);
  background-size: var(--pitch) var(--pitch), var(--pitch) var(--pitch), 100% 100%, 100% 100%;
}

.admin-board.is-dragging {
  user-select: none;
  cursor: grabbing;
}

.board__slot {
  /*
   * 触屏上格子本体不接手势（只轻点开编辑），翻页交还给浏览器 —— 整屏都是格子，
   * 全设成 none 就等于整屏都翻不动。唯一能抓住拖的是右下角那个方块，它自带 none。
   * `user-select` / `-webkit-touch-callout` 一起关掉：慢一点的拖动在 iOS 上会变成选字，
   * 长按带链接的格子还会弹「在新标签页打开」。
   */
  touch-action: auto;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}

.board__slot.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 12px;
}

.board__slot.is-selected .slot__bar {
  opacity: 1;
}

/* the rectangle the current gesture would produce */
.board__ghost {
  z-index: 4;
  pointer-events: none;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.board__ghost.is-bad {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, transparent);
}

/* bottom-right grip: drag it to resize the cell */
.slot__handle {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 6;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink-900);
  border-radius: 4px;
  background: var(--accent);
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.16s;
  /* 触屏上它是唯一的抓取点，得拦在浏览器前面：否则按住方块也会被当成翻页 */
  touch-action: none;
}

.board__slot:hover .slot__handle,
.board__slot.is-selected .slot__handle {
  opacity: 1;
}

/*
 * 触屏上没法在空白处画格子：棋盘的空白处是 `touch-action: auto`，浏览器会把这一手
 * 当成滚动、随即 pointercancel，手势本来就活不下来。所以新建只能走「＋ 添加格子」，
 * 棋盘上方这一栏（提示 + 右下角方块的开关）也只给触屏看。
 */
.board-touch-bar {
  display: none;
}

@media (hover: none) {
  .board-touch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0 0 10px;
  }

  /* 这一栏比鼠标端紧凑：分段按钮是给指头点的，别缩太小 */
  .board-touch-bar .segmented {
    padding: 3px;
  }

  .board-touch-bar .segmented__btn {
    padding: 7px 14px;
  }

  /* 工具条那行是鼠标的操作说明，「在空白处拖动画出格子」「单击」在触屏上都不成立 */
  .admin-toolbar__help {
    display: none;
  }
}

/* 触屏上没有 hover，右下角手柄得常显、并且够手指点（鼠标下仍然藏到悬停才出现） */
@media (hover: none) {
  .slot__handle {
    width: 22px;
    height: 22px;
    right: -6px;
    bottom: -6px;
    opacity: 1;
  }

  /*
   * 视觉上还是 22px，命中范围撑到 34px（和放大角标同款尺寸）：
   * 方块现在是触屏上唯一的抓取点，指头按不准就等于挪不动格子。
   */
  .slot__handle::before {
    content: '';
    position: absolute;
    inset: -6px;
  }
}

.board-status {
  margin-top: 10px;
}

/* 用户行里的「可分享」开关 */
.user-share {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.user-share input {
  accent-color: var(--accent);
}

/* 盒子仓库：按标签分组 */
.repo-group {
  margin: 12px 2px 2px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.repo-thumb {
  overflow: hidden;
  background: var(--ink-500);
}

.repo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------- users & invites */

.files__title {
  margin: 18px 0 2px;
  font-size: 14px;
}

.files__title:first-child {
  margin-top: 0;
}

.input--slim {
  width: auto;
  padding: 7px 9px;
  font-size: 12.5px;
}

/* the one field in a row that should take the leftover width */
.input--grow {
  flex: 1 1 12rem;
  width: auto;
}

.file-row__code {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------- edit grid */

.admin-grid {
  --cell: clamp(84px, 13vw, 128px);
  --gap: 12px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* a caption and its compact select, so three controls fit on one line */
.tool {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.tool__label {
  white-space: nowrap;
}

.admin-toolbar .input--slim {
  padding: 5px 7px;
}

/* the board instructions take whatever room is left at the end of the row */
.admin-toolbar__help {
  margin-left: auto;
}

.slot {
  position: relative;
}

.slot > .cell {
  position: absolute;
  inset: 0;
}

/* an embedded page in the list is a thumbnail, not something to click or scroll:
   without this the iframe swallows the mouse and the slot cannot be dragged */
.slot .cell__frame {
  pointer-events: none;
}

/* 放大角标是主页的交互（点开全屏）；棋盘上的格子点开的是抽屉，别显示它 */
.slot .cell__expand {
  display: none;
}

.slot.is-dragging {
  opacity: 0.35;
}

.slot__bar {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ink-900) 82%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.16s;
  /*
   * The buttons are a fixed 22px. Zoomed out, a cell is smaller than that, and
   * the bar used to spill out of it — invisible (opacity 0) but still hit-tested,
   * so it quietly swallowed presses in the empty rows below. Clipping to the
   * cell keeps it working at any size, and changes nothing at 100%.
   */
  max-height: calc(100% - 10px);
  overflow: hidden;
}

.slot:hover .slot__bar,
.slot:focus-within .slot__bar {
  opacity: 1;
}

.slot__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink-600);
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.slot__btn:hover {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 60%, white);
}

.slot__btn--grab {
  cursor: grab;
  color: var(--text-dim);
}

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

/* ------------------------------------------------------------------ drawer */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(390px, 100%);
  height: 100%;
  border-left: 1px solid var(--line);
  background: var(--ink-800);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.55);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer__preview {
  display: grid;
  place-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-900);
}

.drawer__preview .grid {
  --cell: 62px;
  --gap: 10px;
  /* a definite width, otherwise auto-fill collapses to a single column */
  width: 100%;
  /* …but never wider than that width: a grid item's automatic minimum size lets
     its tracks push the element past the drawer, and then the layout pass reads
     a blown-out clientWidth back and everything after that is nonsense */
  min-width: 0;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--ink-700);
}

/*
 * 容器里子盒子的编辑面板：和主面板同宽，从右侧滑进来整块盖住它。
 * z-index 必须高于主抽屉（40）、低于取色面板（50）。
 */
.drawer--nested {
  z-index: 45;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.55), -1px 0 0 var(--line);
}

/* 容器编辑区里的子盒子列表 */
.container-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.container-row {
  gap: 6px;
  padding: 5px 6px;
}

.container-row__open {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.container-row__open:hover .file-row__name {
  color: var(--accent);
}

.container-row .file-row__meta {
  font-size: 11px;
  white-space: nowrap;
}

.container-row .file-row__del {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.container-row .file-row__del:hover {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}

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

/* 容器模式自己的那组设置（轮播 / 瀑布二选一显示） */
.container-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.fieldset > legend {
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 全屏留白的档位：一个「屏幕」缩略图，深色边就是留白 */
.margin-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.margin-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-700);
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.margin-option:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.margin-option[aria-pressed='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--ink-700));
  color: var(--text);
}

.margin-option__screen {
  position: relative;
  width: 52px;
  height: 34px;
  border: 1px solid color-mix(in srgb, var(--line) 60%, var(--text-dim));
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink-900) 80%, transparent);
}

/* 里面的那块 = 页面；留白按真实比例（52×34 的百分之几） */
.margin-option__page {
  position: absolute;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 45%, var(--text-dim));
}

.color-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: center;
}

/*
 * 色板按钮（取代 <input type="color">）：点开自绘的取色面板。
 * 底色垫一层棋盘格，带透明度的颜色一眼看得出来。
 */
.swatch {
  width: 48px;
  height: 100%;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background-color: #2a2438;
  background-image:
    linear-gradient(var(--sw, transparent), var(--sw, transparent)),
    linear-gradient(45deg, #4a4458 25%, transparent 25%, transparent 75%, #4a4458 75%),
    linear-gradient(45deg, #4a4458 25%, transparent 25%, transparent 75%, #4a4458 75%);
  background-position: 0 0, 0 0, 6px 6px;
  background-size: auto, 12px 12px, 12px 12px;
  transition: border-color 0.16s;
}

.swatch:hover,
.swatch:focus-visible {
  border-color: var(--accent);
}

/* 这一项是「透明」：整块换成红斜杠图标（和面板里那个透明色按钮一模一样） */
.swatch--none {
  background: linear-gradient(
      to top right,
      transparent calc(50% - 1px),
      #e5484d calc(50% - 1px),
      #e5484d calc(50% + 1px),
      transparent calc(50% + 1px)
    )
    #fff;
}

/* ---------------------------------------------------------- 取色面板 */

.color-pop {
  position: fixed;
  z-index: 50;
  width: 244px;
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--ink-700);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
}

.color-pop__sv {
  position: relative;
  height: 140px;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--hue, 0) 100% 50%));
}

.color-pop__knob {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.color-pop__sliders {
  display: grid;
  gap: 8px;
}

.color-pop__range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  outline: none;
}

.color-pop__range--hue {
  background: linear-gradient(
    to right,
    #f00 0%,
    #ff0 17%,
    #0f0 33%,
    #0ff 50%,
    #00f 67%,
    #f0f 83%,
    #f00 100%
  );
}

/* 不透明度：从透明到当前颜色，底下垫棋盘格 */
.color-pop__range--alpha {
  background-image:
    linear-gradient(to right, transparent, var(--solid, #7e46b9)),
    repeating-conic-gradient(#4a4458 0% 25%, #2a2438 0% 50%);
  background-size: auto, 10px 10px;
}

.color-pop__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2a2438;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.color-pop__range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2a2438;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

/* HEX / RGB / HSV：三个小标签页 */
.color-pop__modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--ink-900);
}

.color-pop__mode {
  padding: 5px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.color-pop__mode:hover {
  color: var(--text);
}

.color-pop__mode.is-on {
  background: color-mix(in srgb, var(--accent) 30%, var(--ink-700));
  color: var(--text);
}

/* 数值输入：HEX 一个整行，RGB/HSV 各四个小格 */
.color-pop__fields {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
}

.color-pop__field {
  display: grid;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-dim);
}

.color-pop__field input {
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--ink-900);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.color-pop__field input:focus {
  border-color: var(--accent);
  outline: none;
}

/* 数字框上下那对小箭头太挤了，收掉 */
.color-pop__field input[type='number'] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.color-pop__field input[type='number']::-webkit-outer-spin-button,
.color-pop__field input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.color-pop__foot {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 吸管 + 透明：两个图标按钮，一起靠右 */
.color-pop__icon {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s;
}

.color-pop__icon:hover,
.color-pop__icon:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.color-pop__icon[hidden] {
  display: none;
}

.color-pop__preview {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background-color: #2a2438;
  background-image:
    linear-gradient(var(--sw, transparent), var(--sw, transparent)),
    linear-gradient(45deg, #4a4458 25%, transparent 25%, transparent 75%, #4a4458 75%),
    linear-gradient(45deg, #4a4458 25%, transparent 25%, transparent 75%, #4a4458 75%);
  background-position: 0 0, 0 0, 4px 4px;
  background-size: auto, 8px 8px, 8px 8px;
}

.color-pop__value {
  flex: 1;
  font-size: 12px;
  color: var(--text-dim);
}

/*
 * 透明色按钮：业界通用的「无颜色」图标 —— 白底 + 一道红斜杠（Photoshop / Figma 那个）。
 */
.color-none {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(
      to top right,
      transparent calc(50% - 1px),
      #e5484d calc(50% - 1px),
      #e5484d calc(50% + 1px),
      transparent calc(50% + 1px)
    ),
    #fff;
  cursor: pointer;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.color-none:hover {
  border-color: color-mix(in srgb, var(--line) 40%, var(--text));
}

/* 当前就是透明：点亮描边 + 光晕 */
.color-none[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.thumb-current {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thumb-current img {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  object-fit: cover;
  background: var(--ink-900);
}

.upload-picker {
  display: flex;
  gap: 8px;
  align-items: center;
}

.upload-picker input[type='file'] {
  display: none;
}

.size-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}

.size-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-700);
  color: var(--text-dim);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.size-option:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.size-option[aria-pressed='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--ink-700));
  color: var(--text);
}

/* one dot per grid unit, on a board big enough for the largest cell (8 × 4) */
.size-option__shape {
  display: grid;
  grid-template-columns: repeat(8, 3px);
  grid-auto-rows: 3px;
  gap: 1px;
  height: 15px;
  align-content: center;
}

.size-option__shape span {
  background: currentColor;
  border-radius: 1px;
  opacity: 0.85;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(4, 3, 8, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}

.scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------- 身份 / 分享 */

/* 顶栏最左边：现在是以谁的身份在编辑 */
.identity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.identity::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/*
 * 选盒子模式下，编辑相关的操作说明先收起来 —— 这会儿点格子是「挑它去分享」，
 * 不是画格子 / 挪位置 / 改尺寸 / 打开编辑，留着那行只添乱。
 */
body.is-sharing .admin-toolbar__help,
body.is-sharing .board-touch-hint {
  display: none;
}

/* 选盒子模式：棋盘上每颗盒子都可以点，盖一层透明接收层，网页封面里的 iframe 也点得到 */
body.is-sharing .admin-board .slot {
  cursor: pointer;
  outline: 1px dashed color-mix(in srgb, var(--accent) 65%, transparent);
  outline-offset: 2px;
}

body.is-sharing .admin-board .slot:hover {
  outline-style: solid;
}

body.is-sharing .admin-board .slot::after {
  content: '';
  position: absolute;
  inset: 0;
  /* 压在按钮条（5）和右下角手柄（6）上面 */
  z-index: 7;
  border-radius: inherit;
}

/* 我分享的盒子 */
.my-share-row .file-row__meta {
  min-width: 0;
}

/* ------------------------------------------------------------ 分享窗口 */

.share-dialog {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 3, 8, 0.62);
  backdrop-filter: blur(4px);
}

.share-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--ink-700);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
}

.share-card h2 {
  margin: 0;
  font-size: 17px;
}

.share-hint {
  margin: -6px 0 0;
  color: var(--text-dim);
  font-size: 12.5px;
}

.share-field {
  display: grid;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.share-field em {
  margin-left: 4px;
  color: var(--accent);
  font-style: normal;
}

.share-field i {
  margin-left: 4px;
  font-style: normal;
  opacity: 0.7;
}

.share-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-900);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
}

.share-input:focus {
  border-color: var(--accent);
  outline: none;
}

.share-error {
  margin: 0;
  color: #ffb4b6;
  font-size: 12.5px;
}

.share-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

