/* Creator Icons - dark gallery theme */
:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --panel-2: #181c25;
  --line: #232937;
  --line-2: #2e3647;
  --text: #e8ecf4;
  --muted: #8a93a6;
  --accent: #0475FF;
  --accent-soft: rgba(4, 117, 255, .16);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Banner ---------- */
.banner {
  position: relative;
  height: 82px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(255,140,60,.35), transparent 60%),
    radial-gradient(60% 120% at 0% 100%, rgba(0,0,0,.45), transparent 70%),
    radial-gradient(60% 120% at 100% 100%, rgba(0,0,0,.45), transparent 70%),
    linear-gradient(90deg, #8f1d0a, #c2410c 50%, #8f1d0a);
  overflow: hidden;
}
.banner::after { /* subtle grain */
  content: ""; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.banner h1 {
  position: relative; z-index: 1; margin: 0;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #ffffff 0%, #f1f1f1 55%, #b9b9b9 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(60, 10, 0, .55)) drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.search {
  flex: 1 1 420px; max-width: 900px;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; background: none; border: 0; outline: 0; font-size: 18px; min-width: 0; }
.search input::placeholder { color: #6f788b; }
.search kbd {
  font: 12px var(--font); color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 2px 7px;
}

.controls { display: flex; align-items: center; gap: 18px; }
.styles { display: flex; align-items: center; gap: 12px; }
.styles-label { color: var(--muted); font-size: 14px; letter-spacing: .12em; text-transform: uppercase; }
.segmented {
  display: flex; padding: 4px; gap: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.segmented button {
  border: 0; background: none; padding: 9px 16px; border-radius: 9px;
  font-size: 15px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] {
  background: var(--panel-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 2px 8px rgba(0,0,0,.35);
}

.color-control { position: relative; display: flex; align-items: center; gap: 10px; }
.color-ring {
  width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 4px;
  background: conic-gradient(#ff3b3b, #ffd23b, #3bff6a, #3bf0ff, #3b6bff, #c53bff, #ff3b3b);
  display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.color-ring span {
  width: 100%; height: 100%; border-radius: 50%;
  border: 3px solid #0b0d12; background: var(--accent);
}
.hex-field {
  display: flex; align-items: center; gap: 4px;
  height: 40px; padding: 0 10px; width: 112px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-family: Consolas, "Cascadia Mono", monospace; color: var(--muted);
}
.hex-field input {
  width: 100%; background: none; border: 0; outline: 0;
  font-family: inherit; font-size: 15px; text-transform: uppercase; color: var(--text);
}
.hex-field:focus-within { border-color: var(--accent); }
.hex-field.invalid { border-color: #e5484d; }

.popover {
  position: absolute; right: 0; top: calc(100% + 10px);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  padding: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.55); z-index: 30;
  display: grid; gap: 10px;
}
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 2px; justify-self: start; }
.link-btn:hover { color: var(--text); }

/* ---------- Categories ---------- */
.categories {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 13px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  font-size: 15px; font-weight: 600; color: #cdd3df;
  transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: #415069; color: #fff; }
.chip .count { font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.soon .count { font-style: italic; }
.chip[aria-pressed="true"] {
  background: #1a2a44; border-color: #3d7be0; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(80,140,255,.35), 0 0 18px rgba(4,117,255,.18);
}
.chip[aria-pressed="true"] .count { color: #9cc0ff; }

/* ---------- Gallery ---------- */
main { padding: 6px 24px 60px; }
.result-bar { color: var(--muted); font-size: 13px; padding: 10px 2px 6px; min-height: 34px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1.08;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 14px; background: none;
  padding: 0;
  transition: background .15s, border-color .15s, transform .15s;
  content-visibility: auto; contain-intrinsic-size: 140px;
}
.tile:hover, .tile:focus-visible { background: var(--panel); border-color: var(--line); outline: none; }
.tile:hover canvas { transform: translateY(-2px) scale(1.04); }
.tile canvas {
  width: 92px; height: 92px;
  transition: transform .18s ease;
}
.tile .name {
  position: absolute; left: 6px; right: 6px; bottom: 6px;
  font-size: 12px; color: var(--muted); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .15s;
}
.tile:hover .name, .tile:focus-visible .name { opacity: 1; }

.empty {
  display: grid; place-items: center; gap: 8px; text-align: center;
  padding: 90px 20px; color: var(--muted);
}
.empty strong { color: var(--text); font-size: 20px; font-weight: 600; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(4, 8, 18, .72);
  backdrop-filter: blur(6px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(720px, 100%);
  background: #13161d; border: 1.5px solid #2f7cf0; border-radius: 22px;
  padding: 34px 40px 32px;
  box-shadow: 0 0 0 1px rgba(4,117,255,.15), 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(4,117,255,.12);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: 0; font-size: 28px; line-height: 1; color: var(--muted);
}
.close:hover { color: #fff; }
.modal-body { display: grid; grid-template-columns: 1fr 280px; gap: 32px; align-items: center; }
.preview-wrap { display: grid; justify-items: center; gap: 14px; }
#previewCanvas { width: 240px; height: 240px; }
.preview-meta { text-align: center; }
.preview-meta h2 { margin: 0; font-size: 18px; font-weight: 600; }
.preview-meta p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.size-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 26px; }
.size-label { color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.segmented.small button { padding: 7px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.quality-note { margin: 10px 0 0; min-height: 18px; text-align: center; font-size: 12.5px; color: var(--muted); }
.quality-note .warn { color: #f0b429; }
.modal-actions { display: flex; gap: 14px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn {
  height: 52px; padding: 0 26px; border: 0; border-radius: 8px;
  background: #0f3e7e; color: #e9f1ff; font-size: 19px; font-weight: 600;
  transition: background .15s, transform .1s;
}
.btn:hover { background: #1550a0; }
.btn:active { transform: translateY(1px); }
.split { position: relative; display: flex; gap: 2px; }
.split .btn:first-child { border-radius: 8px 0 0 8px; }
.split .caret { border-radius: 0 8px 8px 0; padding: 0 12px; display: grid; place-items: center; }
.caret svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 6px; display: grid; box-shadow: 0 14px 40px rgba(0,0,0,.5);
}
.menu button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: none; border: 0; border-radius: 7px; padding: 10px 12px; text-align: left; font-weight: 600;
}
.menu button:hover, .menu button.active { background: #1f2735; }
.menu small { color: var(--muted); font-weight: 400; }

/* ---------- Color picker ---------- */
.cp {
  width: 280px; padding: 12px;
  border: 1px solid #3a4152; border-radius: 12px; background: #0f1218;
  display: grid; gap: 12px;
}
.cp-top { display: flex; gap: 10px; align-items: center; }
.cp-swatch { width: 40px; height: 40px; border-radius: 9px; border: 1px solid rgba(255,255,255,.18); flex: none; }
.cp-hex {
  flex: 1; display: flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px;
  background: #0a0c11; border: 1px solid #2c3442; border-radius: 9px;
  font-family: Consolas, "Cascadia Mono", monospace; color: var(--muted);
}
.cp-hex input { width: 100%; background: none; border: 0; outline: 0; font-family: inherit; font-size: 15px; text-transform: uppercase; color: var(--text); }
.cp-hex:focus-within { border-color: var(--accent); }
.cp-hex.invalid { border-color: #e5484d; }
.cp-sv {
  position: relative; height: 150px; border-radius: 9px; cursor: crosshair; touch-action: none;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(var(--h, 214), 100%, 50%));
}
.cp-knob {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.5); pointer-events: none;
}
.cp-hue {
  position: relative; height: 14px; border-radius: 7px; cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.cp-hue .cp-knob { top: 50%; }
.cp-presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.cp-presets button {
  height: 28px; border-radius: 7px; border: 1px solid rgba(255,255,255,.12); padding: 0;
}
.cp-presets button.on { outline: 2px solid #fff; outline-offset: 1px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1b2230; border: 1px solid var(--line-2); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: #e5484d; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; max-width: none; }
  .controls { width: 100%; justify-content: space-between; }
}
@media (max-width: 640px) {
  .toolbar, .categories, main { padding-left: 14px; padding-right: 14px; }
  .styles-label { display: none; }
  .segmented button { padding: 8px 11px; font-size: 14px; }
  .hex-field { display: none; }
  .categories { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; height: 40px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .tile canvas { width: 72px; height: 72px; }
  .modal-card { padding: 28px 18px 22px; }
  .modal-body { grid-template-columns: 1fr; justify-items: center; gap: 18px; }
  #previewCanvas { width: 180px; height: 180px; }
  .btn { font-size: 16px; height: 46px; padding: 0 18px; }
}
