:root {
  --red: #C8102E;
  --red-dark: #9A0C22;
  --ink: #1A1A1A;
  --ink-soft: #3A3A3A;
  --line: #E5E5E5;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --muted: #6B6B6B;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,.08);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--ink));
  box-shadow: 0 4px 12px rgba(200,16,46,.35);
}
.top h1 { margin: 0; font-size: 1.1rem; letter-spacing: .02em; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 20px; padding: 20px 24px 32px; max-width: 1280px; width: 100%; margin: 0 auto;
}
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.form-panel h2 {
  margin: 18px 0 10px; font-size: .85rem; color: var(--muted);
  letter-spacing: .06em; font-weight: 600;
}
.form-panel h2:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: .82rem; color: var(--ink-soft); font-weight: 500; }
.field-hint { color: var(--muted); font-size: .74rem; margin-top: -2px; }
.field input[type="text"], .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font: inherit; color: var(--ink); background: #FAFAFA;
}
.field input[type="text"]:focus, .field textarea:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200,16,46,.12); background: #fff;
}
.field textarea { resize: vertical; min-height: 100px; line-height: 1.45; }
.field input[type="color"] {
  height: 42px; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px; background: #fff; cursor: pointer;
}
.field input[type="file"] { font-size: .82rem; }
.field.check { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 14px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--red); }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row.tight { align-items: center; margin-bottom: 8px; }
.half { flex: 1; }
.size-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.size-tab {
  border: 1px solid var(--line); background: #FAFAFA; border-radius: 10px;
  padding: 10px 6px; cursor: pointer; font: inherit; color: var(--ink); line-height: 1.25;
}
.size-tab small { color: var(--muted); font-size: .72rem; }
.size-tab.active {
  border-color: var(--red); background: #FFF5F6; color: var(--red-dark);
  box-shadow: inset 0 0 0 1px var(--red);
}
.size-tab.active small { color: var(--red); }
.templates { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-hint { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }
.tpl {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font: inherit; cursor: pointer; color: var(--ink);
}
.tpl:hover { border-color: var(--red); color: var(--red); }
.tpl.active { border-color: var(--red); background: #FFF5F6; color: var(--red-dark); font-weight: 600; }
.btn {
  border: none; border-radius: 999px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: .82rem; white-space: nowrap; margin-bottom: 12px; }
.preview-panel { display: flex; flex-direction: column; min-height: 520px; }
.preview-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px;
}
.preview-head h2 { margin: 0; font-size: 1rem; }
.dim { color: var(--muted); font-size: .82rem; }
.canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #f0f0f0;
  border-radius: 10px; border: 1px solid var(--line); padding: 16px;
  overflow: auto; min-height: 420px;
}
#posterCanvas {
  max-width: 100%; max-height: min(70vh, 720px);
  width: auto; height: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); border-radius: 4px; background: #fff;
}
.hint { margin: 10px 0 0; color: var(--muted); font-size: .78rem; }
.foot { text-align: center; padding: 12px 16px 20px; color: var(--muted); font-size: .75rem; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .top { padding: 12px 14px; }
  .top h1 { font-size: 1rem; }
  .canvas-wrap { min-height: 360px; }
}
