
:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #111827;
  --muted: #687385;
  --line: #dce5f1;
  --line-strong: #c8d5e6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf2ff;
  --danger: #b42318;
  --shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  --shadow-strong: 0 18px 42px rgba(15, 23, 42, 0.09);
}
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101722;
  --panel: #172033;
  --panel-soft: #111827;
  --text: #e6edf7;
  --muted: #9aa8ba;
  --line: #29364a;
  --line-strong: #40516a;
  --accent: #60a5fa;
  --accent-dark: #bfdbfe;
  --accent-soft: #183456;
  --danger: #fca5a5;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
  --shadow-strong: 0 18px 42px rgba(0, 0, 0, 0.34);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.announcement-bar {
  padding: 18px 22px 0;
}
.announcement-inner {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--accent);
  border-radius: 16px;
  background: #eff6ff;
  color: #1e3a8a;
  box-shadow: var(--shadow);
}
body[data-theme="dark"] .announcement-inner {
  border-color: #2f5f95;
  border-left-color: var(--accent);
  background: #10243a;
  color: #dbeafe;
}
.announcement-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}
.announcement-inner strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}
.announcement-inner ol,
.announcement-inner ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 14px;
  line-height: 1.65;
}
.announcement-inner ul {
  margin-top: 4px;
  list-style: disc;
}
.app {
  min-height: calc(100vh - 100px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  padding: 22px;
}
.preview-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.preview-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
}
.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 4px 14px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.preview-header h1,
.panel-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.22;
}
.preview-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.preview-tools span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}
.pin-preview-button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.pin-preview-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}
body.preview-pinned .preview-panel {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  z-index: 20;
}
.canvas-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: var(--bg);
}
#previewCanvas {
  width: min(100%, calc(100vh - 210px));
  max-width: 920px;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.preview-note {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}
.control-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px;
}
.panel-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-header p:last-child {
  margin: 8px 0 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.panel-header p.is-error { color: var(--danger); font-weight: 700; }
.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.theme-row > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.theme-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}
.theme-toggle button {
  min-width: 58px;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}
.theme-toggle button.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow);
}
.selection-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  padding: 12px 12px;
  border: 1px solid #bfdbfe;
  background: var(--accent-soft);
}
.selection-summary span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.selection-summary p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.selection-summary button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  font-weight: 900;
}
.controls {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}
.fixed-notice {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 13px;
}
.control-section {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}
.control-section summary {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 14px 14px;
  cursor: pointer;
}
.control-section summary::-webkit-details-marker { display: none; }
.section-title {
  font-size: 18px;
  font-weight: 900;
}
.section-badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.section-arrow {
  color: var(--muted);
  font-weight: 900;
  transform: rotate(0);
  transition: transform 0.2s ease;
}
.control-section[open] .section-arrow { transform: rotate(180deg); }
.section-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}
.section-body {
  padding: 0 14px 14px;
}
.control-group {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-weight: 900;
}
.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}
select,
.mobile-choice-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
}
.mobile-choice-button {
  display: none;
  justify-content: space-between;
  align-items: center;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  font-weight: 800;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.actions button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}
.actions button:last-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}
.color-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: flex-end;
}
body.color-sheet-open .color-sheet { display: flex; }
.color-sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
}
.color-sheet-panel {
  position: relative;
  width: 100%;
  max-height: 54vh;
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  background: var(--panel);
  box-shadow: 0 -18px 48px rgba(0,0,0,.24);
  overflow: hidden;
}
.color-sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.color-sheet-layer-button {
  display: block;
  min-width: 0;
  border: 2px solid var(--accent);
  border-radius: 16px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
}
.color-sheet-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.color-sheet-layer-button strong {
  display: inline;
  font-size: 18px;
}
.color-sheet-layer-button b {
  float: right;
  color: var(--muted);
}
.color-sheet-close {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
}
.color-sheet-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: calc(54vh - 84px);
  overflow: auto;
  padding: 14px 16px 18px;
}
.color-sheet-options.is-layer-list {
  grid-template-columns: 1fr;
}
.color-option-button {
  min-height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 900;
  line-height: 1.25;
}
.color-option-button.is-active {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.layer-option-button {
  text-align: left;
  padding-left: 16px;
}
@media (max-width: 900px) {
  .announcement-bar {
    padding: 12px 12px 0;
  }
  .announcement-inner {
    grid-template-columns: 28px minmax(0, 1fr);
    border-radius: 14px;
    padding: 12px;
  }
  .announcement-inner ol,
  .announcement-inner ul {
    font-size: 13px;
  }
  .app {
    display: block;
    padding: 0;
  }
  .preview-panel,
  .control-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .preview-panel {
    padding: 16px 14px 14px;
  }
  body.preview-pinned .preview-panel {
    position: sticky;
    top: 0;
    z-index: 40;
  }
  body.preview-pinned .preview-note { display: none; }
  body.preview-pinned .canvas-shell { max-height: 52vh; }
  .preview-header h1 { font-size: 20px; }
  .pin-preview-button { display: inline-flex; align-items: center; }
  .canvas-shell {
    padding: 8px;
  }
  #previewCanvas {
    width: 100%;
    max-width: none;
  }
  .control-panel {
    padding: 18px 16px 96px;
  }
  select { display: none; }
  .mobile-choice-button { display: flex; }
  .actions {
    position: sticky;
    bottom: 0;
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    background: var(--panel);
  }
}
