@font-face {
  font-family: "Horizon";
  src: url("/static/fonts/Horizon.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #2a43cf;
  --primary-dark: #1f33ad;
  --primary-container: #e1e4fb;
  --on-primary: #ffffff;
  --yellow: #fbbc04;
  --green: #1e8e3e;
  --red: #e8313f;
  --red-dark: #c01f2c;
  --brand-blue: #2a43cf;
  --brand-red: #e8313f;
  --brand: linear-gradient(125deg, #2a43cf 0%, #7b35a8 50%, #e8313f 100%);
  --brand-soft: linear-gradient(125deg, #eef0fe 0%, #fdeef0 100%);
  --focus-ring: 0 0 0 3px rgba(42, 67, 207, .14);

  --surface: #ffffff;
  --surface-1: #f7f8fa;
  --surface-2: #f4f5f8;
  --on-surface: #1a1c22;
  --on-surface-variant: #6b7280;
  --outline: #dfe1e7;
  --outline-soft: #edeef2;
  --line: #e7e9ef;

  --elev-1: 0 1px 2px rgba(18, 22, 40, .04);
  --elev-2: 0 6px 18px rgba(18, 22, 40, .07);
  --elev-3: 0 18px 44px rgba(18, 22, 40, .16);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-full: 999px;

  --font: "Google Sans Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--on-surface);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}
h3 { margin: 0; font-weight: 500; }

.material-symbols-rounded {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
}

.top-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 520px) 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.top-bar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--brand);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-badge {
  width: 42px; height: 42px;
  object-fit: contain;
  display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name {
  font-family: "Horizon", "Google Sans Text", sans-serif;
  font-size: 23px; font-weight: 700; letter-spacing: 0.5px;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { font-size: 12px; color: var(--on-surface-variant); }

.progress-wrap { width: 100%; }
.progress-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--on-surface-variant); margin-bottom: 6px;
}
.progress-pct { font-weight: 500; color: var(--on-surface); }
.linear-progress {
  height: 6px; background: var(--surface-2);
  border-radius: var(--r-full); overflow: hidden;
}
.linear-bar {
  height: 100%; width: 0%;
  background: var(--brand);
  border-radius: var(--r-full);
  transition: width .6s cubic-bezier(.2,0,0,1);
}
.bar-actions { display: flex; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: #fef7e0; color: #b06000;
  padding: 6px 12px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 500;
}
.pill .material-symbols-rounded { font-size: 16px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}
.canvas-panel, .sidebar {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.legal-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}
.legal-foot a { color: var(--on-surface-variant); text-decoration: none; }
.legal-foot a:hover { color: var(--primary); text-decoration: underline; }

.canvas-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 12px;
  border-bottom: 1px solid var(--outline-soft);
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--on-surface-variant);
  padding: 7px 14px; border-radius: var(--r-full);
  position: relative; overflow: hidden;
  transition: background .15s, color .15s;
}
.seg-btn .material-symbols-rounded { font-size: 18px; }
.seg-btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--elev-1); }
.tool-group { display: flex; align-items: center; gap: 4px; }
.tool-divider { width: 1px; height: 22px; background: var(--outline); margin: 0 4px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: transparent; color: var(--on-surface-variant);
  cursor: pointer; display: grid; place-items: center;
  position: relative; overflow: hidden;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--on-surface); }
.icon-btn.is-active { background: var(--primary-container); color: var(--primary-dark); }

.canvas-wrap {
  position: relative; flex: 1; min-height: 360px;
  background-color: #fbfbfc;
  background-image: radial-gradient(circle, #e4e6ec 1px, transparent 1.4px);
  background-size: 22px 22px;
  overflow: hidden; touch-action: none;
}
#map { width: 100%; height: 100%; display: block; cursor: crosshair; }
#map.mode-pan { cursor: grab; }
#map.mode-pan.dragging { cursor: grabbing; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #202124; color: #fff;
  padding: 8px 11px; border-radius: var(--r-sm);
  font-size: 12.5px; box-shadow: var(--elev-2);
  max-width: 240px; transform: translate(-50%, -125%);
}
.tooltip strong { font-weight: 500; }
.tooltip .tt-msg { color: #c8d3e0; display: block; margin-top: 2px; }
.tooltip .tt-link { color: #8ab4f8; display: block; margin-top: 2px; word-break: break-all; }

.canvas-loading {
  position: absolute; inset: 0; display: flex; gap: 10px;
  align-items: center; justify-content: center;
  color: var(--on-surface-variant); font-size: 13px; background: var(--surface);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--outline); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.palette-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--outline-soft);
}
.palette { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
  transition: transform .1s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: var(--on-surface); box-shadow: var(--elev-1); transform: scale(1.12); }
.custom-color {
  position: relative; width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; cursor: pointer;
  border: 1px dashed var(--outline); color: var(--on-surface-variant);
  overflow: hidden;
}
.custom-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.brush-size { display: flex; align-items: center; gap: 6px; color: var(--on-surface-variant); }
.brush-size .material-symbols-rounded { font-size: 18px; }
.brush-size input[type=range] { width: 92px; }
.brush-size-val { font-size: 12.5px; font-weight: 500; min-width: 26px; text-align: right; }
.hint { font-size: 11.5px; color: var(--on-surface-variant); margin-left: auto; }

.tabs { display: flex; padding: 6px 8px 0; border-bottom: 1px solid var(--outline-soft); }
.tab {
  flex: 1; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--on-surface-variant);
  padding: 12px 8px; border-bottom: 2.5px solid transparent;
  position: relative; overflow: hidden;
}
.tab:hover { color: var(--on-surface); background: var(--surface-1); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.tab-panel { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sel-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand-soft); color: var(--primary-dark);
  border: 1px solid #e1e4fb;
  border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 16px;
}
.sel-info { display: flex; flex-direction: column; }
.sel-count { font-size: 24px; font-weight: 700; line-height: 1; }
.sel-label { font-size: 12px; }

#buy-form { display: flex; flex-direction: column; gap: 14px; }
.cgv-check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--on-surface-variant); line-height: 1.45; cursor: pointer; }
.cgv-check input { margin: 2px 0 0; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.cgv-check a { color: var(--primary); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--on-surface); }
.opt { color: var(--on-surface-variant); font-weight: 400; }
.field input {
  font-family: inherit; font-size: 14px;
  padding: 11px 13px; border: 1px solid var(--outline);
  border-radius: var(--r-sm); background: var(--surface); color: var(--on-surface);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.btn-filled {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: var(--on-primary);
  border: none; border-radius: var(--r-full);
  font-family: inherit; font-size: 14.5px; font-weight: 600;
  padding: 13px 20px; cursor: pointer;
  transition: filter .12s, transform .04s;
}
.btn-filled:hover:not(:disabled) { filter: brightness(.96); }
.btn-filled:active:not(:disabled) { transform: translateY(1px); }
.btn-filled:disabled { background: var(--surface-2); color: #9aa0a6; cursor: default; }
.btn-filled .material-symbols-rounded { font-size: 19px; }

.text-btn {
  border: none; background: none; color: var(--primary); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--r-full); position: relative; overflow: hidden;
}
.text-btn:hover { background: rgba(42,67,207,.08); }

.buy-status { display: flex; flex-direction: column; gap: 6px; }
.bs-bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bs-fill { height: 100%; width: 0%; background: var(--brand); border-radius: 999px; transition: width .3s linear; }
.bs-text { font-size: 12px; color: var(--on-surface-variant); text-align: center; }

.secure {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin: 0; font-size: 11.5px; color: var(--on-surface-variant);
}
.secure .material-symbols-rounded { font-size: 14px; }
.form-error {
  margin: 0; font-size: 12.5px; color: var(--red);
  background: #fce8e6; border-radius: var(--r-sm); padding: 10px 12px;
}

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--on-surface-variant); margin: 4px 0 10px; }
.section-title:not(:first-child) { margin-top: 20px; }
.contributors { list-style: none; margin: 0; padding: 0; }
.c-row { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; padding: 9px 6px; border-radius: var(--r-sm); }
.c-row:hover { background: var(--surface-1); }
.c-rank { font-weight: 700; color: #9aa0a6; text-align: center; font-size: 12.5px; }
.c-row.top1 .c-rank { color: var(--yellow); }
.c-row.top2 .c-rank { color: #9aa0a6; }
.c-row.top3 .c-rank { color: #cd7f32; }
.c-main { min-width: 0; }
.c-name { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-bar { height: 4px; background: var(--surface-2); border-radius: var(--r-full); margin-top: 5px; overflow: hidden; }
.c-bar > span { display: block; height: 100%; background: var(--brand); border-radius: var(--r-full); }
.c-px { font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.c-px small { color: #9aa0a6; font-weight: 400; }

.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.a-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.a-dot { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--surface-2); display: grid; place-items: center; color: var(--on-surface-variant); flex-shrink: 0; }
.a-body { min-width: 0; line-height: 1.35; }
.a-name { font-weight: 500; }
.a-link { display: flex; gap: 10px; align-items: center; flex: 1; text-decoration: none; color: inherit; }
.a-meta { color: #9aa0a6; font-size: 11.5px; }
.empty { color: #9aa0a6; font-size: 12.5px; }

#img-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
#img-layer img { position: absolute; image-rendering: auto; }
#img-ghost {
  position: absolute; box-sizing: border-box;
  border: 2px solid var(--primary); cursor: move; touch-action: none; z-index: 6;
  background: rgba(42,67,207,.06);
}
#img-ghost.invalid { border-color: var(--red); background: rgba(217,48,37,.08); }
#img-ghost img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.ghost-handle {
  position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px;
  background: var(--primary); border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; box-shadow: var(--elev-1);
}
#img-ghost.invalid .ghost-handle { background: var(--red); }

.img-source { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.upload-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--outline); border-radius: var(--r-sm); padding: 14px;
  cursor: pointer; color: var(--primary); font-weight: 500; font-size: 13.5px;
}
.upload-btn:hover { background: var(--surface-1); }
.or-sep { display: flex; align-items: center; gap: 8px; color: #9aa0a6; font-size: 12px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--outline-soft); }
.img-url-row { display: flex; gap: 8px; }
.img-url-row input {
  flex: 1; font-family: inherit; font-size: 13.5px; padding: 10px 12px;
  border: 1px solid var(--outline); border-radius: var(--r-sm);
}
.img-url-row input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
#img-size { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.img-dim-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-container); color: var(--primary-dark);
  border-radius: var(--r-md); padding: 12px 14px;
}
.img-dim { font-weight: 500; }
.img-dim-px strong { font-size: 18px; }
.range-label { font-size: 12.5px; color: var(--on-surface); }
input[type=range] { width: 100%; accent-color: var(--primary); }
.img-valid { font-size: 12.5px; font-weight: 500; min-height: 16px; }
.img-valid.ok { color: var(--green); }
.img-valid.ko { color: var(--red); }

.pill-today { background: #fdecee; color: var(--red-dark); }
.custom-color.is-active {
  border-style: solid; border-color: var(--primary);
  color: var(--primary); background: var(--primary-container);
}
.recent { display: flex; gap: 4px; align-items: center; }
.recent .swatch { width: 22px; height: 22px; }
.recent:empty { display: none; }

.modal {
  position: fixed; inset: 0; z-index: 60; padding: 16px;
  background: rgba(32, 33, 36, .5);
  display: flex; align-items: center; justify-content: center;
  animation: fade .2s ease;
}
.modal-card {
  position: relative; width: 100%; max-width: 380px; text-align: center;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--elev-3); padding: 28px 24px;
}
.modal-close {
  position: absolute; top: 8px; right: 12px; border: none; background: none;
  font-size: 26px; line-height: 1; color: var(--on-surface-variant); cursor: pointer;
}
.share-emoji { font-size: 42px; }
.share-title { font-size: 20px; margin: 8px 0 4px; }
.share-sub { color: var(--on-surface-variant); margin: 0 0 18px; font-size: 13.5px; }
.share-buttons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--r-full);
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--outline); background: var(--surface); color: var(--on-surface);
  text-decoration: none;
}
.share-btn:hover { filter: brightness(.97); }
.share-btn.x { background: #000; color: #fff; border-color: #000; }
.share-btn.wa { background: #25d366; color: #fff; border-color: #25d366; }

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #202124; color: #fff;
  padding: 13px 20px; border-radius: var(--r-sm);
  font-size: 13.5px; box-shadow: var(--elev-3); z-index: 50;
  opacity: 0; transition: opacity .25s, transform .25s; max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #0b6b32; }
.toast.error { background: #a50e0e; }

@media (max-width: 940px) {
  body { overflow: auto; }
  .top-bar { grid-template-columns: 1fr; gap: 10px; }
  .layout { grid-template-columns: 1fr; }
  .canvas-wrap { min-height: 300px; height: 56vh; }
  .hint { display: none; }
}
