:root {
  --paper: #f6f4ef;
  --paper-2: #efece5;
  --ink: #16150f;
  --ink-2: #4b493f;
  --muted: #8b877a;
  --line: rgba(22, 21, 15, 0.1);
  --line-strong: rgba(22, 21, 15, 0.22);
  --accent: #1d4ed8;
  --accent-soft: rgba(29, 78, 216, 0.1);
  --card: #fffdf9;
  --shadow: 0 1px 2px rgba(22, 21, 15, 0.04), 0 8px 24px -12px rgba(22, 21, 15, 0.18);
  --r: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(29, 78, 216, 0.07), transparent 60%),
    var(--paper);
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- seo footer -------------------------------------------------------- */
.seo {
  max-width: 1440px; margin: 0 auto; padding: 48px 40px 72px;
  color: var(--muted); font-size: 13px; line-height: 1.65; text-align: center;
}
.seo > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.seo::before { content: ""; display: block; border-top: 1px solid var(--line); max-width: none; margin-bottom: 48px; }
.seo h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; color: var(--ink-2); margin: 0 auto 12px; letter-spacing: -0.01em; }
.seo p { margin: 0 auto 12px; }
.seo strong { font-weight: 500; color: var(--ink-2); }
.seo dl { margin: 24px auto 0; display: grid; gap: 14px; justify-items: center; }
.seo dt { font-weight: 500; color: var(--ink-2); }
.seo dd { margin: 2px 0 0; }
.seo .creator { margin: 36px auto 0; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12px; text-align: center; }
.seo .creator a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.seo .creator a:hover { color: var(--accent); }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 34vw, 480px);
  gap: 40px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}
.work { min-width: 0; }

/* ---- header ------------------------------------------------------------ */
.brand { display: inline-block; line-height: 0; }
.brand img { height: 40px; width: auto; display: block; }
h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 4.4vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 18px 0 14px;
}
h1 em { font-style: italic; color: var(--accent); }
.sub { color: var(--ink-2); font-size: 15px; max-width: 54ch; margin: 0; }

/* ---- entry ------------------------------------------------------------- */
#entry { margin: 32px 0 24px; display: flex; flex-direction: column; gap: 10px; }
.field {
  position: relative; display: flex; align-items: center;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.field-icon { width: 20px; height: 20px; margin-left: 16px; color: var(--muted); flex: none; }
#company-input {
  flex: 1; min-width: 0;
  padding: 16px 14px;
  border: none; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px;
}
#company-input:focus { outline: none; }
#company-input::placeholder { color: var(--muted); }
.field kbd {
  margin-right: 12px; padding: 2px 8px;
  font: 12px var(--sans); color: var(--muted);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
}
.entry-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.entry-hint { margin-left: auto; font-size: 12px; }
.link { background: none; border: none; padding: 0; color: var(--ink-2); cursor: pointer; font-size: 13px; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { color: var(--accent); text-decoration-color: currentColor; }

/* ---- companies --------------------------------------------------------- */
#companies { display: flex; flex-direction: column; gap: 14px; }
.companies-empty { padding: 28px 4px; color: var(--muted); font-size: 14px; }
.companies-empty .hint { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.company {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
  animation: rise 0.45s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.company-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-height: 28px; }
.company-head .name { font-weight: 600; font-size: 15px; letter-spacing: -0.005em; }
.company-head .dom { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company-head .status { color: var(--muted); font-size: 12px; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.company-head .status.picked { color: var(--accent); }
.company-head .status .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.company-head .finding { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.company-head .finding .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }
.iconbtn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid transparent; background: none;
  color: var(--muted); cursor: pointer; display: inline-grid; place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.iconbtn:hover { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
.iconbtn svg { width: 15px; height: 15px; }
.iconbtn.refresh:disabled { opacity: 0.35; cursor: default; }
.iconbtn.refresh.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.cand {
  position: relative;
  aspect-ratio: 1.55;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  overflow: hidden;
  background:
    conic-gradient(#e9e6df 25%, #f9f8f4 0 50%, #e9e6df 0 75%, #f9f8f4 0) 0 0 / 14px 14px;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.cand.new {
  animation: pop 0.4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.cand:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.cand img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.2s var(--ease); }
.cand.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cand.sel::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 10.5l3 3 7-7' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
  animation: pop 0.25s var(--ease) both;
}
.cand .src {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 8px; font-size: 10px; color: var(--ink-2);
  background: rgba(255, 253, 249, 0.92);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transform: translateY(100%); transition: transform 0.2s var(--ease);
}
.cand:hover .src { transform: none; }

.skeletons { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.skel {
  aspect-ratio: 1.55; border-radius: 10px;
  background: linear-gradient(100deg, var(--paper-2) 30%, #f7f5f0 50%, var(--paper-2) 70%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.none { color: var(--muted); font-size: 13px; padding: 6px 0; display: flex; gap: 8px; align-items: center; }

/* ---- tray / slide ------------------------------------------------------ */
#tray { position: sticky; top: 32px; height: fit-content; }
.tray-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.tray-head h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1; margin: 0; letter-spacing: -0.01em; }
.tray-sub { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.slide-frame {
  padding: 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, var(--paper-2));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.slide {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #fff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
#tray-grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), 1fr);
  grid-template-rows: repeat(var(--rows, 1), 1fr);
}
.tray-cell { display: flex; align-items: center; justify-content: center; position: relative; }
.tray-cell img { width: var(--logo-size, 72%); height: var(--logo-size, 72%); object-fit: contain; animation: land 0.5s var(--ease) both; }
@keyframes land { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.tray-cell .who {
  position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%);
  font-size: 9px; color: var(--muted); white-space: nowrap; opacity: 0; transition: opacity 0.15s;
}
.slide:hover .tray-cell .who { opacity: 1; }
.slide-empty {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px;
  color: var(--muted); font-size: 12px; text-align: center; padding: 20px;
  transition: opacity 0.3s;
}
.slide-empty.hidden { display: grid !important; opacity: 0; pointer-events: none; }
.slide-empty p { margin: 0; }
.ghost-grid { display: grid; grid-template-columns: repeat(3, 44px); gap: 10px; }
.ghost-grid i { display: block; height: 28px; border: 1.5px dashed var(--line-strong); border-radius: 6px; }
.tray-foot { margin: 10px 4px 0; color: var(--muted); font-size: 12px; }
.size-ctl {
  display: flex; align-items: center; gap: 12px; margin: 16px 4px 0;
  font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.size-ctl span { font-weight: 500; }
.size-ctl output { color: var(--muted); min-width: 36px; text-align: right; }
.size-ctl input[type=range] { flex: 1; accent-color: var(--accent); height: 20px; margin: 0; cursor: pointer; }
.tray-actions { display: flex; flex-direction: column; gap: 8px; margin: 16px 4px 0; }
.tray-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  background: var(--ink); color: #fff; border: none;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: transform 0.15s var(--ease), opacity 0.2s, background 0.2s;
}
.tray-btn svg { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }
.tray-btn:hover:not(:disabled) { background: var(--accent); transform: translateY(-1px); }
.tray-btn:hover:not(:disabled) svg { transform: translateX(3px); }
.tray-btn:disabled { opacity: 0.35; cursor: default; }
.tray-btn .badge {
  font-style: normal; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px; background: var(--accent); color: #fff; line-height: 1;
}
.tray-btn:hover:not(:disabled) .badge { background: #fff; color: var(--accent); }
.tray-actions .tray-foot { margin: 2px 0 0; }

/* flying logo (pick → slide) */
.fly {
  position: fixed; z-index: 30; pointer-events: none; object-fit: contain;
  transition: all 0.55s cubic-bezier(0.3, 0.9, 0.3, 1);
}

/* ---- modal / toast ----------------------------------------------------- */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(22, 21, 15, 0.45); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 10;
  animation: fade 0.2s both;
}
@keyframes fade { from { opacity: 0; } }
#modal {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; max-width: 480px; width: 90%; box-shadow: 0 30px 80px -20px rgba(22, 21, 15, 0.4);
  animation: rise 0.35s var(--ease) both;
}
#modal h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0 0 6px; }
#modal .sub { font-size: 14px; }
#modal ol { padding-left: 20px; color: var(--ink-2); font-size: 14px; line-height: 1.8; margin: 14px 0 0; }
#modal ol b { color: var(--ink); font-weight: 600; }
#modal .actions { display: flex; gap: 10px; margin-top: 22px; }
#modal button {
  background: var(--ink); color: #fff; border: none; padding: 10px 16px;
  border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 500;
}
#modal button:hover { background: var(--accent); }
#modal button.ghost { background: none; border: 1px solid var(--line-strong); color: var(--ink); }
#modal button.ghost:hover { background: var(--paper-2); }
.hidden { display: none !important; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 13px; z-index: 20; box-shadow: var(--shadow);
  animation: rise 0.3s var(--ease) both;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; gap: 28px; padding: 24px 20px 60px; }
  .seo { padding: 32px 20px 56px; }
  .entry-hint { display: none; }
  #tray { position: static; order: -1; }
  h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
