:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-d: #4338ca;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; padding-bottom: 40px;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--ink); color: #fff;
}
.brand { font-size: 20px; letter-spacing: .3px; }
.repo { color: #c7d2fe; text-decoration: none; font-size: 14px; font-weight: 600; }
.repo:hover { color: #fff; }

/* Layout */
.layout {
  max-width: 1040px; margin: 28px auto 0; padding: 0 20px;
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px;
}
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.controls h1 { font-size: 22px; letter-spacing: -.4px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; }
.field > span { color: var(--muted); font-weight: 600; }
.field em { color: var(--accent); font-style: normal; }
.field input[type=text], .field select {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px;
  background: #fff; color: var(--ink);
}
.field input[type=text]:focus, .field select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.field input[type=color] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.field input[type=range] { accent-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding-bottom: 12px; }
.field.check span { color: var(--ink); font-weight: 500; }

/* Preview */
.preview { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stage {
  width: 100%; min-height: 300px; display: grid; place-items: center;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(45deg, transparent 75%, #eef2f7 75%) -10px 0/20px 20px,
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%) -10px 0/20px 20px;
  border-radius: 12px; padding: 16px;
}
.stage svg { width: 260px; height: 260px; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }

/* History */
.history { max-width: 1040px; margin: 20px auto 0; }
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.history-head h2 { font-size: 18px; }
.count { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 13px; margin-left: 6px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.hist-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; position: relative; background: #fff; }
.hist-card svg { width: 96px; height: 96px; }
.hist-card .t { font-size: 13px; font-weight: 600; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-card .u { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-card .del {
  position: absolute; top: 6px; right: 8px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.hist-card .del:hover { color: #dc2626; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }

.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 32px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr 1fr; }
}
