:root {
  --bg: #0e1116;
  --bg-soft: #151a22;
  --card: #1a2029;
  --line: #262e3a;
  --text: #e7ecf3;
  --muted: #8b97a8;
  --accent: #ff6a3d;
  --accent-2: #ff9166;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 80% -10%, #1d2431 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, .8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-dot {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 18px rgba(255, 106, 61, .55);
  flex: none;
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: .3px;
  white-space: nowrap;
}

.tag {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 8px; flex: none; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: .18s;
  font-family: inherit;
}

.btn:hover { border-color: #3a4453; }
.btn.ghost:hover { background: #1f2632; }

.btn.primary {
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 18px -6px rgba(255, 106, 61, .8);
}

.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled,
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.block { width: 100%; margin-top: 4px; }

/* ---------- 布局 ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

.panel {
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(21, 26, 34, .45);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-head h2 {
  font-size: 13px;
  margin: 0;
  letter-spacing: .5px;
}

.hint { color: var(--muted); font-size: 11px; }

/* ---------- 上传区 ---------- */
.drop {
  border: 1px dashed #38424f;
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: .18s;
  background: rgba(255, 255, 255, .015);
}

.drop.small { padding: 13px 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255, 106, 61, .07); }

.drop-inner strong { display: block; font-size: 13px; font-weight: 600; }
.drop-inner span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.drop.filled { border-style: solid; border-color: #2f6b4a; background: rgba(46, 160, 108, .08); }

/* ---------- 表单控件 ---------- */
.field { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2.sub { padding-left: 10px; border-left: 2px solid var(--line); margin-top: 4px; }

.field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field label em { color: var(--text); font-style: normal; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: #2b3441;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}

select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  cursor: pointer;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-row .btn { flex: 1; padding: 9px 4px; font-size: 12px; }
.btn.danger { color: #ff7b7b; }
.btn.danger:hover { background: rgba(255, 80, 80, .12); border-color: #6d3030; }

.tip.err { color: #ff8f8f; }
.hint.ok { color: #4ecb8d; }

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

.tip {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- 画布区 ---------- */
.stage {
  padding: 20px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.stage-inner { width: 100%; max-width: 1100px; }

.canvas-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: repeating-conic-gradient(#1b212a 0% 25%, #171c24 0% 50%) 50% / 22px 22px;
  border: 1px solid var(--line);
  min-height: 220px;
  touch-action: none;
}

#canvas { display: block; width: 100%; height: auto; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.empty.hide { display: none; }

.stage-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.kbd-tip { text-align: right; }

/* ---------- 结果弹层（移动端 / 微信内长按保存） ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 8, 12, .78);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
}

.modal[hidden] { display: none; }

.modal-box.narrow { max-width: 360px; }

.modal-box {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
}

#resultImg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #fff;
}

.modal-box .tip { margin: 10px 0 12px; }
.modal-box .btn.block { text-align: center; text-decoration: none; display: block; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; order: 2; }
  .stage { order: 1; padding: 14px; }
  .tag { display: none; }
  .kbd-tip { display: none; }
}
