/* ============================================================
   萌豆坊 MoriBean — 拼豆图纸生成器
   "Warm Craft Workshop" Aesthetic
   ============================================================ */

/* ----- Design Tokens ----- */
:root {
  /* Warm craft palette */
  --bg: #FCF7F0;
  --bg-dot: #E8D5BE;
  --panel: #FFFFFF;
  --panel-warm: #FFFBF6;
  --panel-hover: #FFF8EF;
  --border: #E8D5BE;
  --border-light: #F0E4D4;
  --border-strong: #D4C0A8;
  --text: #3A2618;
  --text-secondary: #6B5744;
  --text-muted: #A89078;
  --primary: #F2552E;
  --primary-dark: #D9431F;
  --primary-light: #FFF1EB;
  --primary-glow: rgba(242, 85, 46, 0.2);

  /* Accent bead colors */
  --accent-teal: #2CB7AA;
  --accent-yellow: #F5A623;
  --accent-pink: #F06292;
  --accent-purple: #9B6FDC;
  --accent-blue: #4FA8E0;
  --accent-green: #66BB6A;

  /* Spacing */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 40px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(58, 38, 24, 0.04);
  --shadow-sm: 0 2px 6px rgba(58, 38, 24, 0.06);
  --shadow-md: 0 4px 16px rgba(58, 38, 24, 0.08);
  --shadow-lg: 0 8px 32px rgba(58, 38, 24, 0.12);
  --shadow-xl: 0 16px 48px rgba(58, 38, 24, 0.16);
  --shadow-button: 0 2px 12px rgba(242, 85, 46, 0.3);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 120ms;
  --duration-normal: 220ms;
  --duration-slow: 350ms;
}

/* ----- Reset & Base ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-family:
    "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", cursive, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  /* Pegboard dot pattern — subtle, thematic */
  background-image:
    radial-gradient(circle, var(--bg-dot) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 0 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Selection */
::selection {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Ensure [hidden] always hides, regardless of other display styles */
[hidden] { display: none !important; }

/* ----- Header ----- */
.app-header {
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md) var(--space-lg);
  position: relative;
}
/* Decorative bead strip at top of header */
.app-header::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary) 0%, var(--primary) 14%,
    var(--accent-yellow) 14%, var(--accent-yellow) 28%,
    var(--accent-green) 28%, var(--accent-green) 42%,
    var(--accent-teal) 42%, var(--accent-teal) 57%,
    var(--accent-blue) 57%, var(--accent-blue) 71%,
    var(--accent-purple) 71%, var(--accent-purple) 85%,
    var(--accent-pink) 85%, var(--accent-pink) 100%
  );
  z-index: 1;
}

/* Header top row: title left, lang selector right */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.brand-logo {
  height: 32px;
  width: 32px;
  vertical-align: middle;
  filter: drop-shadow(0 2px 4px rgba(242, 85, 46, 0.25));
  transition: transform var(--duration-normal) var(--ease-spring);
}
.brand-logo:hover {
  transform: rotate(-10deg) scale(1.1);
}

.brand-en {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.04em;
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

.subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* Header actions group (lang + login) — top-right corner */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Language selector */
.lang-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}
.lang-select {
  padding: 7px 28px 7px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--panel-warm) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M5 7L1 2h8z' fill='%23A89078'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  -webkit-appearance: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  min-width: 130px;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}
.lang-select:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.lang-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ----- Layout ----- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: var(--space-lg);
  padding: var(--space-lg);
  overflow: hidden;
}
.layout > * {
  min-width: 0;
}

/* ----- Panel / Card ----- */
.panel,
.result {
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out);
  overflow: hidden;  /* 圆角裁切 */
  display: flex;
  flex-direction: column;
}

/* Inner scroll wrapper — scrollbar sits flush against border */
.panel-scroll,
.result-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: var(--space-lg);
  /* push scrollbar to the very right edge: no right padding for the scrollbar gutter */
  scrollbar-gutter: stable;
}

/* Give scrollbar a bit of breathing room from content */
.panel-scroll {
  padding-right: 8px;
}
.result-scroll {
  padding-right: 8px;
}

.panel:hover,
.result:hover {
  box-shadow: var(--shadow-md);
}
.panel:hover,
.result:hover {
  box-shadow: var(--shadow-md);
}

/* ----- Control Groups ----- */
.control-group {
  margin-bottom: var(--space-lg);
  background: var(--panel-warm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition:
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}
.control-group:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.control-group:last-child {
  margin-bottom: 0;
}
.control-group h2 {
  font-size: 15px;
  font-weight: 400;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  margin: 0 0 var(--space-sm);
  color: var(--text);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Numbered bead badge — replaces the tiny dot */
.control-group h2::before {
  content: attr(data-step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  box-shadow: 0 2px 6px rgba(242, 85, 46, 0.3);
}
/* Fallback for when data-step is not set */
.control-group h2:not([data-step])::before {
  content: "";
  width: 8px;
  height: 8px;
  min-width: 8px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: none;
  color: transparent;
}

/* ----- Drop Zone ----- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--panel-warm);
  transition:
    border-color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
  position: relative;
}
.drop-zone::after {
  content: "✦";
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 18px;
  color: var(--border-strong);
  transition: all var(--duration-normal) var(--ease-out);
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.drop-zone:hover::after,
.drop-zone.dragover::after {
  color: var(--primary);
  transform: rotate(180deg) scale(1.3);
}
.drop-zone p {
  margin: 4px 0;
  font-weight: 500;
}
.drop-zone .hint {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.thumb-wrap {
  margin-top: var(--space-sm);
  text-align: center;
}
.thumb-wrap img {
  max-width: 100%;
  max-height: 140px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

/* ----- Form Controls ----- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.field b {
  color: var(--primary);
  font-weight: 700;
}

/* Range slider — custom styled */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-button);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* Select */
.field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-warm) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23A89078'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}
.field select:hover {
  border-color: var(--border-strong);
}
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Checkbox / Radio */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-out);
}
.check:hover {
  background: var(--panel-warm);
}
.check input[type="checkbox"],
.check input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}
.check input[type="radio"] {
  border-radius: 50%;
}
.check input[type="checkbox"]:checked,
.check input[type="radio"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.check input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
}
.check input:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ----- Buttons ----- */
.btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.btn:hover:not(:disabled) {
  background: var(--panel-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-xs);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Primary button */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(242, 85, 46, 0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 16px rgba(242, 85, 46, 0.35);
  transform: translateY(-2px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 1px 4px rgba(242, 85, 46, 0.3);
}
/* Subtle shimmer on primary */
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.15) 45%,
    rgba(255,255,255,0.2) 50%,
    rgba(255,255,255,0.15) 55%,
    transparent 60%
  );
  transform: translateX(-100%);
  transition: transform 0.6s;
}
.btn-primary:hover:not(:disabled)::after {
  transform: translateX(100%);
}

/* Export buttons row */
.export-row {
  display: flex;
  gap: var(--space-xs);
}
.export-row .btn {
  font-size: 13px;
  padding: 8px 6px;
}

/* ----- Result Area ----- */
.result-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}
.result-toolbar h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.meta-info {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* Canvas wrapper */
.canvas-wrap {
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(45deg, #FAFAF8 25%, transparent 25%, transparent 75%, #FAFAF8 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, #FAFAF8 25%, #F5F5F2 25%, #F5F5F2 75%, #FAFAF8 75%) 8px 8px / 16px 16px;
  padding: var(--space-md);
  flex-shrink: 0;
  position: relative;
}
.canvas-wrap canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 2px;
}
.placeholder {
  color: var(--text-muted);
  text-align: center;
  padding: 60px 0;
  font-size: 14px;
}

/* ----- Legend & BOM ----- */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.legend-block,
.bom-block {
  background: var(--panel-warm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.bottom-grid h3 {
  font-size: 15px;
  font-weight: 400;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  margin: 0 0 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.bottom-grid h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  background: #fff;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.legend-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.legend-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.35), inset 0 -2px 2px rgba(0,0,0,0.08);
}

/* BOM Table */
.bom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.bom-table th,
.bom-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.bom-table th {
  background: var(--primary-light);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  border-bottom: 2px solid var(--primary);
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
}
.bom-table tbody tr {
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}
.bom-table tbody tr:nth-child(even) {
  background: var(--panel-warm);
}
.bom-table tbody tr:hover {
  background: var(--primary-light);
  transform: translateX(3px);
}
.bom-table tbody tr:last-child td {
  border-bottom: none;
}
.bom-table td.num {
  text-align: right;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  font-weight: 700;
  color: var(--primary);
  font-size: 14px;
}
.bom-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  vertical-align: middle;
  margin-right: 8px;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3), inset 0 -1px 2px rgba(0,0,0,0.06);
}

/* ----- Footer ----- */
.app-footer {
  flex-shrink: 0;
  padding: 14px var(--space-lg);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  border-top: 1px solid var(--border-light);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  position: relative;
}
/* Mini bead strip on footer top — mirrors header */
.app-footer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--accent-pink) 0%, var(--accent-pink) 14%,
    var(--accent-purple) 14%, var(--accent-purple) 28%,
    var(--accent-blue) 28%, var(--accent-blue) 42%,
    var(--accent-teal) 42%, var(--accent-teal) 57%,
    var(--accent-green) 57%, var(--accent-green) 71%,
    var(--accent-yellow) 71%, var(--accent-yellow) 85%,
    var(--primary) 85%, var(--primary) 100%
  );
}
.app-footer #statusMsg {
  color: var(--text-muted);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(30, 18, 8, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: modalFadeIn var(--duration-slow) var(--ease-out);
}
.modal[hidden] {
  display: none;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-box {
  background: var(--panel);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: min(960px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn var(--duration-slow) var(--ease-out);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  background: var(--panel-warm);
}
.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.modal-close {
  border: none;
  background: var(--border-light);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
}
.modal-close:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: rotate(90deg);
}

/* ----- Matting Modal ----- */
.matting-body {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--space-md);
  padding: var(--space-md);
  overflow: auto;
}
.matting-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, #eee 25%, #fff 25%, #fff 75%, #eee 75%) 10px 10px / 20px 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: auto;
  min-height: 300px;
}
#mattingCanvas {
  max-width: 100%;
  max-height: 70vh;
  cursor: crosshair;
  display: block;
  image-rendering: auto;
}
.matting-tools .tool-row {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}
.matting-tools .tool-row .btn {
  flex: 1;
}
.matting-tools .field {
  margin-bottom: 14px;
}

/* ----- Page Ad Container ----- */
.page-ad {
  max-width: 970px;
  margin: var(--space-sm) auto 0;
  padding: 0 var(--space-md);
  text-align: center;
  min-height: 0;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  body {
    height: auto;
    overflow: auto;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
    padding: var(--space-sm);
    flex: none;
    overflow: visible;
  }
  .panel,
  .result {
    overflow: visible;
    max-height: none;
  }
  .panel-scroll,
  .result-scroll {
    overflow: visible;
    max-height: none;
    padding-right: var(--space-md);
  }
  .bottom-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    padding: var(--space-md) var(--space-md);
  }
  .app-header h1 {
    font-size: 20px;
  }
  .lang-select {
    min-width: 110px;
    font-size: 12px;
    padding: 6px 24px 6px 10px;
  }
  .subtitle {
    font-size: 12px;
  }
  .panel,
  .result {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
  }
  .result {
    min-height: 0;
  }
  .canvas-wrap {
    max-height: 62vh;
  }
  .export-row {
    flex-wrap: wrap;
  }
  .export-row .btn {
    flex: 1 1 30%;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .matting-body {
    grid-template-columns: 1fr;
  }
  .matting-canvas-wrap {
    min-height: 200px;
  }
}

/* ===== Print / Export PDF ===== */
@media print {
  body {
    background: #fff;
    background-image: none;
  }
  .app-header,
  .app-footer,
  #controls,
  .result-toolbar .meta-info,
  .drop-zone,
  .export-row,
  #generateBtn,
  .modal,
  .page-ad {
    display: none !important;
  }
  .app-header::before {
    display: none;
  }
  .layout {
    display: block;
    padding: 0;
  }
  .result,
  .result-scroll {
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    overflow: visible;
  }
  .canvas-wrap {
    overflow: visible;
    border: none;
    max-height: none;
    padding: 0;
    background: #fff;
  }
  .bottom-grid {
    grid-template-columns: 1fr 1fr;
  }
  .legend-item,
  .bom-table th,
  .bom-table td {
    border-color: #999;
  }
  @page {
    margin: 12mm;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .header-top {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .app-header h1 {
    font-size: 18px;
  }
  .brand-logo {
    height: 24px;
    width: 24px;
  }
  .brand-en {
    font-size: 13px;
    padding: 1px 8px;
  }
  .lang-select {
    min-width: 100px;
    font-size: 12px;
    padding: 5px 22px 5px 8px;
  }
  .btn-login {
    padding: 5px 14px;
    font-size: 12px;
  }
  .layout {
    padding: var(--space-xs);
  }
  .panel,
  .result {
    padding: var(--space-sm);
    border-radius: var(--radius-md);
  }
  .modal-box {
    border-radius: var(--radius-lg);
  }
  .canvas-wrap {
    padding: var(--space-xs);
  }
}

/* ============================================================
   入场动画 Entrance Animation — "彩珠洒落"
   ============================================================ */

/* ----- 遮罩层 ----- */
.entrance-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #FCF7F0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: all;
  animation: overlayExit 1.6s var(--ease-out) forwards;
}
.entrance-overlay.entrance-skip {
  display: none;
}

@keyframes overlayExit {
  0%, 68% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* ----- 中央 Logo 弹入 ----- */
.entrance-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: centerFadeOut 1.6s var(--ease-out) forwards;
}

@keyframes centerFadeOut {
  0%, 50% { opacity: 1; }
  100% { opacity: 0; }
}

.entrance-logo {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 4px 16px rgba(242, 85, 46, 0.35));
  animation: beanPopIn 0.7s 0.05s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes beanPopIn {
  0% {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.25) rotate(8deg);
    opacity: 1;
  }
  85% {
    transform: scale(0.88) rotate(-4deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.entrance-brand {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: 32px;
  color: var(--primary);
  letter-spacing: 0.08em;
  animation: brandReveal 0.5s 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes brandReveal {
  0% {
    transform: translateY(12px) scale(0.6);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ----- 彩珠样式 ----- */
.bead {
  position: absolute;
  top: -30px;
  border-radius: 50%;
  --bead-color: #F2552E;
  /* 3D 珠子质感：径向渐变模拟高光 */
  background:
    radial-gradient(
      circle at 35% 28%,
      rgba(255, 255, 255, 0.7) 0%,
      rgba(255, 255, 255, 0.15) 25%,
      transparent 50%
    ),
    radial-gradient(
      circle at 50% 50%,
      var(--bead-color) 0%,
      color-mix(in srgb, var(--bead-color) 85%, #000) 100%
    );
  box-shadow:
    inset 0 -3px 4px rgba(0, 0, 0, 0.12),
    0 4px 10px rgba(58, 26, 8, 0.15);
  pointer-events: none;
  will-change: transform;
}

/* ----- 三种不同的掉落动画 ----- */

/* 动画名称、缓动函数、填充模式由 class 定义；
   动画时长和延迟由 JS 通过内联 style 设置。 */

/* A: 标准弹跳（多数珠子） */
.bead-dropA {
  animation-name: beadBounceA;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
  animation-fill-mode: both;
}

@keyframes beadBounceA {
  0% {
    transform: translateY(-20vh) rotate(0deg);
    opacity: 0;
  }
  6% {
    opacity: 1;
  }
  45% {
    transform: translateY(96vh) rotate(200deg);
    animation-timing-function: cubic-bezier(0.28, 1.5, 0.5, 1);
  }
  62% {
    transform: translateY(83vh) rotate(330deg);
    animation-timing-function: ease-in;
  }
  78% {
    transform: translateY(92vh) rotate(380deg);
    animation-timing-function: cubic-bezier(0.34, 1.4, 0.64, 1);
  }
  90% {
    transform: translateY(88vh) rotate(400deg);
    animation-timing-function: ease-in;
  }
  100% {
    transform: translateY(91vh) rotate(420deg);
    opacity: 1;
  }
}

/* B: 轻盈飘落（小珠子），带水平偏移 */
.bead-dropB {
  animation-name: beadBounceB;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

@keyframes beadBounceB {
  0% {
    transform: translateY(-15vh) translateX(0px) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 0.9;
  }
  40% {
    transform: translateY(70vh) translateX(15px) rotate(150deg);
  }
  65% {
    transform: translateY(50vh) translateX(-8px) rotate(270deg);
    animation-timing-function: cubic-bezier(0.28, 1.3, 0.5, 1);
  }
  82% {
    transform: translateY(88vh) translateX(4px) rotate(350deg);
    animation-timing-function: ease-in;
  }
  93% {
    transform: translateY(83vh) translateX(-2px) rotate(380deg);
    animation-timing-function: cubic-bezier(0.34, 1.2, 0.64, 1);
  }
  100% {
    transform: translateY(88vh) translateX(0px) rotate(400deg);
    opacity: 1;
  }
}

/* C: 沉重大弹跳（大珠子） */
.bead-dropC {
  animation-name: beadBounceC;
  animation-timing-function: ease-in;
  animation-fill-mode: both;
}

@keyframes beadBounceC {
  0% {
    transform: translateY(-25vh) rotate(0deg);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  35% {
    transform: translateY(90vh) rotate(160deg);
    animation-timing-function: cubic-bezier(0.28, 1.8, 0.5, 1);
  }
  55% {
    transform: translateY(70vh) rotate(320deg);
    animation-timing-function: ease-in;
  }
  72% {
    transform: translateY(89vh) rotate(430deg);
    animation-timing-function: cubic-bezier(0.34, 1.6, 0.64, 1);
  }
  86% {
    transform: translateY(80vh) rotate(480deg);
    animation-timing-function: ease-in;
  }
  100% {
    transform: translateY(87vh) rotate(520deg);
    opacity: 1;
  }
}

/* ----- 页面内容入场动画 ----- */

/* 仅在首次访问（未标记 entrance-done）时播放入场动画 */
@media not print {
  body:not(.entrance-done) .app-header {
    animation: contentSlideDown 0.65s 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  @keyframes contentSlideDown {
    from {
      transform: translateY(-30px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  body:not(.entrance-done) .page-ad {
    animation: contentFadeIn 0.5s 0.45s ease-out both;
  }

  @keyframes contentFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  body:not(.entrance-done) .panel {
    animation: contentSlideLeft 0.6s 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  @keyframes contentSlideLeft {
    from {
      transform: translateX(-40px);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  body:not(.entrance-done) .result {
    animation: contentSlideRight 0.6s 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  @keyframes contentSlideRight {
    from {
      transform: translateX(40px);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  body:not(.entrance-done) .app-footer {
    animation: contentFadeUp 0.5s 0.7s ease-out both;
  }

  @keyframes contentFadeUp {
    from {
      transform: translateY(15px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

/* ============================================================
   Auth Bar / Project Actions / Modals / Share / Gallery
   ============================================================ */

/* --- Login Button (top-right) --- */
.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition:
    background var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
  box-shadow: 0 2px 8px rgba(242, 85, 46, 0.22);
}
.btn-login::before {
  content: "👤";
  font-size: 12px;
}
.btn-login:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(242, 85, 46, 0.35);
  transform: translateY(-1px);
}
.btn-login:active {
  transform: scale(0.96);
}

/* --- User Menu (top-right, when logged in) --- */
.user-menu {
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  border: 2px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out);
}
.user-menu-btn:hover {
  background: #fff;
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(242, 85, 46, 0.25);
}

/* Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
  z-index: 50;
  animation: dropIn var(--duration-fast) var(--ease-out);
}
.user-dropdown[hidden] { display: none; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.user-dropdown .auth-status {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 6px;
  text-align: center;
  word-break: break-all;
}
.user-dropdown .btn {
  width: 100%;
  margin-bottom: 4px;
}
.user-dropdown .btn:last-child { margin-bottom: 0; }

/* --- Auth Bar (deprecated — kept for compatibility) --- */
.auth-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.auth-status {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Text Input --- */
.text-input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  box-sizing: border-box;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ============================================================
   Auth Modal — Warm Craft Login/Signup
   ============================================================ */

/* Card container */
.auth-card {
  max-width: 420px;
  width: 94vw;
  max-height: 94vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  animation: authCardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Close button — absolute positioned */
.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

/* Brand area */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-md);
}

.auth-logo {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 4px 12px rgba(242, 85, 46, 0.3));
  animation: authLogoBounce 0.6s 0.1s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes authLogoBounce {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.auth-brand-name {
  margin: 0;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: 18px;
  color: var(--text);
  letter-spacing: 0.06em;
}

/* Title & Subtitle */
.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: 0.04em;
}

.auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-lg);
  line-height: 1.5;
}

/* Error */
.auth-error {
  background: #FFF0EE;
  color: #D9431F;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  text-align: center;
  border: 1px solid #FDDDD8;
  animation: shakeIn 0.35s var(--ease-out);
}
.auth-error:empty { display: none; }

@keyframes shakeIn {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Form fields */
.auth-field {
  margin-bottom: var(--space-md);
  animation: fieldSlideUp 0.35s var(--ease-out) both;
}
.auth-field:nth-child(2) { animation-delay: 0.05s; }
.auth-field:nth-child(3) { animation-delay: 0.1s; }
.auth-field:nth-child(4) { animation-delay: 0.15s; }

@keyframes fieldSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

/* Input wrapper with icon */
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.auth-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  background: var(--panel-warm);
  color: var(--text);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
  outline: none;
  box-sizing: border-box;
}

.auth-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 13px;
}

.auth-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.auth-input:focus + .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon {
  opacity: 1;
}

/* Password strength indicator */
.pwd-strength {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwd-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.pwd-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  transition:
    width 0.3s var(--ease-out),
    background 0.3s var(--ease-out);
}

.pwd-strength-text {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 28px;
  text-align: right;
}

/* Strength levels */
.pwd-strength[data-level="weak"] .pwd-strength-bar span    { width: 25%; background: #F2552E; }
.pwd-strength[data-level="weak"] .pwd-strength-text        { color: #F2552E; }
.pwd-strength[data-level="fair"] .pwd-strength-bar span    { width: 50%; background: #F5A623; }
.pwd-strength[data-level="fair"] .pwd-strength-text        { color: #F5A623; }
.pwd-strength[data-level="good"] .pwd-strength-bar span    { width: 75%; background: #66BB6A; }
.pwd-strength[data-level="good"] .pwd-strength-text        { color: #66BB6A; }
.pwd-strength[data-level="strong"] .pwd-strength-bar span  { width: 100%; background: #2CB7AA; }
.pwd-strength[data-level="strong"] .pwd-strength-text      { color: #2CB7AA; }

/* Confirm password match hint */
.pwd-match-hint {
  display: block;
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}
.pwd-match-hint.match-ok  { color: #66BB6A; }
.pwd-match-hint.match-bad { color: #F2552E; }

/* Submit button */
.auth-submit-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-top: var(--space-xs);
  margin-bottom: var(--space-md);
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out);
  box-shadow: 0 4px 16px rgba(242, 85, 46, 0.3);
  position: relative;
  overflow: hidden;
}

.auth-submit-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(242, 85, 46, 0.4);
}

.auth-submit-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Shimmer on submit */
.auth-submit-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255,255,255,0.12) 45%,
    rgba(255,255,255,0.18) 50%,
    rgba(255,255,255,0.12) 55%,
    transparent 60%
  );
  transform: translateX(-100%);
  transition: transform 0.6s;
}
.auth-submit-btn:hover::after {
  transform: translateX(100%);
}

/* Switch link */
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.auth-switch a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
  transition: color var(--duration-fast) var(--ease-out);
}

.auth-switch a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* Footer note */
.auth-footer-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* --- Project List Modal --- */
/* (styles moved to Decorative Utilities section below) */

/* --- Gallery Link in Footer --- */
.gallery-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  margin-left: var(--space-md);
}

.gallery-link:hover { text-decoration: underline; }

/* ============================================================
   Share Page
   ============================================================ */
.share-app {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-lg);
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* Share Header */
.share-header {
  text-align: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--border-light);
}

.share-header h1 {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 28px;
  color: var(--text);
  margin: var(--space-sm) 0;
}

.share-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin: var(--space-xs) 0;
}

.share-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  margin: var(--space-xs) 0;
  padding: 6px 16px;
  background: var(--panel-warm);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}
.share-meta::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

.share-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
}
.share-back:hover {
  background: var(--primary);
  color: #fff;
}

/* Share Toolbar */
.share-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: var(--space-md) 0;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition:
    all var(--duration-fast) var(--ease-out);
}
.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.share-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Platform-specific share button tints */
.copy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.copy-btn .share-btn-icon {
  background: var(--primary);
  color: #fff;
}

.twitter-btn:hover {
  border-color: #1da1f2;
  color: #1da1f2;
  background: #e8f5fd;
}
.twitter-btn .share-btn-icon {
  background: #1da1f2;
  color: #fff;
}

.facebook-btn:hover {
  border-color: #1877f2;
  color: #1877f2;
  background: #e7f0fd;
}
.facebook-btn .share-btn-icon {
  background: #1877f2;
  color: #fff;
}

.line-btn:hover {
  border-color: #06c755;
  color: #06c755;
  background: #e6f9ef;
}
.line-btn .share-btn-icon {
  background: #06c755;
  color: #fff;
}

.share-native-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(242, 85, 46, 0.25);
}
.share-native-btn:hover {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
  box-shadow: 0 4px 16px rgba(242, 85, 46, 0.35);
}
.share-native-btn .share-btn-icon {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

/* QR Code section */
.share-qr-section {
  text-align: center;
  margin: var(--space-lg) 0;
}
.share-qr-card {
  display: inline-block;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-normal) var(--ease-out);
}
.share-qr-card:hover {
  box-shadow: var(--shadow-md);
}
.share-qr-code {
  display: block;
  border-radius: var(--radius-md);
  background: #fff;
}
.share-qr-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: var(--space-sm);
  padding: 4px 12px;
  background: var(--panel-warm);
  border-radius: var(--radius-full);
}
.share-qr-hint::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent-teal);
  border-radius: 50%;
  animation: qrPulse 2s ease-in-out infinite;
}
@keyframes qrPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.5); }
}

/* Share Canvas */
.share-canvas-wrap {
  text-align: center;
  margin: var(--space-lg) 0;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.share-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Share Legend & BOM */
.share-legend-bom {
  display: flex;
  gap: var(--space-lg);
  margin: var(--space-lg) 0;
  flex-wrap: wrap;
}
.share-legend-bom > * {
  flex: 1;
  min-width: 240px;
  background: var(--panel-warm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.share-legend-bom h3 {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 16px;
  margin: 0 0 var(--space-sm);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-legend-bom h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.share-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  margin-bottom: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  transition: background var(--duration-fast) var(--ease-out);
}
.share-legend-item:hover {
  background: #fff;
}

.share-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3), inset 0 -1px 2px rgba(0,0,0,0.06);
}

/* Share BOM table */
.share-bom table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 13px;
}
.share-bom th, .share-bom td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.share-bom th {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 12px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  border-bottom: 2px solid var(--primary);
}
.share-bom tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.5);
}
.share-bom tbody tr:hover {
  background: var(--primary-light);
}

/* Share Footer */
.share-footer {
  text-align: center;
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 2px solid var(--border-light);
  color: var(--text-muted);
  font-size: 13px;
}
.share-footer p {
  margin: 0 0 var(--space-md);
}
.share-footer a {
  color: var(--primary);
  text-decoration: none;
}
.share-footer .btn {
  display: inline-block;
  width: auto;
  min-width: 200px;
}

/* Share loading / error */
.share-loading,
.share-error {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}
.share-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: 16px;
}
.share-loading::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.share-error {
  background: var(--panel-warm);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--border);
  margin: var(--space-lg) auto;
  max-width: 480px;
}
.share-error-icon {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 24px;
  line-height: 48px;
  font-weight: 700;
}
.share-error h2 { font-size: 32px; margin: 0 0 var(--space-xs); }

/* ============================================================
   Gallery Page
   ============================================================ */
.gallery-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-lg);
  font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* Gallery Header */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--border-light);
}

.gallery-header h1 {
  font-family: 'ZCOOL KuaiLe', cursive;
  font-size: 28px;
  margin: 0;
  color: var(--text);
}

.gallery-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
}
.gallery-back:hover {
  background: var(--primary);
  color: #fff;
}

.gallery-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.gallery-sort {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.gallery-sort a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
}
.gallery-sort a.active {
  color: #fff;
  background: var(--primary);
  font-weight: 600;
}
.gallery-sort a:hover:not(.active) {
  color: var(--primary);
  background: var(--primary-light);
}

/* Gallery Search */
.gallery-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-sm);
}
.gallery-search-input {
  flex: 1;
  max-width: 400px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  outline: none;
  background: var(--panel-warm);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}
.gallery-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
  background: #fff;
}
.gallery-search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  transition:
    background var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out);
  box-shadow: 0 2px 8px rgba(242, 85, 46, 0.2);
}
.gallery-search-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(242, 85, 46, 0.35);
}
.gallery-search-clear {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast) var(--ease-out);
}
.gallery-search-clear:hover {
  color: var(--primary-dark);
  background: var(--primary-light);
}
.gallery-count {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: var(--space-md);
}

/* Gallery Grid & Cards */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-lg);
}

.gallery-card {
  display: block;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  background: var(--panel);
  cursor: pointer;
  transition:
    transform var(--duration-normal) var(--ease-spring),
    box-shadow var(--duration-normal) var(--ease-out);
}
.gallery-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.gallery-card-preview {
  height: 170px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.gallery-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}
.gallery-card:hover .gallery-card-preview img {
  transform: scale(1.05);
}

/* Bead-pattern placeholder for cards without thumbnails */
.gallery-card-placeholder-bead {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle, var(--bg-dot) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
}
.gallery-card-placeholder-bead .placeholder-grid-size {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}
.gallery-card-placeholder-bead .placeholder-bead-icon {
  font-size: 28px;
  opacity: 0.5;
  /* CSS bead: a round gradient circle */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.1), 0 2px 6px rgba(242,85,46,0.25);
}

.gallery-card-info {
  padding: var(--space-sm) var(--space-md);
}
.gallery-card-info h3 {
  font-size: 15px;
  margin: 0 0 4px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
}
.gallery-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* Gallery Pagination */
.gallery-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  padding: var(--space-md) 0;
}
.gallery-page-btn {
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  text-decoration: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  transition:
    all var(--duration-fast) var(--ease-out);
}
.gallery-page-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(242, 85, 46, 0.3);
  transform: translateY(-1px);
}
.gallery-page-btn.disabled {
  color: var(--text-muted);
  border-color: var(--border-light);
  pointer-events: none;
  opacity: 0.4;
}
.gallery-page-info {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 0 var(--space-sm);
}

/* Gallery empty state */
.gallery-empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  background: var(--panel-warm);
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  margin: var(--space-lg) 0;
}
.gallery-empty-icon {
  display: inline-block;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.5) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, var(--accent-teal) 0%, #1a9e93 100%);
  box-shadow: inset 0 -3px 4px rgba(0,0,0,0.1), 0 4px 16px rgba(44,183,170,0.3);
  margin-bottom: var(--space-md);
}
.gallery-empty h2 {
  font-size: 20px;
  color: var(--text);
  margin: 0 0 var(--space-xs);
}
.gallery-empty p {
  margin: 0 0 var(--space-md);
  color: var(--text-secondary);
}

/* Gallery loading skeleton */
.gallery-loading {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-lg);
}
.gallery-skeleton-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border-light);
}
.gallery-skeleton-img {
  height: 170px;
  background: linear-gradient(110deg, var(--border-light) 30%, var(--panel-warm) 50%, var(--border-light) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.gallery-skeleton-text {
  padding: var(--space-sm) var(--space-md);
}
.gallery-skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(110deg, var(--border-light) 30%, var(--panel-warm) 50%, var(--border-light) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}
.gallery-skeleton-line:last-child {
  width: 60%;
  margin-bottom: 0;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Gallery error */
.gallery-error {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  background: var(--panel-warm);
  border-radius: var(--radius-xl);
}

/* ============================================================
   Gallery Lightbox — 点击卡片直接看大图 + 色号 + 材料清单
   ============================================================ */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 56px 16px 40px;
  /* 滚动条样式 */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.gallery-lightbox::-webkit-scrollbar {
  width: 8px;
}
.gallery-lightbox::-webkit-scrollbar-track {
  background: transparent;
}
.gallery-lightbox::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 4px;
}
.gallery-lightbox::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.5);
}
.gallery-lightbox[hidden] {
  display: none;
}
.gallery-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  cursor: pointer;
}
.gallery-lightbox-close {
  position: fixed;
  top: 10px;
  right: 16px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.gallery-lightbox-close:hover {
  background: rgba(255,255,255,0.3);
}
.gallery-lightbox-body {
  position: relative;
  z-index: 5;
  width: min(100%, 960px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}
/* 图片 / canvas 容器 */
.gallery-lightbox-img-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}
.gallery-lightbox-img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  background: #fff;
}
.gallery-lightbox-canvas {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  background: #fff;
}
.gallery-lightbox-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border-radius: var(--radius-lg);
  color: #fff;
  font-size: 15px;
}
.gallery-lightbox-loading span {
  background: rgba(0,0,0,0.6);
  padding: 8px 20px;
  border-radius: var(--radius-full);
}
/* 标题 & 元信息 */
.gallery-lightbox-info {
  text-align: center;
  color: #fff;
  flex-shrink: 0;
}
.gallery-lightbox-title {
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: 22px;
  margin: 0 0 4px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.gallery-lightbox-meta {
  font-size: 14px;
  margin: 0;
  opacity: 0.85;
}
/* 图例 + BOM 详情区 */
.gallery-lightbox-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  width: 100%;
  padding: var(--space-md);
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.gallery-lightbox-details[hidden] {
  display: none;
}
.gallery-lightbox-legend h4,
.gallery-lightbox-bom h4 {
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
  font-size: 14px;
  margin: 0 0 var(--space-sm);
  color: rgba(255,255,255,0.85);
}
.gallery-lightbox-legend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gallery-lightbox-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.gallery-lightbox-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.gallery-lightbox-bom-table-wrap {
  max-height: 200px;
  overflow-y: auto;
}
.gallery-lightbox-bom table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.gallery-lightbox-bom th,
.gallery-lightbox-bom td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.gallery-lightbox-bom th {
  color: rgba(255,255,255,0.6);
  font-weight: 600;
}
.gallery-lightbox-bom td {
  color: rgba(255,255,255,0.85);
}

@media (max-width: 600px) {
  .gallery-lightbox-details {
    grid-template-columns: 1fr;
  }
  .gallery-lightbox {
    padding: 50px 8px 24px;
  }
}

@media (max-width: 600px) {
  .gallery-header { flex-direction: column; text-align: center; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery-search { flex-wrap: wrap; }
  .gallery-search-input { max-width: none; }
}

/* --- Small button variant --- */
.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
}

/* ============================================================
   Decorative Utilities & Empty States
   ============================================================ */

/* Section divider: a row of colored dots (like beads) */
.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: var(--space-lg) 0;
}
.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-light);
}
.section-divider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Empty state component */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
  background: var(--panel-warm);
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
}
.empty-state-icon {
  display: inline-block;
  margin-bottom: var(--space-md);
}
.empty-state h3 {
  font-size: 18px;
  color: var(--text);
  margin: 0 0 var(--space-xs);
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Microsoft YaHei", cursive;
}
.empty-state p {
  margin: 0 0 var(--space-md);
  font-size: 14px;
}

/* ============================================================
   Auth Modal — CSS Icon replacements (no emoji)
   ============================================================ */

/* Replace emoji icons with CSS-drawn equivalents */
.auth-input-icon {
  /* Hide the emoji text, show CSS icon instead */
  font-size: 0 !important;
}
.auth-input-icon::before {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

/* User icon */
.auth-input-icon[data-icon="user"]::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  position: relative;
  top: 2px;
  box-shadow: 0 5px 0 -2px var(--text-muted);
}
.auth-input-wrap:focus-within .auth-input-icon[data-icon="user"]::before {
  border-color: var(--primary);
  box-shadow: 0 5px 0 -2px var(--primary);
}

/* Email/envelope icon */
.auth-input-icon[data-icon="email"]::before {
  content: "";
  width: 14px;
  height: 10px;
  border: 2px solid var(--text-muted);
  border-radius: 2px;
  position: relative;
  top: 1px;
  background: linear-gradient(135deg, transparent 48%, var(--text-muted) 48%, var(--text-muted) 52%, transparent 52%);
}
.auth-input-wrap:focus-within .auth-input-icon[data-icon="email"]::before {
  border-color: var(--primary);
  background: linear-gradient(135deg, transparent 48%, var(--primary) 48%, var(--primary) 52%, transparent 52%);
}

/* Lock icon */
.auth-input-icon[data-icon="lock"]::before {
  content: "";
  width: 10px;
  height: 8px;
  border: 2px solid var(--text-muted);
  border-radius: 2px;
  position: relative;
  top: -1px;
  box-shadow: 0 -5px 0 -2px var(--text-muted), 2px -5px 0 -2px var(--text-muted), 4px -5px 0 -2px var(--text-muted);
}
.auth-input-wrap:focus-within .auth-input-icon[data-icon="lock"]::before {
  border-color: var(--primary);
  box-shadow: 0 -5px 0 -2px var(--primary), 2px -5px 0 -2px var(--primary), 4px -5px 0 -2px var(--primary);
}

/* Auth footer note — replace bean emoji with CSS beads */
.auth-footer-bead {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.5) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.1);
}

/* Login button — replace person emoji with CSS icon */
.btn-login::before {
  content: "" !important;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  position: relative;
  top: 1px;
  box-shadow: 0 5px 0 -2px #fff;
  opacity: 0.9;
}

/* Project list */
.project-list-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-sm);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  border-radius: var(--radius-md);
  background: var(--panel-warm);
  border: 1px solid var(--border-light);
  gap: var(--space-sm);
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}
.project-list-item:hover {
  background: #fff;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.project-list-item:last-child { margin-bottom: 0; }

.project-list-info strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}
.project-list-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.project-list-actions {
  display: flex;
  gap: var(--space-2xs);
  flex-shrink: 0;
}

.project-list-empty,
.project-list-error {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-xl);
}
.project-list-empty::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-sm);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.5) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--border-strong) 0%, var(--text-muted) 100%);
}

/* Result toolbar polish */
.result-toolbar h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-toolbar h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

/* Canvas wrap polish */
.canvas-wrap {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}
.canvas-wrap:has(canvas:not([hidden])) {
  box-shadow: var(--shadow-sm);
}

/* Placeholder polish */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 200px;
}
.placeholder::before {
  content: "";
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.5) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--border-strong) 0%, var(--text-muted) 100%);
  opacity: 0.5;
}

/* Responsive: control groups lose card styling on mobile */
@media (max-width: 860px) {
  .control-group {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: var(--space-md);
  }
  .control-group:hover {
    border-color: transparent;
    box-shadow: none;
  }
  .control-group h2::before {
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }
  .legend-block,
  .bom-block {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
  }
}
