:root {
  --bg: #0b0f17;
  --bg2: #121826;
  --card: #161d2e;
  --card2: #1d2540;
  --line: #2a3350;
  --text: #e6ecff;
  --muted: #8a93b0;
  --accent: #6aa8ff;
  --accent2: #a07bff;
  --ok: #5cd9a4;
  --err: #ff7a7a;
  --warn: #ffc266;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 600px at 20% -10%, rgba(106,168,255,.18), transparent 60%),
    radial-gradient(800px 500px at 100% 10%, rgba(160,123,255,.18), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.hero {
  text-align: center;
  padding: 14px 0 22px;
}
.hero .logo { font-size: 44px; }
.hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -.02em;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub { color: var(--muted); margin: 0 auto; max-width: 60ch; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.row input {
  flex: 1;
  min-width: 0;
  background: #0e1422;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(106,168,255,.2);
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #1a2238;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  transition: transform .05s, background .15s, border-color .15s, box-shadow .15s;
}
button:hover { background: #232c4a; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #0b0f17;
  font-weight: 700;
}
button.primary:hover { filter: brightness(1.07); }
button.primary.big { padding: 14px 22px; font-size: 16px; width: 100%; }
button.ghost { background: transparent; }

.status {
  margin-top: 10px;
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
}
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }

.preview { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.thumb-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: #0e1422;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meta h2 { margin: 6px 0 10px; font-size: 20px; line-height: 1.25; }
.platform {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(106,168,255,.15);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(106,168,255,.3);
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px 16px;
  margin: 8px 0 10px;
  font-size: 14px;
}
.meta-grid > div { display: flex; flex-direction: column; }
.meta-grid span { color: var(--muted); font-size: 12px; }
.meta-grid b { font-weight: 600; }
.desc { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 8px;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
}
.tab.active {
  background: rgba(106,168,255,.12);
  color: var(--text);
  border-color: rgba(106,168,255,.3);
}

.tab-pane {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.tab-pane.active { display: grid; }
.tab-pane label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.tab-pane select {
  background: #0e1422;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
}
.hint { color: var(--muted); font-size: 14px; grid-column: 1 / -1; margin: 0; }
.hint code { background: #0e1422; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); }

.format-list {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}
.fmt {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0e1422;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 13px;
}
.fmt:hover { border-color: var(--accent); }
.fmt input { accent-color: var(--accent); }
.fmt.selected { border-color: var(--accent); background: rgba(106,168,255,.08); }
.fmt .fid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.fmt .tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.actions { margin-top: 16px; }

.settings { padding: 14px 18px; }
.settings summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
  list-style: none;
  user-select: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings[open] summary { margin-bottom: 10px; }
.cookie-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.cookie-row {
  background: #0e1422;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.cookie-row .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cookie-row .name { font-weight: 600; text-transform: capitalize; }
.cookie-row .badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.cookie-row .badge.ok { color: var(--ok); border-color: rgba(92,217,164,.4); background: rgba(92,217,164,.1); }
.cookie-row .badge.miss { color: var(--muted); }
.cookie-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cookie-row button { padding: 6px 10px; font-size: 13px; }
.cookie-row .file-label {
  display: inline-block;
  padding: 6px 10px;
  font-size: 13px;
  background: #1a2238;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.cookie-row .file-label:hover { background: #232c4a; }
.cookie-row .file-label input { display: none; }

.tok-details { margin-top: 4px; }
.tok-details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  list-style: none;
  padding: 4px 0;
}
.tok-details summary::-webkit-details-marker { display: none; }
.tok-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 4px;
}
.tok-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.tok-inp {
  background: #0b101c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.tok-inp:focus { border-color: var(--accent); }
.tok-msg { font-size: 13px; margin: 6px 0 0; min-height: 18px; }

.divider { border: none; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.sect-title { font-size: 15px; margin: 0 0 6px; }
.custom-form { display: flex; flex-direction: column; gap: 10px; }
#custom-domain {
  background: #0e1422; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: 15px; outline: none;
  transition: border-color .15s;
}
#custom-domain:focus { border-color: var(--accent); }
.pair-list { display: flex; flex-direction: column; gap: 6px; }
.pair-row { display: flex; gap: 6px; align-items: center; }
.pair-row .pair-name {
  width: 160px; flex-shrink: 0;
  background: #0e1422; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.pair-row .pair-value {
  flex: 1;
  background: #0e1422; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; outline: none;
}
.pair-row .pair-name:focus, .pair-row .pair-value:focus { border-color: var(--accent); }
.pair-remove { padding: 6px 8px; color: var(--muted); }
.custom-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.custom-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 14px;
}
.custom-entry {
  display: flex; align-items: center; justify-content: space-between;
  background: #0e1422; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; gap: 10px;
}
.custom-entry .dom { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.custom-entry .meta { color: var(--muted); font-size: 12px; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 18px;
}

.hidden { display: none !important; }

@media (max-width: 640px) {
  .preview { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row .primary { flex: 1; }
}

/* Loading spinner */
.spin::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -3px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
