:root {
  color-scheme: light;
  --bg: #f1f2f5;
  --card: #ffffff;
  --text: #191c22;
  --muted: #868e9c;
  --border: #ebedf0;
  --field: #f5f6f8;

  --dark: #14171d;         /* buttons / active pills */
  --dark-hover: #2b2f38;
  --accent: #2f6bff;       /* links, focus, number badge */
  --accent-soft: #eaf0ff;

  --green: #1fa463;  --green-soft: #e6f6ee;
  --orange: #d9861f; --orange-soft: #fbf0dc;
  --danger: #e5484d; --danger-soft: #fdecec;

  --shadow: 0 1px 2px rgba(20, 30, 55, .04), 0 8px 24px rgba(20, 30, 55, .06);
  --shadow-sm: 0 1px 3px rgba(20, 30, 55, .05);
  --radius: 20px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  line-height: 1.5;
  padding: 0 20px 60px;
  background: var(--bg);
}

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 12px; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  max-width: 1120px; margin: 12px auto 0; padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 40px;
  box-shadow: var(--shadow-sm);
}
.brand { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.nav-links { display: flex; gap: 4px; }
.navlink {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 16px; border-radius: 30px;
  font-weight: 600; font-size: .92rem; color: var(--muted); transition: .16s;
}
.navlink:hover { color: var(--text); }
.navlink.active { background: var(--dark); color: #fff; }
.authbar { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }
.authbar .email { font-weight: 600; color: var(--text); }

/* ---- Layout ---- */
.view { max-width: 1120px; margin: 20px auto 0; }
.layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: start; }
.col-left { display: grid; gap: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.sec-head {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 18px; font-size: 1.18rem; font-weight: 800; letter-spacing: -.01em;
}
.num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: .95rem; font-weight: 800; flex: 0 0 auto;
}
.optional { color: var(--muted); font-weight: 500; font-size: .9rem; }
.field-label { display: block; color: var(--muted); font-size: .9rem; margin: 4px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }

/* ---- Fields ---- */
.link-input, .login-email, .domain-add input, #domain-select, .sub-input, input[type=text], input[type=email] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  font-size: 1rem;
  transition: .16s;
}
.link-input:focus, .login-email:focus, .domain-add input:focus, input[type=text]:focus, input[type=email]:focus {
  outline: none; border-color: var(--accent); background: var(--card);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---- QR type constructor ---- */
.type-group-title { font-size: .78rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin: 16px 0 10px; }
.type-group-title:first-child { margin-top: 0; }
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); cursor: pointer; transition: .14s;
}
.type-card:hover { border-color: var(--accent); background: var(--field); transform: translateY(-1px); }
.tc-icon { font-size: 1.25rem; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--field); border-radius: 10px; flex: 0 0 auto; }
.type-card:hover .tc-icon { background: var(--accent-soft); }
.tc-text { display: flex; flex-direction: column; min-width: 0; }
.tc-label { font-weight: 700; font-size: .95rem; }
.tc-desc { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- WYSIWYG editor ---- */
.wysiwyg { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--card); }
.wys-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; background: var(--field); border-bottom: 1px solid var(--border); }
.wys-toolbar button { border: 0; background: transparent; cursor: pointer; min-width: 32px; height: 30px; padding: 0 8px; border-radius: 8px; font-size: .9rem; color: var(--text); }
.wys-toolbar button:hover { background: var(--card); }
.wys-toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.wys-sep { width: 1px; background: var(--border); margin: 3px 4px; }
.wys-area { min-height: 160px; max-height: 340px; overflow-y: auto; padding: 14px 16px; outline: none; line-height: 1.6; }
.wys-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.wys-area h1 { font-size: 1.5rem; margin: .3em 0; } .wys-area h2 { font-size: 1.25rem; margin: .3em 0; }
.wys-area ul, .wys-area ol { padding-left: 1.4em; } .wys-area a { color: var(--accent); }

.type-back { margin-bottom: 16px; padding: 7px 14px; font-size: .85rem; }
.type-form-head { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 800; margin-bottom: 14px; }
.type-form-head .tf-icon { font-size: 1.35rem; }
#type-fields label.field-label { margin-top: 14px; }
#type-fields label.field-label:first-child { margin-top: 0; }
.type-form select, #type-fields textarea { width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--field); color: var(--text); font-size: 1rem; }
.type-form select:focus, #type-fields textarea:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 4px var(--accent-soft); }
#type-fields textarea { resize: vertical; font-family: inherit; }

@media (max-width: 460px) { .type-cards { grid-template-columns: 1fr; } }

/* ---- Dropzone ---- */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: 16px;
  background: var(--field); padding: 28px 18px; text-align: center;
  cursor: pointer; transition: .16s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 2rem; margin-bottom: 6px; }
.dz-hint { font-size: .8rem; margin-top: 4px; }
.dz-picked { display: flex; align-items: center; justify-content: center; gap: 12px; }
.dz-picked #dz-name { font-weight: 600; word-break: break-all; }

/* ---- Switch ---- */
.switch { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: .9rem; cursor: pointer; }
.switch input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--dark); }
.dyn-note { margin: 8px 0 0; font-size: .85rem; }

/* ---- Design tabs ---- */
.dtabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.dtab {
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  padding: 8px 14px; font-size: .78rem; font-weight: 700; letter-spacing: .5px;
  color: var(--muted); border-radius: 20px; transition: .16s;
}
.dtab:hover { color: var(--text); }
.dtab.active { color: #fff; background: var(--dark); border-color: var(--dark); }
.dpanel { display: none; }
.dpanel.active { display: block; }

/* ---- Choice grids (frames, shapes) ---- */
.grid-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; margin-bottom: 6px; }
.choice {
  aspect-ratio: 1; border: 1.5px solid var(--border); border-radius: 14px;
  background: var(--card); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 6px; transition: .15s;
}
.choice:hover { border-color: var(--accent); }
.choice.active { border-color: var(--dark); box-shadow: 0 0 0 3px rgba(20, 23, 29, .08); }
.choice svg { width: 30px; height: 30px; }
.choice .cap { font-size: .58rem; color: var(--muted); font-weight: 700; letter-spacing: .3px; text-align: center; }
.choice.active .cap { color: var(--text); }

/* ---- Color ---- */
.color-row { display: flex; gap: 24px; flex-wrap: wrap; }
.color-field { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; }
.color-field input[type=color] {
  width: 46px; height: 34px; padding: 0; border: 1px solid var(--border);
  border-radius: 10px; background: none; cursor: pointer;
}

/* ---- Logo ---- */
input[type=file] { font-size: .9rem; color: var(--muted); }
#logo-remove { margin-top: 14px; }

/* ---- Preview ---- */
.preview-card { position: sticky; top: 92px; }
.preview-wrap { display: flex; justify-content: center; padding: 8px 0 4px; }
.frame-wrap {
  --fc: #000;
  display: inline-flex; flex-direction: column; align-items: stretch;
  background: var(--fc); padding: 14px; border-radius: 22px; gap: 8px;
  transition: opacity .2s, filter .2s;
}
.frame-wrap.top { flex-direction: column-reverse; }
.frame-wrap.square { border-radius: 8px; }
.frame-wrap.none { background: transparent; padding: 0; gap: 0; }
.frame-wrap.placeholder { opacity: .28; filter: grayscale(1); }
.frame-wrap .qr-box { background: #fff; border-radius: 12px; padding: 8px; line-height: 0; }
.frame-wrap.none .qr-box { padding: 0; }
.frame-wrap .frame-label { color: #fff; text-align: center; font-weight: 800; letter-spacing: 2px; font-size: 1rem; padding: 2px 0 4px; }
.frame-wrap.none .frame-label { display: none; }
#preview canvas, #preview svg { display: block; width: 240px; height: 240px; border-radius: 6px; }
.preview-hint { text-align: center; font-size: .88rem; margin: 12px 0 0; }
.content-preview { display: flex; align-items: center; gap: 12px; margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--field); text-align: left; }
.cp-icon { width: 40px; height: 40px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cp-icon img { width: 100%; height: 100%; object-fit: cover; }
.cp-icon .cp-fav { width: 22px; height: 22px; }
.cp-text { min-width: 0; flex: 1; }
.cp-title { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-sub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content-preview.page-mode { display: block; padding: 0; background: transparent; border: 0; }
.pp-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--field); border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; }
.pp-bar i { width: 9px; height: 9px; border-radius: 50%; background: #d6dae1; flex: 0 0 auto; }
.pp-bar span { margin-left: 8px; font-size: .72rem; color: var(--muted); }
.pp-frame { width: 100%; height: 320px; border: 1px solid var(--border); border-radius: 0 0 12px 12px; background: #f1f2f5; display: block; }
.short-note { text-align: center; font-size: .85rem; color: var(--muted); word-break: break-all; margin: 12px 0 0; }
.short-note a { color: var(--accent); }

/* ---- Buttons ---- */
.dl-row { display: flex; gap: 10px; margin-top: 22px; }
.btn-primary, .btn-download {
  border: 0; cursor: pointer; color: #fff;
  background: var(--dark);
  font-weight: 700; border-radius: 30px; transition: .16s;
}
.btn-primary { padding: 13px 20px; font-size: 1rem; }
.btn-download { flex: 1; padding: 15px; font-size: 1.02rem; }
.btn-primary:hover, .btn-download:hover { background: var(--dark-hover); }
.btn-primary:disabled, .btn-download:disabled { opacity: .55; cursor: default; }

.btn-ghost {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 30px; font-weight: 600; cursor: pointer; transition: .16s;
}
.btn-ghost:hover { border-color: var(--muted); background: var(--field); }
.authbar button {
  padding: 7px 14px; font-size: .85rem; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 24px; cursor: pointer;
}
.authbar button:hover { background: var(--field); }
.link-danger { color: var(--danger) !important; border-color: rgba(229, 72, 77, .4) !important; }
.link-danger:hover { background: var(--danger-soft) !important; }

/* ---- Login ---- */
.login { display: grid; gap: 12px; }
.login h2 { margin: 0 40px 0 0; font-size: 1.2rem; }
.login-msg { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--field); font-size: .9rem; word-break: break-all; }
.login-msg a { color: var(--accent); }
.consent { font-size: .78rem; line-height: 1.5; margin: 2px 0 0; }
.consent a { color: var(--accent); }
.login-prompt { display: grid; gap: 14px; justify-items: start; }
.login-prompt .muted { margin: 0; }

/* ---- Modal popup ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 22, 40, .45);
  animation: overlay-in .16s ease;
}
.modal {
  position: relative; width: 100%; max-width: 420px; padding: 28px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 24px 60px rgba(10, 25, 50, .28);
}
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 30px; height: 30px; padding: 0;
  border: 0; background: transparent; cursor: pointer; font-size: 1.6rem; line-height: 1;
  color: var(--muted); border-radius: 8px;
}
.modal-close:hover { background: var(--field); color: var(--text); }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Codes / files list ---- */
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.code-row { display: grid; gap: 4px; padding: 16px 0; border-top: 1px solid var(--border); }
.code-row:first-child { border-top: 0; }
.code-title { font-weight: 700; }
.code-meta { font-size: .85rem; color: var(--muted); word-break: break-all; }
.code-meta a { color: var(--accent); }
.code-scans { color: var(--green); font-weight: 700; }
.code-actions { display: flex; gap: 8px; margin-top: 6px; }
.code-actions button { padding: 7px 14px; font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 22px; }

/* ---- Domains ---- */
.dom-option { padding: 18px 20px; margin: 16px 0; background: var(--card); border: 1px solid var(--border); border-radius: 16px; }
.dom-option-title { font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: 10px; }
.dom-tag { font-size: .68rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--green); background: var(--green-soft); padding: 3px 9px; border-radius: 20px; }
.dom-option-sub { margin: 6px 0 12px; font-size: .88rem; }
.sub-add { display: flex; gap: 10px; }
.sub-input { flex: 1; display: flex; align-items: center; padding: 0; overflow: hidden; }
.sub-input input { flex: 1; border: 0; background: transparent; box-shadow: none; padding: 13px 14px; min-width: 0; }
.sub-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--card); }
.sub-input input:focus { box-shadow: none; background: transparent; border: 0; }
.sub-suffix { color: var(--muted); padding: 0 14px 0 4px; white-space: nowrap; font-size: .95rem; }
.domain-add { display: flex; gap: 10px; }
.dom-row { padding: 16px 0; border-top: 1px solid var(--border); }
.dom-row:first-child { border-top: 0; }
.dom-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dom-name { font-weight: 700; }
.dom-badge { font-size: .72rem; font-weight: 700; padding: 4px 11px; border-radius: 20px; }
.dom-badge.active { background: var(--green-soft); color: var(--green); }
.dom-badge.pending { background: var(--orange-soft); color: var(--orange); }
.dom-badge.error { background: var(--danger-soft); color: var(--danger); }
.dom-actions { margin-left: auto; display: flex; gap: 8px; }
.dom-actions button { padding: 7px 14px; font-size: .85rem; }
.dom-help { margin: 10px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--field); font-size: .86rem; color: var(--muted); line-height: 1.6; }
.dom-help code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; color: var(--accent); font-size: .85rem; font-weight: 600; }
.dom-err { color: var(--danger); font-size: .85rem; margin: 8px 0 0; }

/* ---- Domain selector in generator ---- */
.domain-row { margin-top: 16px; }

/* ---- Profile / storage ---- */
.storage-head { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.storage-bar { height: 12px; border-radius: 8px; background: var(--field); overflow: hidden; margin: 10px 0 6px; }
.storage-fill { height: 100%; width: 0; background: var(--accent); border-radius: 8px; transition: width .3s, background .3s; }
.storage-fill.warn { background: var(--orange); }
.storage-fill.full { background: var(--danger); }
.plan-box { margin-top: 22px; border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; padding: 0; font-size: 1.2rem; border-radius: 12px; }
.stepper span { min-width: 28px; text-align: center; font-weight: 700; }
.plan-summary { margin-top: 12px; }

/* ---- Analytics dashboard ---- */
.stats-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.range-btn { padding: 7px 14px; font-size: .82rem; }
.stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.stat-card { background: var(--field); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.stat-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-num { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.chart-block { margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.chart-title { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.chart-block svg { display: block; width: 100%; height: auto; }
.stats-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats-two .chart-block { margin-top: 16px; }
.hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: 90px 1fr 42px; align-items: center; gap: 8px; font-size: .84rem; }
.hbar-label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; background: var(--field); border-radius: 6px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.hbar-val { text-align: right; color: var(--muted); font-weight: 700; }
@media (max-width: 640px) { .stats-two { grid-template-columns: 1fr; } .stat-cards { grid-template-columns: 1fr; } }

/* ---- Terms / disclaimer ---- */
.upload-terms { margin: 12px 0 0; font-size: .78rem; line-height: 1.5; }
.upload-terms a, .linklike { color: var(--accent); }
.legal-footer { max-width: 1120px; margin: 28px auto 0; text-align: center; }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; font-size: .85rem; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.linklike:hover { color: var(--accent); }
.terms-modal { max-width: 560px; max-height: 85vh; overflow-y: auto; }
.terms-body { display: grid; gap: 12px; font-size: .9rem; color: var(--text); }
.terms-body strong { font-weight: 700; }

/* ---- Responsive ---- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .col-right { order: -1; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; border-radius: 24px; }
  .authbar { width: 100%; margin: 4px 0 0; justify-content: flex-start; }
}
