/* ---------- Tokens ---------- */
:root{
  --bg:            #0B1220;
  --bg-panel:      #10192E;
  --bg-elevated:   #16223B;
  --border:        #253453;
  --text:          #EDEFF3;
  --text-dim:      #8C97AC;
  --accent:        #3DD6C4;
  --accent-strong: #23A897;
  --amber:         #F2A93B;
  --danger:        #E1585A;
  --radius:        14px;
  --radius-sm:     8px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: 'Space Grotesk', 'Inter', sans-serif;
  --body: 'Inter', sans-serif;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(61,214,196,0.08), transparent 60%),
    var(--bg);
  color:var(--text);
  font-family:var(--body);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}

a{ color:var(--accent); }
button{ font-family:inherit; }

/* ---------- Layout ---------- */
.wrap{
  max-width:1180px;
  margin:0 auto;
  padding:32px 24px 80px;
}

header.top{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:16px;
  margin-bottom:36px;
  flex-wrap:wrap;
}

.brand h1{
  font-family:var(--display);
  font-size:26px;
  margin:0 0 4px;
  letter-spacing:-0.01em;
}

.brand .tagline{
  font-family:var(--mono);
  font-size:12.5px;
  color:var(--text-dim);
}
.brand .tagline .arrow{ color:var(--accent); padding:0 6px; }

.top .meta{
  font-family:var(--mono);
  font-size:12px;
  color:var(--text-dim);
  text-align:right;
}

.grid{
  display:grid;
  grid-template-columns:400px 1fr;
  gap:24px;
  align-items:start;
}

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

.panel{
  background:var(--bg-panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
}

.panel h2{
  font-family:var(--display);
  font-size:15px;
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--text-dim);
  margin:0 0 18px;
}

/* ---------- Form ---------- */
.field{ margin-bottom:18px; }
.field label{
  display:block;
  font-size:13px;
  font-weight:600;
  margin-bottom:6px;
}
.field .hint{
  display:block;
  font-size:12px;
  color:var(--text-dim);
  margin-top:5px;
}

input[type="text"], input[type="url"]{
  width:100%;
  background:var(--bg-elevated);
  border:1px solid var(--border);
  color:var(--text);
  border-radius:var(--radius-sm);
  padding:10px 12px;
  font-size:14px;
  outline:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="url"]:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(61,214,196,0.18);
}
input[type="text"].invalid, input[type="url"].invalid{
  border-color:var(--danger);
}

.error-text{
  color:var(--danger);
  font-size:12px;
  margin-top:6px;
  display:none;
}
.error-text.show{ display:block; }

/* Logo dropzone */
.dropzone{
  border:1px dashed var(--border);
  border-radius:var(--radius-sm);
  background:var(--bg-elevated);
  padding:14px;
  display:flex;
  align-items:center;
  gap:14px;
  cursor:pointer;
  transition:border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.drag{
  border-color:var(--accent);
  background:rgba(61,214,196,0.06);
}
.dropzone input[type="file"]{ display:none; }
.dropzone .thumb{
  width:44px; height:44px;
  border-radius:8px;
  background:var(--bg);
  border:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex-shrink:0;
}
.dropzone .thumb img{ width:100%; height:100%; object-fit:contain; }
.dropzone .thumb svg{ width:18px; height:18px; color:var(--text-dim); }
.dropzone .dz-text{ font-size:13px; color:var(--text-dim); }
.dropzone .dz-text b{ color:var(--text); font-weight:600; }
.dropzone .dz-clear{
  margin-left:auto;
  background:none;
  border:none;
  color:var(--text-dim);
  font-size:12px;
  text-decoration:underline;
  cursor:pointer;
  display:none;
}
.dropzone.has-file .dz-clear{ display:block; }

/* Style presets */
.style-grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:8px;
}
.style-card{
  border:1px solid var(--border);
  background:var(--bg-elevated);
  border-radius:var(--radius-sm);
  padding:10px 6px;
  text-align:center;
  cursor:pointer;
  transition:border-color .15s ease, transform .1s ease;
}
.style-card:hover{ transform:translateY(-1px); }
.style-card.active{
  border-color:var(--accent);
  box-shadow:0 0 0 2px rgba(61,214,196,0.18) inset;
}
.style-card svg{ width:34px; height:34px; margin-bottom:6px; }
.style-card span{ display:block; font-size:11px; color:var(--text-dim); }
.style-card.active span{ color:var(--text); }

/* Advanced (collapsible) */
details.advanced{ margin-top:6px; }
details.advanced > summary{
  cursor:pointer;
  font-size:12.5px;
  color:var(--text-dim);
  list-style:none;
  display:flex;
  align-items:center;
  gap:6px;
  user-select:none;
}
details.advanced > summary::-webkit-details-marker{ display:none; }
details.advanced > summary::before{
  content:'▸';
  font-size:10px;
  transition:transform .15s ease;
}
details.advanced[open] > summary::before{ transform:rotate(90deg); }
.advanced-body{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
  margin-top:14px;
}
.color-field label{ font-size:12px; color:var(--text-dim); display:block; margin-bottom:4px; }
.color-field .swatch-row{ display:flex; align-items:center; gap:8px; }
input[type="color"]{
  -webkit-appearance:none;
  width:32px; height:32px;
  border:1px solid var(--border);
  border-radius:6px;
  background:none;
  padding:0;
  cursor:pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper{ padding:2px; }
input[type="color"]::-webkit-color-swatch{ border-radius:4px; border:none; }
.color-field code{ font-family:var(--mono); font-size:11px; color:var(--text-dim); }

input[type="range"]{ width:100%; accent-color:var(--accent); }
.slider-field{ grid-column:1 / -1; }
.slider-field label{ font-size:12px; color:var(--text-dim); display:flex; justify-content:space-between; }

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  border:none;
  border-radius:var(--radius-sm);
  padding:11px 18px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition:filter .15s ease, transform .1s ease;
}
.btn:active{ transform:translateY(1px); }
.btn-primary{
  background:var(--accent);
  color:#04211D;
  width:100%;
  margin-top:8px;
}
.btn-primary:hover{ filter:brightness(1.08); }
.btn-primary:disabled{ opacity:0.55; cursor:not-allowed; }
.btn-ghost{
  background:var(--bg-elevated);
  color:var(--text);
  border:1px solid var(--border);
}
.btn-ghost:hover{ border-color:var(--accent); }
.btn-danger-ghost{
  background:none;
  border:1px solid var(--border);
  color:var(--danger);
  padding:6px 10px;
  font-size:12px;
  border-radius:6px;
}
.btn-danger-ghost:hover{ border-color:var(--danger); background:rgba(225,88,90,0.08); }

/* ---------- Preview ---------- */
.preview-panel{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:18px;
  min-height:420px;
  justify-content:center;
}
.preview-panel.empty .reticle{ opacity:0.35; }

.reticle{
  position:relative;
  width:300px;
  height:300px;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:opacity .2s ease;
}
.reticle::before, .reticle::after,
.reticle .corner-tr, .reticle .corner-bl{
  content:'';
  position:absolute;
  width:26px; height:26px;
  border-color:var(--accent);
  border-style:solid;
  border-width:0;
}
.reticle::before{ top:-8px; left:-8px; border-top-width:3px; border-left-width:3px; border-radius:6px 0 0 0; }
.reticle::after{ bottom:-8px; right:-8px; border-bottom-width:3px; border-right-width:3px; border-radius:0 0 6px 0; }
.reticle .corner-tr{ top:-8px; right:-8px; border-top-width:3px; border-right-width:3px; border-radius:0 6px 0 0; }
.reticle .corner-bl{ bottom:-8px; left:-8px; border-bottom-width:3px; border-left-width:3px; border-radius:0 0 0 6px; }

.reticle.pulse::before, .reticle.pulse::after,
.reticle.pulse .corner-tr, .reticle.pulse .corner-bl{
  animation:blink .5s ease;
}
@keyframes blink{
  0%{ border-color:var(--text); }
  100%{ border-color:var(--accent); }
}
@media (prefers-reduced-motion: reduce){
  .reticle.pulse::before, .reticle.pulse::after,
  .reticle.pulse .corner-tr, .reticle.pulse .corner-bl{ animation:none; }
}

#qr-canvas{
  width:260px;
  height:260px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#fff;
  border-radius:8px;
  overflow:hidden;
}
#qr-canvas canvas, #qr-canvas svg, #qr-canvas img{ display:block; }

.preview-panel .placeholder{
  font-family:var(--mono);
  font-size:12.5px;
  color:var(--text-dim);
  text-align:center;
  max-width:220px;
}

.short-link{
  display:flex;
  align-items:center;
  gap:8px;
  background:var(--bg-elevated);
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px 12px;
  font-family:var(--mono);
  font-size:13px;
}
.short-link .copy-btn{
  background:none;
  border:none;
  color:var(--accent);
  cursor:pointer;
  font-size:12px;
  font-family:var(--mono);
}

.download-row{ display:flex; gap:10px; }

/* ---------- History ---------- */
.history{ margin-top:24px; }
table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
thead th{
  text-align:left;
  color:var(--text-dim);
  font-weight:600;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.06em;
  padding:0 10px 10px;
  border-bottom:1px solid var(--border);
}
tbody td{
  padding:12px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}
tbody tr:last-child td{ border-bottom:none; }
td.id-cell{ font-family:var(--mono); color:var(--accent); }
td.hits-cell{ font-family:var(--mono); color:var(--amber); }
td.url-cell{
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--text-dim);
}
.row-actions{ display:flex; gap:8px; }
.empty-row td{ text-align:center; color:var(--text-dim); padding:24px; font-family:var(--mono); font-size:12px; }

/* Scrollbar polish (optional, harmless if unsupported) */
::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-thumb{ background:var(--border); border-radius:6px; }

/* focus visibility */
button:focus-visible, input:focus-visible, summary:focus-visible, .style-card:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}
