@font-face {
  font-family: Inter;
  src: url('/fonts/Inter.var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}
:root {
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --radius: 16px;
  --accent: #7c5cff; --accent-2: #ff5c8a;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
}
[data-theme="dark"] {
  --bg: #0b0a12; --bg-2: #12101d; --card: #171425; --card-2: #1f1b31; --line: #2a2540;
  --text: #f3f1ff; --muted: #9c97b8; --shadow: 0 10px 40px rgba(0,0,0,.45); --glow: rgba(124,92,255,.22);
}
[data-theme="light"] {
  --bg: #f6f5fb; --bg-2: #ffffff; --card: #ffffff; --card-2: #f0eef8; --line: #e3e0ef;
  --text: #17142a; --muted: #6b6684; --shadow: 0 10px 30px rgba(30,20,80,.10); --glow: rgba(124,92,255,.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh;
  background-image: radial-gradient(900px 500px at 90% -10%, var(--glow), transparent 60%),
                    radial-gradient(700px 400px at -10% 10%, rgba(255,92,138,.08), transparent 60%);
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff; padding: 8px 14px; z-index: 100; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px); backdrop-filter: blur(14px); background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -.02em; text-decoration: none; }
.logo .mark { flex-shrink: 0; color: var(--text); }
.logo .tld { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-right { display: flex; gap: 14px; align-items: center; }
.topbar-link { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.topbar-link:hover, .topbar-link:focus-visible { color: var(--text); }
.icon-btn { border: 1px solid var(--line); background: var(--card); width: 38px; height: 38px; border-radius: 12px;
  cursor: pointer; display: grid; place-items: center; font-size: 18px; transition: transform .15s; }
.icon-btn:hover, .icon-btn:focus-visible { transform: rotate(20deg); outline: none; }
.icon-btn:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-weight: 650; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .12s, box-shadow .2s, opacity .2s; white-space: nowrap; }
.btn:hover:not(:disabled), .btn:focus-visible:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); outline: none; }
.btn.primary { background: var(--grad); border: 0; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: #c0392b; border: 0; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.home { max-width: 1120px; margin: 0 auto; padding: clamp(28px, 6vw, 72px) clamp(16px, 4vw, 40px) 64px; }
.hero { text-align: center; max-width: 760px; margin: 0 auto 44px; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
[data-theme="dark"] .eyebrow { color: #a99bff; }
.hero h1 { font-size: clamp(34px, 6vw, 60px); line-height: 1.05; letter-spacing: -.035em; margin: 14px 0 16px; font-weight: 800; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: clamp(16px, 2vw, 19px); line-height: 1.5; }
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.cat { position: relative; overflow: hidden; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 20px;
  padding: 22px 20px 20px; cursor: pointer; min-height: 160px; display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .18s, border-color .18s, box-shadow .18s; }
.cat::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 160px; height: 160px; border-radius: 50%;
  background: var(--c, var(--accent)); opacity: .16; filter: blur(10px); transition: opacity .2s, transform .3s; }
.cat:hover, .cat:focus-visible { transform: translateY(-3px); border-color: color-mix(in srgb, var(--c) 60%, var(--line)); box-shadow: var(--shadow); outline: none; }
.cat:hover::after, .cat:focus-visible::after { opacity: .3; transform: scale(1.15); }
.cat .emo { font-size: 38px; line-height: 1; }
.cat strong { display: block; font-size: 19px; letter-spacing: -.01em; margin-top: 18px; }
.cat small { color: var(--muted); font-size: 13px; display: block; margin-top: 4px; }
.cat .draft { position: absolute; top: 16px; right: 16px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--text); }

.editor { max-width: 1280px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 40px) 64px; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: 32px; align-items: start; }
.pane-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pane-head h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.source-pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }
.searchbox { position: relative; }
.searchbox input { width: 100%; padding: 16px 48px 16px 48px; font-size: 17px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s; }
.searchbox input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-52%); font-size: 22px; color: var(--muted); }
.spinner { position: absolute; right: 16px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.examples { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; align-items: center; font-size: 13px; color: var(--muted); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip:hover, .chip:focus-visible { border-color: var(--accent); outline: none; }
.target-banner { margin-top: 12px; padding: 10px 14px; border-radius: 12px; font-size: 14px; background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px dashed var(--accent); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.target-banner button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.result { position: relative; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 14px; overflow: hidden;
  padding: 0; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
.result:hover, .result:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); outline: none; }
.result .img { aspect-ratio: 1; background: var(--card-2); position: relative; overflow: hidden; }
.result img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.result img.loaded { opacity: 1; }
.result .meta { padding: 10px 12px 12px; }
.result strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.25; }
.result small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.3; }
.result .add { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.6); color: #fff; font-weight: 800; font-size: 18px; opacity: 0; transform: scale(.8); transition: .15s; }
.result:hover .add, .result:focus-visible .add { opacity: 1; transform: none; }
.result.added { border-color: color-mix(in srgb, #22c1a4 70%, var(--line)); }
.result.added .add { opacity: 1; transform: none; background: #22c1a4; font-size: 15px; }
.result.skeleton .img { animation: pulse 1.2s ease-in-out infinite; }
.result.skeleton .meta i { display: block; height: 10px; border-radius: 6px; background: var(--card-2); margin: 4px 0 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; font-weight: 800; color: rgba(255,255,255,.85);
  background: linear-gradient(135deg, hsl(var(--h, 260) 70% 55%), #1b1830); }
.empty-msg { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
.results-foot { grid-column: 1 / -1; font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

.board { position: sticky; top: 86px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); }
.board-head { margin-bottom: 14px; }
.grid-title { width: 100%; border: 0; background: transparent; font-size: 22px; font-weight: 800; letter-spacing: -.02em; outline: none; padding: 4px 2px;
  border-bottom: 1px dashed transparent; }
.grid-title:hover, .grid-title:focus { border-bottom-color: var(--line); }
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 8px; }
.progress .bar { flex: 1; height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .3s; }
.grid9 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { position: relative; margin: 0; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--card-2); user-select: none;
  border: 1.5px dashed var(--line); transition: transform .18s, box-shadow .18s, border-color .18s; }
.tile.empty { display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.tile.empty:hover, .tile.empty:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.tile.empty .plus { font-size: 26px; font-weight: 300; }
.tile.filled { border: 0; cursor: grab; touch-action: none; }
.tile.pop { animation: drop .35s cubic-bezier(.2,1.4,.4,1); }
.tile.readonly { cursor: default; touch-action: auto; animation: drop .35s cubic-bezier(.2,1.4,.4,1); animation-delay: calc(var(--i) * 40ms); animation-fill-mode: both; }
@keyframes drop { from { transform: scale(.6) translateY(-20px); opacity: 0; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile .num { position: absolute; top: 7px; left: 7px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; background: rgba(0,0,0,.55); color: #fff; z-index: 1; }
.tile.empty .num { background: transparent; color: var(--muted); }
.tile figcaption { position: absolute; inset: auto 0 0 0; padding: 22px 9px 8px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.85)); font-size: 12px; line-height: 1.2; }
.tile figcaption strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile figcaption small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .75; font-size: 10.5px; margin-top: 2px; }
.tile-credit { display: block; font-size: 9px; opacity: .55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tile .actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; z-index: 2; }
.tile:hover .actions, .tile.show-actions .actions, .tile:focus-within .actions { opacity: 1; }
.tile .actions button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 13px; }
.tile .actions button:hover { background: var(--accent-2); }
.tile.target { outline: 3px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.tile.dragging { opacity: .3; }
.tile.drop-target { transform: scale(1.04); box-shadow: 0 0 0 3px var(--accent); }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.5);
  transform: rotate(-3deg) scale(1.05); opacity: .95; }
.drag-ghost img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tip { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 0; }
.board-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }

.dialog { border: 1px solid var(--line); border-radius: 22px; padding: 0; background: var(--bg-2); color: var(--text); width: min(520px, 94vw); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(5,4,12,.6); backdrop-filter: blur(4px); }
.dialog-inner { padding: 24px; position: relative; }
.dialog h3 { margin: 0 0 4px; font-size: 22px; }
.dialog .close { position: absolute; top: 16px; right: 16px; }
.field-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.share-preview { margin: 16px 0 8px; border-radius: 14px; overflow: hidden; background: var(--card-2); aspect-ratio: 4/5; max-height: 40vh; display: grid; place-items: center; }
.share-preview canvas { max-width: 100%; max-height: 40vh; display: block; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 13px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.share { max-width: 640px; margin: 0 auto; padding: 32px 16px 64px; }
.share-head { text-align: center; margin-bottom: 22px; }
.share-head h1 { font-size: clamp(28px, 5vw, 42px); letter-spacing: -.03em; margin: 10px 0 6px; }
.share-board { position: static; }
.share-board .tile figcaption { font-size: 13px; }
.share-actions, .edit-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.attribution-block { margin-top: 28px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: var(--card); font-size: 13px; }
.attribution-block summary { cursor: pointer; font-weight: 700; }
.attribution-block ul { padding-left: 18px; margin: 10px 0; color: var(--muted); }
.empty-state { text-align: center; padding: 80px 0; }

.legal { max-width: 720px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 40px) 80px; line-height: 1.55; }
.legal h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.03em; }
.legal-list { padding-left: 18px; }
.legal-list li { margin: 10px 0; }
.contact-card { border: 1px solid var(--line); border-radius: 16px; padding: 20px; background: var(--card); margin: 20px 0; }
.contact-card h2 { margin-top: 0; font-size: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 200;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.site-foot { margin-top: auto; text-align: center; padding: 24px; font-size: 13px; color: var(--muted); }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--text); }

/* Board toggle: hidden on desktop (board always expanded) */
.board-toggle { display: none; }
.board-body { display: block; }

.mobile-bar { display: none; }
@media (max-width: 980px) {
  .mobile-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30; display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(12px);
    border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; }
  .mobile-bar[hidden] { display: none !important; }
  .editor { padding: 12px clamp(12px, 3vw, 24px) 96px; grid-template-columns: 1fr; gap: 12px; }
  /* Search first so it + early results sit above the fold; sticky compact board below topbar */
  .search-pane { order: 1; }
  .board {
    order: 0; position: sticky; top: 58px; z-index: 18; padding: 0; border-radius: 14px; overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
  }
  .board-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
    padding: 10px 12px; border: 0; background: var(--card); cursor: pointer; text-align: left; font: inherit; color: inherit;
  }
  .board-toggle-left { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 14px; white-space: nowrap; }
  .board-toggle-label { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
  .board-toggle-count { font-variant-numeric: tabular-nums; }
  .board-mini { display: flex; gap: 3px; flex: 1; justify-content: flex-end; min-width: 0; overflow: hidden; }
  .board-mini span {
    width: 22px; height: 22px; border-radius: 5px; background: var(--card-2); border: 1px solid var(--line);
    background-size: cover; background-position: center; flex-shrink: 0;
  }
  .board-mini span.on { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
  .board-chevron { color: var(--muted); font-size: 14px; transition: transform .2s; flex-shrink: 0; }
  .board[data-collapsed="false"] .board-chevron { transform: rotate(180deg); }
  .board[data-collapsed="true"] .board-body { display: none; }
  .board[data-collapsed="false"] .board-body { display: block; padding: 0 12px 12px; }
  .board[data-collapsed="false"] .board-mini { display: none; }
  /* Compact 3×3 when expanded on tablet/phone */
  .board .grid9 { gap: 6px; }
  .board .grid-title { font-size: 18px; }
  .board .tip { margin: 8px 0; }
  .cats { grid-template-columns: repeat(2, 1fr); }
  .pane-head { margin-bottom: 8px; }
  .pane-head h2 { font-size: 22px; }
  .searchbox input { padding: 12px 44px 12px 42px; font-size: 16px; border-radius: 12px; }
  .examples { margin: 10px 0 4px; }
  .results { margin-top: 10px; gap: 10px; }
}
@media (max-width: 520px) {
  .cats { gap: 10px; }
  .cat { min-height: 130px; padding: 16px; border-radius: 16px; }
  .cat .emo { font-size: 30px; }
  .cat strong { font-size: 16px; margin-top: 12px; }
  .results { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .grid9 { gap: 5px; }
  .tile { border-radius: 10px; }
  .tile figcaption { padding: 14px 5px 4px; font-size: 10px; }
  .tile figcaption small, .tile-credit { display: none; }
  .tile .actions { opacity: 1; }
  .tile .actions button { width: 24px; height: 24px; font-size: 11px; }
  .topbar-link { display: none; }
  #navCats.topbar-link { display: inline; }
  .topbar { padding: 10px 14px; }
  .board { top: 52px; }
}
