:root {
  --ink: #15171a; --muted: #6b6f76; --line: #e7e5e0; --bg: #faf9f6; --panel: #ffffff;
  --accent: #4338ca; --accent-soft: #eef1ff; --ok: #1f9d55; --err: #c0392b; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Inter", system-ui, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; padding: 12px 20px; border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: #fff; font: 600 15px/1 inherit; font-family: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { opacity: .9; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.logo span { color: var(--accent); }

/* Landing */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing header { padding: 24px 32px; }
.landing main { flex: 1; display: grid; place-items: center; padding: 24px 16px 80px; }
.hero-box { width: min(720px, 100%); text-align: center; }
.hero-box h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 18px; }
.hero-box h1 em { font-style: normal; background: linear-gradient(90deg, #4338ca, #b04bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-box > p { font-size: 19px; color: var(--muted); margin: 0 auto 36px; max-width: 560px; line-height: 1.5; }
.url-form { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: 0 20px 50px -20px rgba(20,20,40,.18); }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; min-width: 0; border: 0; font: 17px inherit; font-family: inherit; padding: 14px 16px; outline: none; background: transparent; }
.url-opts { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 14px 4px; border-top: 1px solid var(--line); margin-top: 10px; font-size: 14px; color: var(--muted); text-align: left; }
.url-opts label { display: flex; gap: 8px; align-items: center; }
.url-opts select { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.error { color: var(--err); margin-top: 14px; font-size: 15px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 56px; text-align: left; }
.steps div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.steps b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
@media (max-width: 640px) { .steps { grid-template-columns: 1fr; } .url-row { flex-direction: column; } }

/* Progress */
.progress { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 16px; }
.spinner { width: 44px; height: 44px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 22px; }
@keyframes spin { to { transform: rotate(360deg); } }
.pg-card { width: min(520px, 100%); text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px; box-shadow: 0 24px 60px -36px rgba(20,20,40,.25); }
.pg-card h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; line-height: 1.3; }
.pg-detail { margin: 6px 0 22px; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.pg-bar { height: 10px; border-radius: 99px; background: #efede8; overflow: hidden; }
.pg-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: #4338ca; transition: width .4s ease-out; }
.pg-meta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pg-meta span:first-child { color: var(--ink); font-weight: 600; }
.pg-steps { list-style: none; margin: 26px 0 0; padding: 22px 0 0; border-top: 1px solid var(--line); display: grid; gap: 12px; font-size: 15px; color: var(--muted); }
.pg-steps li { display: flex; align-items: center; gap: 12px; }
.pg-steps i { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.pg-steps li.now { color: var(--ink); font-weight: 600; }
.pg-steps li.now i { border-color: #4338ca; border-top-color: transparent; animation: spin 0.9s linear infinite; }
.pg-steps li.done i { border-color: #4338ca; background: #4338ca; }
.pg-steps li.done i::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translate(0, -1px) rotate(45deg); }
.pg-note { margin: 22px 0 0; font-size: 13px; color: var(--muted); }
@media (max-width: 480px) { .pg-card { padding: 24px 20px; } }
@media (prefers-reduced-motion: reduce) { .pg-bar span { transition: none; } .pg-steps li.now i { animation: none; border-top-color: #4338ca; } }

/* Editor */
.editor { display: grid; grid-template-columns: 380px 1fr; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.side-head .src { font-size: 13px; color: var(--muted); margin-top: 6px; word-break: break-all; }
.side-body { flex: 1; overflow-y: auto; padding: 6px 22px 30px; }
.side-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.side-foot .btn { flex: 1; }
fieldset { border: 0; padding: 0; margin: 22px 0 0; }
legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.choice-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.choice { position: relative; display: block; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; cursor: pointer; font-size: 14px; }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice small { display: block; color: var(--muted); margin-top: 2px; font-size: 12.5px; }
.choice.font b { font-size: 17px; font-weight: 600; }
.fonts-grid { grid-template-columns: 1fr 1fr; }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
input[type=color] { width: 38px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.field { display: block; margin-bottom: 8px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; text-transform: capitalize; }
.field input[type=text], .field input[type=url] { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: 14px inherit; font-family: inherit; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 14px; }
.checks label, .sections label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.sections { display: grid; gap: 6px; font-size: 14px; }
.sections label { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.sections label:has(input:not(:checked)) { opacity: .5; text-decoration: line-through; }
.tag { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--bg); padding: 2px 7px; border-radius: 99px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

.stage { display: flex; flex-direction: column; min-width: 0; background: #ecebe7; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: 600 13px inherit; font-family: inherit; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.status { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.busy .dot { background: #f0a500; animation: pulse 1s infinite; }
.status.err .dot { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }
.viewport { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 18px; }
.viewport iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; box-shadow: 0 10px 40px -10px rgba(0,0,0,.25); transition: width .25s; }
.viewport.mobile iframe { width: 390px; }
.viewport .before { max-width: 100%; height: fit-content; border-radius: 8px; box-shadow: 0 10px 40px -10px rgba(0,0,0,.25); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; height: auto; } .sidebar { border-right: 0; } .stage { height: 90vh; } }

/* ---- Editor v2: tabs, theme gallery, layout picker */
.editor { grid-template-columns: 430px 1fr; }
.tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: none; padding: 13px 6px 12px; font: 600 13px inherit; font-family: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.hint.top { margin: 16px 0 12px; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.theme-card { display: block; cursor: pointer; position: relative; }
.theme-card input { position: absolute; opacity: 0; }
.thumb { display: block; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #efeee9; border: 1px solid var(--line); position: relative; transition: box-shadow .2s, transform .2s; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.theme-card:hover .thumb { transform: translateY(-2px); box-shadow: 0 10px 24px -12px rgba(0,0,0,.35); }
.theme-card:has(input:checked) .thumb { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.themes.refreshing .thumb img { opacity: .55; transition: opacity .3s; }
.thumb-wait { position: absolute; inset: 0; display: grid; place-items: center; }
.thumb-wait i { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.theme-meta { display: block; padding: 8px 2px 0; }
.theme-meta b { font-size: 14px; }
.theme-meta small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.35; margin-top: 2px; }
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lay { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 11.5px; line-height: 1.25; color: var(--muted); }
.lay input { position: absolute; opacity: 0; }
.lay svg { width: 100%; height: auto; display: block; background: #f6f5f1; border-radius: 5px; }
.lay svg rect, .lay svg circle, .lay svg path { fill: #3a3d44; }
.lay svg .img { fill: #c9c4b8; } .lay svg .img2 { fill: #aea898; stroke: #fff; stroke-width: 1.2; }
.lay svg .w { fill: #fff; } .lay svg .l { fill: #d4d1c8; } .lay svg .o { fill: #fff; stroke: #3a3d44; stroke-width: .8; }
.lay:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: 0 0 0 1px var(--accent); }
.lay:has(input:checked) svg .img { fill: #9fb0f7; }
.lay-auto { display: grid; place-items: center; aspect-ratio: 64 / 40; background: #f6f5f1; border-radius: 5px; font: 700 13px inherit; font-family: inherit; color: var(--ink); }
.seg-choice { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-choice label { flex: 1; position: relative; }
.seg-choice input { position: absolute; opacity: 0; }
.seg-choice span { display: block; text-align: center; padding: 8px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-choice input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg-choice input:disabled + span { opacity: .4; cursor: not-allowed; }
.toggle { display: flex; align-items: center; gap: 12px; font-size: 14px; padding: 8px 0; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 38px; height: 22px; border-radius: 99px; background: #d9d7d1; position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.thumb-wait[hidden] { display: none; }
.theme-meta .rec { font-style: normal; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--accent); padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: #17803d; background: #ecf8f0; border-color: #c6ebd2; }
.pill.warn { color: #9a5b00; background: #fff6e6; border-color: #f3dcb0; }
.linkbtn { border: 0; background: none; color: var(--accent); font: 600 12.5px inherit; font-family: inherit; cursor: pointer; padding: 0 4px; }
/* GoRestyle logo */
.gr-logo { display: inline-flex; align-items: center; gap: 3px; text-decoration: none; color: #0f1a17; font: 700 21px/1 "Plus Jakarta Sans", "Inter", system-ui, sans-serif; letter-spacing: -.03em; }
.gr-logo b, .sw-brand b { display: inline-grid; place-items: center; height: 1.45em; padding: 0 .3em; border-radius: 7px; background: #4338ca; color: #fff; font-weight: 800; letter-spacing: -.02em; }
.sw-brand { text-decoration: none; font: 700 17px/1 "Plus Jakarta Sans", "Inter", system-ui, sans-serif; }
.sw-brand { border-right: 0; padding-right: 0; }
