/* ─────────────────────────────────────────────
   白板 · 离线无限画布
   暗色新拟物 / 黑白灰
   ───────────────────────────────────────────── */

:root {
  --bg:        #1c1c1c;
  --surface:   #272727;
  --surface-hi: #313131;
  --surface-lo: #232323;
  --light:     rgba(255,255,255,.115);
  --dark:      #080808;
  --accent:    #f2f2f2;
  --accent-2:  #8c8c8c;
  --txt:       #ececec;
  --txt-dim:   #a6a6a6;
  --danger:    #f2f2f2;

  --grad: linear-gradient(145deg, var(--surface-hi), var(--surface-lo));

  --sh-out:    7px 7px 18px var(--dark), -6px -6px 16px var(--light);
  --sh-out-sm: 3px 3px 8px var(--dark), -2px -2px 7px var(--light);
  --sh-in:     inset 3px 3px 8px var(--dark), inset -2px -2px 7px var(--light);

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
}

/* ── 画布 ─────────────────────────────────── */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(255,255,255,.15) 1.3px, transparent 1.3px);
  background-size: 28px 28px;
  cursor: default;
  contain: strict;
}

.stage.panning { cursor: grabbing; }
.stage.space   { cursor: grab; }

/* 尺寸必须足够大，否则绝对定位文字节点会因可用宽度为 0 而逐字换行 */
.world {
  position: absolute;
  top: 0; left: 0;
  width: 120000px; height: 120000px;
  transform-origin: 0 0;
  will-change: transform;
  --inv: 1;
}

/* ── 节点 ─────────────────────────────────── */

.node {
  position: absolute;
  top: 0; left: 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

.node.image {
  border-radius: calc(9px * var(--inv));
  box-shadow: 0 calc(12px * var(--inv)) calc(28px * var(--inv)) rgba(0,0,0,.4);
  background: rgba(255,255,255,.03);
}

.node.image img {
  display: block;
  width: 100%; height: 100%;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
  border-radius: calc(9px * var(--inv));
}

.node.text {
  min-width: calc(1em * var(--inv));
  max-width: 34em;
  padding: calc(2px * var(--inv)) calc(4px * var(--inv));
  font-size: 20px;
  line-height: 1.45;
  color: var(--txt);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  border-radius: calc(4px * var(--inv));
  outline: none;
}

.node.selected {
  outline: calc(1.5px * var(--inv)) solid var(--accent);
  outline-offset: calc(3px * var(--inv));
}

.node.text.selected { outline-style: dashed; }

.node.editing {
  outline: calc(1.5px * var(--inv)) solid var(--accent) !important;
  outline-style: solid !important;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

/* 图片缩放把手 */
.handle {
  position: absolute;
  width: calc(13px * var(--inv));
  height: calc(13px * var(--inv));
  margin: calc(-6.5px * var(--inv)) 0 0 calc(-6.5px * var(--inv));
  border-radius: 50%;
  background: var(--accent);
  border: calc(1.5px * var(--inv)) solid var(--bg);
  box-shadow: 0 0 0 calc(1px * var(--inv)) rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity .12s;
  z-index: 2;
  pointer-events: none;
}
.handle.nw { top: 0; left: 0; cursor: nwse-resize; }
.handle.ne { top: 0; left: 100%; cursor: nesw-resize; }
.handle.sw { top: 100%; left: 0; cursor: nesw-resize; }
.handle.se { top: 100%; left: 100%; cursor: nwse-resize; }
.node.selected .handle,
.node.resizing .handle { opacity: 1; pointer-events: auto; }

.node.dragging { cursor: grabbing; }

/* ── 底部工具栏 ───────────────────────────── */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 22px;
  background: var(--grad);
  box-shadow: 8px 8px 20px var(--dark), -6px -6px 18px var(--light),
              inset 1px 1px 0 rgba(255,255,255,.05), inset -1px -1px 0 rgba(0,0,0,.25);
  z-index: 30;
  animation: rise .5s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--grad);
  color: var(--txt-dim);
  cursor: pointer;
  box-shadow: var(--sh-out-sm);
  transition: box-shadow .16s var(--ease), color .16s var(--ease), transform .1s var(--ease);
  font: inherit;
  flex: 0 0 auto;
}

.btn svg {
  width: 21px; height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover { color: var(--txt); }
.btn:active,
.btn.on {
  color: var(--accent);
  background: var(--surface-lo);
  box-shadow: var(--sh-in);
  transform: translateY(1px);
}
.btn[disabled] { opacity: .34; pointer-events: none; }

.btn.small { width: 34px; height: 34px; }
.btn.small svg { width: 18px; height: 18px; }

.btn.label {
  width: auto;
  min-width: 56px;
  padding: 0 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  color: var(--txt-dim);
}

.sep {
  width: 2px; height: 22px;
  margin: 0 4px;
  border-radius: 2px;
  background: var(--bg);
  box-shadow: inset 1px 0 1px var(--dark), inset -1px 0 1px var(--light);
  flex: 0 0 auto;
}

/* tooltip */
.btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 9px;
  border-radius: 7px;
  background: #131313;
  color: var(--txt);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s, transform .16s;
  box-shadow: 0 4px 12px rgba(0,0,0,.45);
}
.btn[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 更多菜单 ─────────────────────────────── */

.menu {
  position: fixed;
  right: 24px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  min-width: 176px;
  border-radius: 18px;
  background: var(--grad);
  box-shadow: 9px 9px 24px var(--dark), -7px -7px 20px var(--light);
  z-index: 40;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
  transform-origin: bottom right;
}

.menu.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(.94) translateY(6px);
}

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--txt);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .14s;
}
.menu button:hover { background: rgba(255,255,255,.07); }
.menu button svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--txt-dim);
}
/* 无彩色可用的前提下，用「更亮的白 + 一条分隔线」区分危险操作 */
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }

.menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: rgba(255,255,255,.1);
  flex: 0 0 auto;
}

/* ── 引导卡片 ─────────────────────────────── */

.hint {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8,8,8,.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  transition: opacity .3s var(--ease);
  animation: fade .3s var(--ease);
}
.hint.gone { opacity: 0; pointer-events: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.hint-card {
  width: min(342px, calc(100vw - 40px));
  padding: 30px 28px 26px;
  border-radius: 26px;
  background: linear-gradient(150deg, #2f2f2f, #212121);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 18px 18px 48px rgba(0,0,0,.6), -12px -12px 36px rgba(56,56,56,.45),
              inset 1px 1px 0 rgba(255,255,255,.07);
  animation: pop .45s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.hint-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--surface-lo);
  box-shadow: var(--sh-in);
  margin-bottom: 18px;
}
.hint-mark svg {
  width: 28px; height: 14px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hint-card h1 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .01em;
}
.hint-card .sub {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--txt-dim);
}

.hint-card ul {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.hint-card li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b4b4b4;
}
.hint-card li span {
  flex: 0 0 50px;
  color: var(--accent-2);
  font-size: 11.5px;
  letter-spacing: .04em;
}
.hint-card li i { font-style: normal; color: var(--txt-dim); font-size: 11px; }

kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  background: #191919;
  color: #d2d2d2;
  font-family: inherit;
  font-size: 11px;
  box-shadow: 0 1px 0 rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.04);
}

.btn-go {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: var(--grad);
  color: var(--accent);
  font: inherit;
  font-size: 13.5px;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: var(--sh-out-sm);
  transition: box-shadow .16s var(--ease), transform .1s;
}
.btn-go:active { box-shadow: var(--sh-in); transform: translateY(1px); }

/* ── 轻提示 ───────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border-radius: 12px;
  background: #131313;
  color: var(--txt);
  font-size: 12.5px;
  letter-spacing: .02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 60;
  max-width: 80vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 拖放高亮：虚线框 + 独立深色胶囊标签，避免文字压在浅色图片上读不出 */
.stage.dropzone::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px dashed rgba(255,255,255,.5);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
  pointer-events: none;
}

.stage.dropzone::before {
  content: "松手放下";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 9px 20px;
  border-radius: 999px;
  background: rgba(18,18,18,.88);
  border: 1px solid rgba(255,255,255,.16);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: .14em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 560px) {
  .dock { gap: 2px; padding: 6px; border-radius: 20px; }
  .btn { width: 40px; height: 40px; border-radius: 12px; }
  .btn svg { width: 19px; height: 19px; }
  .btn.label { min-width: 48px; font-size: 11px; }
  .btn.small { width: 30px; height: 30px; }
  .sep { margin: 0 2px; height: 18px; }
}

/* 窄屏：隐藏缩放组，双指缩放代替 */
@media (max-width: 500px) {
  #btn-zoom-out, #btn-zoom-label, #btn-zoom-in, #sep-zoom { display: none; }
  .btn[data-tip]::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
