:root {
  --ink: #1f2d26;
  --green: #0d7a5f;
  --green-deep: #0a5c48;
  --coral: #f0705a;
  --gold: #d9a441;
  --paper: #fbf8f1;
  --panel: #ffffff;
  --line: #e4ded1;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(31, 45, 38, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* topbar */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 52px; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -.01em; }
.pro-badge {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  background: var(--gold); color: #3a2c08; padding: 2px 7px; border-radius: 20px;
}
.board-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.board-controls select {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 180px;
}
.board-controls button { padding: 6px 9px; border-radius: 8px; }
.board-controls button:hover { background: #f0ece2; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ghost { padding: 7px 12px; border-radius: 8px; font-size: 13.5px; color: var(--ink); }
.ghost:hover { background: #f0ece2; }
.cta {
  background: var(--coral); color: #fff; font-weight: 600; font-size: 13.5px;
  padding: 8px 16px; border-radius: 8px;
}
.cta:hover { filter: brightness(1.06); }

/* toolbar */
.toolbar {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.toolbar button {
  width: 38px; height: 38px; border-radius: 9px; font-size: 16px;
  display: grid; place-items: center;
}
.toolbar button:hover { background: #f0ece2; }
.toolbar button.active { background: var(--green); color: #fff; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* style panel */
.stylepanel {
  position: fixed; left: 14px; top: 120px; z-index: 20; width: 168px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; font-size: 12.5px;
}
.stylepanel label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; color: #5b6660; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
}
.swatch.none { background: repeating-linear-gradient(45deg, #fff 0 4px, #ddd 4px 8px); }
.swatch.sel { outline: 2px solid var(--green); outline-offset: 1px; }
input[type="range"] { width: 100%; accent-color: var(--green); }

/* canvas */
.canvas-wrap { position: fixed; inset: 52px 0 0 0; }
#board { width: 100%; height: 100%; display: block; touch-action: none; }
.text-editor {
  position: absolute; z-index: 15; min-width: 120px; min-height: 1.4em;
  background: transparent; border: 1px dashed var(--green); outline: none; resize: none;
  font-family: "Comic Neue", cursive; line-height: 1.3; padding: 0;
}

/* zoom */
.zoombar {
  position: fixed; right: 14px; bottom: 14px; z-index: 20;
  display: flex; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.zoombar button { padding: 8px 12px; font-size: 13px; }
.zoombar button:hover { background: #f0ece2; }

/* paywall */
dialog#paywall {
  border: none; border-radius: 16px; padding: 28px; width: min(420px, 92vw);
  box-shadow: 0 20px 60px rgba(31,45,38,.25); position: relative;
}
dialog#paywall::backdrop { background: rgba(31,45,38,.45); }
#paywall h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
#paywall .close { position: absolute; top: 12px; right: 14px; font-size: 20px; color: #8b948f; }
#paywallMsg { margin: 0 0 14px; color: #5b6660; font-size: 14px; }
.perks { margin: 0 0 18px; padding: 0 0 0 18px; font-size: 14px; line-height: 1.7; }
.plans { display: flex; gap: 10px; margin-bottom: 14px; }
.plan {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 8px;
}
.plan strong { font-size: 22px; }
.plan span { font-size: 12px; color: #5b6660; }
.plan:hover { border-color: var(--green); }
.plan.best { border-color: var(--green); background: #f0f7f4; position: relative; }
.plan.best::after {
  content: "BEST VALUE"; position: absolute; top: -9px;
  font-size: 9px; font-weight: 600; letter-spacing: .08em;
  background: var(--green); color: #fff; padding: 2px 8px; border-radius: 20px;
}
.linklike { display: block; margin: 0 auto 6px; font-size: 13px; color: var(--green); text-decoration: underline; }
.fineprint { margin: 0; text-align: center; font-size: 11.5px; color: #8b948f; }

@media (max-width: 720px) {
  .ghost { display: none; }
  .board-controls select { max-width: 110px; }
  .stylepanel { left: 8px; top: auto; bottom: 64px; width: 150px; padding: 9px; }
  .toolbar { top: auto; bottom: 10px; }
  .zoombar { right: 10px; bottom: 64px; }
  #cornerLogo, .logo-placeholder { max-width: 80px; opacity: .4; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* corner logo (bottom-left, 50% transparent) */
#cornerLogo {
  position: fixed; left: 14px; bottom: 14px; z-index: 18;
  max-width: 120px; max-height: 60px; opacity: .5; pointer-events: none;
}
.logo-placeholder {
  position: fixed; left: 14px; bottom: 14px; z-index: 18;
  width: 110px; height: 48px; opacity: .5; pointer-events: none;
  border: 2px dashed #8b948f; border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; color: #8b948f; font-family: Inter, sans-serif;
}

/* font picker */
#fontPick { font: inherit; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* brand name in hand font */
.brand-name { font-family: "Patrick Hand", cursive; font-size: 19px; letter-spacing: .01em; }

/* help dialog */
dialog#helpDlg {
  border: none; border-radius: 16px; padding: 26px; width: min(460px, 92vw);
  box-shadow: 0 20px 60px rgba(31,45,38,.25); position: relative;
}
dialog#helpDlg::backdrop { background: rgba(31,45,38,.45); }
#helpDlg h2 { margin: 0 0 12px; font-size: 19px; letter-spacing: -.01em; }
#helpDlg .close { position: absolute; top: 12px; right: 14px; font-size: 20px; color: #8b948f; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 5px 8px 5px 0; }
kbd {
  font-family: Inter, sans-serif; font-size: 11px;
  background: #f0ece2; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px;
}
