:root {
  --red: #C6363C;
  --blue: #0C4076;
  --gold: #EDB92E;
  --navy: #0A2A4D;
  --bg: #f5f3ef;
  --bg-2: #ffffff;
  --bg-3: #ecebe6;
  --fg: #171a21;
  --fg-2: #4a5160;
  --fg-3: #8a90a0;
  --line: #dcdad3;
  --accent: var(--red);
  --accent-fg: #ffffff;
  --shadow: 0 1px 2px rgba(20,24,40,.06), 0 8px 24px rgba(20,24,40,.08);
  --radius: 14px;
  --font: "Montserrat", "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1420;
  --bg-2: #171d2b;
  --bg-3: #1f2636;
  --fg: #f1f2f5;
  --fg-2: #b6bcc9;
  --fg-3: #7b8395;
  --line: #2a3243;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -200px, color-mix(in srgb, var(--red) 12%, transparent), transparent 70%);
}
img { max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
:root[data-theme="dark"] a { color: #7fb0ea; }

.wrap { width: min(1100px, 100% - 32px); margin-inline: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--red); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

.ico { width: 18px; height: 18px; flex: none; }
.ico-lg { width: 44px; height: 44px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-weight: 900; letter-spacing: .02em; white-space: nowrap; }
.brand-mark { display: flex; flex-direction: column; width: 26px; height: 18px; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.brand-mark span { flex: 1; }
.brand-mark span:nth-child(1) { background: var(--red); }
.brand-mark span:nth-child(2) { background: var(--blue); }
.brand-mark span:nth-child(3) { background: #fff; }
.brand-text { font-size: 15px; }
.header-right { display: flex; gap: 8px; }
.tricolor-line { height: 3px; background: linear-gradient(90deg, var(--red) 0 33.3%, var(--blue) 33.3% 66.6%, #e9e9e9 66.6%); }
.t-short { display: none; }
@media (max-width: 560px) { .t-long { display: none; } .t-short { display: inline; } .brand-text { font-size: 13px; } }

/* segmented */
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-full { display: flex; width: 100%; }
.seg-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-2); font-weight: 700; font-size: 13px; line-height: 1.2; transition: background .15s, color .15s; white-space: nowrap; }
.seg-btn:hover { color: var(--fg); }
.seg-btn.is-active { background: var(--bg-2); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-btn.is-active[data-style], .seg-btn.is-active[data-motif-pos], .seg-btn.is-active[data-background], .seg-btn.is-active[data-export-size] { color: var(--red); }
.seg-icon { padding: 7px 9px; }

/* hero */
.sp-hero { text-align: center; padding-block: 44px 28px; }
.sp-hero-kicker { margin: 0 0 6px; color: var(--fg-2); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
.sp-hero h1 { margin: 0; font-size: clamp(34px, 7vw, 68px); font-weight: 900; line-height: 1.02; letter-spacing: -.01em; color: var(--fg); }
.sp-hero h1::after { content: ""; }
.sp-hero-rule { display: block; width: 96px; height: 6px; margin: 18px auto 22px; border-radius: 3px; background: linear-gradient(90deg, var(--red) 0 33.3%, var(--blue) 33.3% 66.6%, #fff 66.6%); box-shadow: 0 0 0 1px var(--line); }
.sp-hero-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.sp-hero-steps a { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); text-decoration: none; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); }
.hs-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 900; font-size: 13px; }
.sp-hero-steps li:nth-child(2) .hs-n { background: var(--blue); }
.sp-hero-steps li:nth-child(3) .hs-n { background: var(--navy); }
.sp-hero-note { margin: 18px 0 0; color: var(--fg-2); font-size: 13px; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 24px; align-items: start; padding-block: 12px 40px; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } }
.stage-col { position: sticky; top: 72px; }
@media (max-width: 860px) { .stage-col { position: static; } }
.stage-wrap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stage { position: relative; aspect-ratio: 1; width: 100%; max-width: 560px; margin-inline: auto; border-radius: 50%; overflow: hidden; outline: none; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--bg-3);
  background-image: linear-gradient(45deg, rgba(0,0,0,.06) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.06) 75%), linear-gradient(45deg, rgba(0,0,0,.06) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.06) 75%);
  background-size: 22px 22px; background-position: 0 0, 11px 11px; }
.stage:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 40%, transparent); }
.stage.is-empty { cursor: pointer; }
.stage:not(.is-empty) { cursor: grab; }
.stage.is-dragging { cursor: grabbing; }
.stage.is-over { box-shadow: 0 0 0 4px var(--red) inset; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--fg-2); padding: 32px; pointer-events: none; }
.stage-empty strong { color: var(--fg); font-size: 17px; }
.stage-empty span { font-size: 13px; }
.stage:not(.is-empty) .stage-empty { display: none; }
.stage-badge { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; pointer-events: none; animation: fadeout 5s forwards; }
@keyframes fadeout { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.stage-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.slider { display: flex; flex-direction: column; gap: 6px; }
.slider label { font-size: 12px; font-weight: 700; color: var(--fg-2); text-transform: uppercase; letter-spacing: .06em; }
.slider-inline { flex: 1; min-width: 160px; }
input[type=range] { width: 100%; accent-color: var(--red); }
input[type=range]:disabled { opacity: .45; }

/* buttons */
.sp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: 14px; line-height: 1.2; transition: transform .08s, background .15s, box-shadow .15s; text-decoration: none; }
.sp-btn:active { transform: translateY(1px); }
.sp-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.sp-btn-primary { background: var(--red); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--red) 35%, transparent); }
.sp-btn-primary:not(:disabled):hover { background: #b12d33; }
.sp-btn-ghost { background: var(--bg-3); color: var(--fg); border-color: var(--line); }
.sp-btn-ghost:not(:disabled):hover { background: var(--line); }
.sp-btn-outline { background: transparent; color: var(--fg); border-color: var(--line); }
.sp-btn-outline:hover { background: var(--bg-3); }
.sp-btn-block { width: 100%; }
.sp-btn-row { display: flex; flex-direction: column; gap: 8px; }
.cant-save { background: none; border: 0; color: var(--fg-3); font-size: 12px; text-decoration: underline; padding: 4px; }

/* cards */
.panel-col { display: flex; flex-direction: column; gap: 14px; }
.sp-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.sp-card-accent { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--red) 6%, var(--bg-2)), var(--bg-2)); }
.sp-card-title { margin: 0 0 14px; font-size: 13px; font-weight: 900; letter-spacing: .12em; color: var(--fg); }
.sp-card-title::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; background: linear-gradient(180deg, var(--red) 0 33%, var(--blue) 33% 66%, #fff 66%); box-shadow: 0 0 0 1px var(--line); vertical-align: -1px; }
.sp-card-details { padding: 0; }
.sp-card-details summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; cursor: pointer; font-size: 13px; font-weight: 900; letter-spacing: .12em; }
.sp-card-details summary::-webkit-details-marker { display: none; }
.sp-card-details summary::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; background: linear-gradient(180deg, var(--red) 0 33%, var(--blue) 33% 66%, #fff 66%); box-shadow: 0 0 0 1px var(--line); }
.sp-card-details summary > span { flex: 1; }
.chev { transition: transform .2s; color: var(--fg-3); }
.sp-card-details[open] .chev { transform: rotate(180deg); }
.details-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field + .field { margin-top: 12px; }
.lbl { font-size: 12px; font-weight: 700; color: var(--fg-2); text-transform: uppercase; letter-spacing: .06em; }
.lbl-row { display: flex; justify-content: space-between; align-items: center; }
.custom-color { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-3); cursor: pointer; }
.custom-color input { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.sp-input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font-weight: 700; letter-spacing: .03em; }
.sp-input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--fg-2); font-weight: 700; font-size: 12px; letter-spacing: .02em; transition: all .15s; }
.chip:hover { border-color: var(--fg-3); color: var(--fg); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .chip.is-active { background: var(--red); border-color: var(--red); }

.motif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.motif-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--fg-2); font-size: 11px; font-weight: 700; line-height: 1.15; text-align: center; transition: all .15s; }
.motif-btn:hover { border-color: var(--fg-3); }
.motif-btn.is-active { border-color: var(--red); color: var(--fg); background: color-mix(in srgb, var(--red) 8%, var(--bg-2)); }
.motif-btn img, .motif-btn .motif-none { width: 40px; height: 40px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--line); object-fit: contain; padding: 4px; }
.motif-btn .motif-none { display: grid; place-items: center; color: var(--fg-3); font-size: 20px; }
.motif-only { display: none; }
.has-motif .motif-only { display: flex; }
.motif-only.field { margin-top: 12px; }
.ring-only { display: none; }
.style-ring .ring-only, .style-tricolor .ring-only { display: flex; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); padding: 0; box-shadow: inset 0 0 0 2px var(--bg-2); transition: transform .1s; }
.swatch:hover { transform: scale(1.08); }
.swatch.is-active { border-color: var(--fg); }

/* covers */
.covers-section, .share-section { padding-block: 24px 40px; }
.covers-section h2, .share-section h2 { margin: 0 0 8px; font-size: 20px; font-weight: 900; letter-spacing: .06em; }
.section-note { margin: 0 0 18px; color: var(--fg-2); font-size: 14px; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cover-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.cover-card canvas { width: 100%; height: auto; border-radius: 8px; display: block; background: var(--bg-3); }
.cover-card .cover-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.cover-card .cover-meta small { color: var(--fg-3); font-weight: 500; }

/* share */
.share-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.share-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; border: 0; }
.share-btn svg { width: 18px; height: 18px; fill: currentColor; }
.link-row { display: flex; gap: 8px; }
.link-row .sp-input { flex: 1; font-weight: 500; letter-spacing: 0; }
@media (max-width: 480px) { .link-row { flex-direction: column; } }

/* footer */
.site-footer { border-top: 1px solid var(--line); padding-block: 28px 40px; background: var(--bg-2); }
.footer-inner { text-align: center; }
.footer-motto { margin: 0 0 6px; font-weight: 900; letter-spacing: .04em; }
.footer-small { margin: 0; color: var(--fg-3); font-size: 12px; }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-card { position: relative; width: min(440px, 100%); background: var(--bg-2); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow: auto; }
.modal-card h3 { margin: 0; font-size: 16px; font-weight: 900; }
.modal-card p { margin: 0; color: var(--fg-2); font-size: 13px; }
.modal-card img { width: 100%; max-width: 280px; margin-inline: auto; border-radius: 50%; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 95; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
