/* 流沙画 · 样式（.g-sandart 前缀） */

.g-sandart {
  gap: 8px;
  padding-bottom: calc(12px + var(--safe-b));
}

/* ---------------- 顶部 ---------------- */

.g-sandart .sa-head { min-height: 40px; align-items: center; gap: 8px; }
.g-sandart .sa-head-left { display: flex; align-items: center; min-width: 0; }

.g-sandart .sa-gallery-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  touch-action: manipulation;
}

.g-sandart .sa-gallery-btn:active { background: var(--surface-2); }
.g-sandart .sa-head-right { gap: 6px; }

.g-sandart .sa-hbtn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  font-size: 12px;
}

/* ---------------- 沙画布 ---------------- */

.g-sandart .sa-stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(210, 172, 112, 0.4);
  background: #eddfc4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 20px 50px -28px rgba(0, 0, 0, 0.9);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.g-sandart .sa-canvas-host {
  position: absolute;
  inset: 0;
}

.g-sandart .sa-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
}

/* ---------------- 底部工具栏 ---------------- */

.g-sandart .sa-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.g-sandart .sa-palette {
  display: grid;
  grid-template-columns: repeat(6, 40px);
  justify-content: space-between;
  padding: 2px;
}

.g-sandart .sa-swatch {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--c);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.45), 0 3px 8px -5px rgba(0, 0, 0, 0.9);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  touch-action: manipulation;
}

.g-sandart .sa-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 4px 12px -5px rgba(0, 0, 0, 0.9);
  transform: scale(1.06);
}

.g-sandart .sa-swatch:active { transform: scale(0.92); }

.g-sandart .sa-tools-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.g-sandart .sa-tool {
  min-height: 44px;
  padding: 0 6px;
  border-radius: 12px;
  border: 1px solid rgba(210, 172, 112, 0.28);
  background: rgba(255, 180, 84, 0.07);
  color: #e6d6bb;
  font-size: 12.5px;
  font-weight: 600;
  touch-action: manipulation;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.g-sandart .sa-tool:active { transform: scale(0.97); }

.g-sandart .sa-tool.on {
  color: var(--accent);
  border-color: rgba(255, 180, 84, 0.6);
  background: rgba(255, 180, 84, 0.16);
  box-shadow: 0 0 16px rgba(255, 180, 84, 0.18);
}

/* ---------------- 我的沙画 ---------------- */

.g-sandart .sa-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 6, 11, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.g-sandart .sa-mask.show { display: flex; animation: fadeIn 0.18s ease both; }

.g-sandart .sa-sheet {
  width: 100%;
  max-width: 430px;
  padding: 16px 16px calc(16px + var(--safe-b));
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line-2);
  border-bottom: 0;
  background: linear-gradient(180deg, #1d1a16, #14110e);
  box-shadow: 0 -22px 60px -18px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: saSheetIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes saSheetIn {
  from { transform: translateY(26px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.g-sandart .sa-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #f3e7d2;
}

.g-sandart .sa-x {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #cbbba3;
  font-size: 19px;
  line-height: 1;
  touch-action: manipulation;
}

.g-sandart .sa-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.g-sandart .sa-gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  touch-action: manipulation;
}

.g-sandart .sa-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.g-sandart .sa-gallery-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 5px;
  font-size: 9.5px;
  line-height: 1.3;
  color: #fff;
  text-align: left;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.66));
}

.g-sandart .sa-gallery-empty {
  padding: 26px 8px;
  text-align: center;
  color: rgba(203, 187, 163, 0.65);
  font-size: 12px;
  line-height: 1.6;
}

.g-sandart .sa-gallery-empty.hidden { display: none; }
.g-sandart .sa-sheet-tip { margin-top: 12px; text-align: center; color: rgba(203, 187, 163, 0.55); }

.g-sandart .sa-img-wrap {
  max-height: 52vh;
  overflow: auto;
  border-radius: 12px;
  background: #0b0f18;
}

.g-sandart .sa-img {
  display: block;
  width: 100%;
  border-radius: 12px;
}

/* ---------------- 窄屏 ---------------- */

@media (max-width: 359px) {
  .g-sandart .sa-palette { grid-template-columns: repeat(6, 36px); }
  .g-sandart .sa-swatch { width: 36px; height: 36px; }
  .g-sandart .sa-tool { font-size: 11.5px; }
  .g-sandart .sa-gallery-btn { padding: 0 11px; font-size: 11.5px; }
}
