@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

.brand, .intro h1 { font-family: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif; }

:root {
  --green: #00603a;
  --green-dark: #00472b;
  --green-tint: #e4f1ea;
  --ink: #17231d;
  --muted: #5d6b63;
  --line: #d9ddd4;
  --paper: #f5f3ec;
  --card: #ffffff;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--green); color: #fff; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.brand b { font-weight: 800; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 26px; height: 26px; }
.brand-mark i { background: #fff; border-radius: 3px; }
.brand-mark i:last-child { background: transparent; border: 3px solid #fff; }
.account { display: flex; align-items: center; gap: 14px; font-size: 0.9rem; min-width: 0; }
.account span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account button { background: none; border: 1px solid rgba(255, 255, 255, 0.45); color: #fff; border-radius: 999px; padding: 5px 14px; font: inherit; cursor: pointer; white-space: nowrap; }
.account button:hover { background: rgba(255, 255, 255, 0.12); }

/* Intro */
.intro { padding: 36px 0 24px; max-width: 720px; }
.intro h1 { margin: 0 0 10px; font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
.intro p { margin: 0; color: var(--muted); font-size: 1.05rem; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.preview { position: sticky; top: 16px; }

h2 { font-size: 1.1rem; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.design-title { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; font-size: 0.85rem; font-weight: 700; flex: none; }

/* Type chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 0.95rem; cursor: pointer; }
.chip:hover { border-color: var(--green); }
.chip[aria-selected="true"] { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 12px 0 16px; }

/* Fields */
.fields { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.label { font-size: 0.88rem; font-weight: 600; }
.label em { font-weight: 400; font-style: normal; color: var(--muted); }
.field small { color: var(--muted); font-size: 0.82rem; }
.field small.err { color: #a12a1c; }

input[type="text"], input[type="tel"], input[type="url"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #c3c9bf; border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
}
textarea { resize: vertical; min-height: 70px; }
input[type="color"] { width: 100%; height: 42px; padding: 3px; border: 1px solid #c3c9bf; border-radius: 9px; background: #fff; cursor: pointer; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, .file-btn:focus-within {
  outline: 3px solid rgba(0, 96, 58, 0.35); outline-offset: 1px; border-color: var(--green);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--green); }

.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Buttons */
.btn { border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--green); color: #fff; flex: 1; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: #fff; border-color: #c3c9bf; color: var(--ink); }
.btn-ghost:hover { border-color: var(--green); color: var(--green); }
.btn-danger { background: #a12a1c; color: #fff; }
.btn-danger:hover { background: #7f1f14; }
.danger-zone { border-color: #e9c3bc; }
.danger-zone #deleteWarning { color: #7f1f14; font-weight: 600; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: #a12a1c; font: inherit; font-size: 0.9rem; cursor: pointer; padding: 0; text-decoration: underline; }

/* Preview */
.qr-box { aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 10px; overflow: hidden; background: #fafaf7; }
.qr-box.has-code { aspect-ratio: auto; border-style: solid; }
.qr-box svg { display: block; width: 100%; height: auto; }
.placeholder { text-align: center; color: var(--muted); padding: 24px; font-size: 0.95rem; }
.placeholder b { display: block; color: var(--ink); margin-bottom: 4px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 9px; padding: 9px 12px; font-size: 0.88rem; margin: 12px 0 0; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.size-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 0.88rem; font-weight: 600; }
.size-row select { flex: 1; padding: 8px 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; margin: 12px 0 0; }

/* Tips */
.tips { margin: 36px 0 12px; max-width: 760px; }
.tips ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: #33423a; }
.site-footer { padding-top: 20px; padding-bottom: 32px; color: var(--muted); font-size: 0.85rem; }
.site-footer a { color: inherit; }
.account a.header-cta { background: #fff; color: var(--green); font-weight: 700; padding: 6px 12px; border-radius: 99px; text-decoration: none; }
.guest-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; border-color: #b9dcc7; background: #eef7f1; }
.guest-banner p { margin: 0; flex: 1 1 320px; }
.guest-banner .btn { flex: none; }
a.btn { text-decoration: none; }
.site-footer a:hover { color: var(--green); }
.site-footer .rights { margin-top: 4px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .card { padding: 18px; }
}

@media print {
  body { background: #fff; }
  .site-header, .intro, .builder, .tips, .site-footer, .actions, .size-row, .notice, .preview .small { display: none !important; }
  .layout { display: block; }
  .card { border: 0; padding: 0; }
  .qr-box { border: 0; width: 12cm; margin: 2cm auto; }
}

/* ---------- accounts, saving, My codes ---------- */
.auth-pending body { visibility: hidden; }
.account a { color: #fff; font-weight: 600; text-underline-offset: 3px; white-space: nowrap; }

.save { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.save h2 { margin: 0; font-size: 1rem; }
.save .small { margin: 0; overflow-wrap: anywhere; }
.save .err { color: #a12a1c; }
.check input { width: 18px; height: 18px; accent-color: var(--green); flex: none; }
.check input:disabled + span { color: var(--muted); }

.plan { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; background: var(--green-tint); border-color: #c5ddd0; }
.plan h2 { margin: 0 0 2px; }
.plan p { margin: 0; }
.plan .btn-primary { flex: none; }

.code-list { display: grid; gap: 12px; }
.code-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.code-row h2 { margin: 0 0 2px; flex-wrap: wrap; overflow-wrap: anywhere; }
.code-row p { margin: 0; }
.short { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; color: var(--green); overflow-wrap: anywhere; margin-top: 4px !important; }
.tag { font-size: 0.72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #ecebe4; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tag-on { background: var(--green); color: #fff; }
.code-stats { display: grid; gap: 2px; font-size: 0.9rem; }
.big { font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.small-text { font-size: 0.8rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 36px; margin: 6px 0 4px; }
.bars i { flex: 1; max-width: 14px; background: var(--green); border-radius: 2px 2px 0 0; }
.bars i.zero { background: var(--line); }
.code-actions { display: flex; align-items: center; gap: 14px; }
.code-actions .btn { text-decoration: none; }
.empty { text-align: center; display: grid; gap: 6px; justify-items: center; padding: 40px 22px; }
.empty h2 { margin: 0; }
.empty .btn { text-decoration: none; flex: none; margin-top: 8px; }
#flash { margin: 0 0 16px; }

@media (max-width: 860px) {
  .code-row { grid-template-columns: 1fr; gap: 12px; }
  .account { gap: 10px; }
}
@media print { .save { display: none !important; } }

[hidden] { display: none !important; }

/* ---------- profile ---------- */
.avatar {
  width: var(--size, 32px); height: var(--size, 32px); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; object-fit: cover;
  background: #d9ecdf; color: var(--green-dark); font-weight: 700; font-size: calc(var(--size, 32px) * 0.45);
}
.me { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.me:hover { text-decoration: underline; }
.profile { max-width: 640px; }
.profile .card { margin-bottom: 16px; }
.profile .card h2 { margin-bottom: 4px; }
.photo-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.photo-actions { display: grid; gap: 8px; justify-items: start; }
.photo-actions .small { margin: 0; }
.file-btn.busy { opacity: 0.5; pointer-events: none; }
.status { margin: 0; font-size: 0.9rem; color: var(--green); min-height: 1.3em; }
.status.err { color: #a12a1c; }
input:disabled { background: #f1f0ea; color: var(--muted); }
@media (max-width: 860px) { .account a:not(.me) { font-size: 0.85rem; } }
