:root {
  --bg: #000;
  --surface: #09090b;
  --surface-2: #111114;
  --surface-3: #17171b;
  --line: #1c1c20;
  --line-strong: #2c2c33;
  --text: #f7f7f8;
  --muted: #9a9aa3;
  --muted-2: #6b6b74;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --danger: #ff8b8b;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  scrollbar-color: #2c2c33 #000;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: inherit; }

button { font: inherit; color: inherit; }

img { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------------------------------------------------------------- shell */

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 244px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: #070708;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  flex: none;
}

.brand-mark svg { width: 20px; height: 20px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 620;
  letter-spacing: 0.02em;
}

.brand-text span {
  font-size: 11.5px;
  color: var(--muted-2);
}

.nav { margin-top: 28px; }

.nav-label {
  padding: 0 10px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--muted-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 10px;
  height: 36px;
  margin-bottom: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-item svg { width: 16px; height: 16px; flex: none; }

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.is-active { background: var(--surface-2); color: var(--text); }

.nav-state {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted-2);
}

.nav-item.is-live .nav-state { color: var(--accent); }

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- main */

.main {
  margin-left: 244px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 40px 56px;
}

/* ---------------------------------------------------------------- hero */

.hero {
  max-width: 720px;
  margin: 48px auto 0;
  text-align: center;
}

.hero h1 {
  font-size: clamp(44px, 7vw, 78px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.lede {
  max-width: 480px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 16px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  margin-top: 30px;
  padding: 0 8px 0 20px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  border-color: #4b4b55;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.search-icon {
  width: 20px;
  height: 20px;
  color: var(--muted-2);
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search input::placeholder { color: var(--muted-2); }
.search input::-webkit-search-cancel-button { display: none; }

.search-clear {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}

.search-clear:hover { color: var(--text); background: var(--surface-2); }
.search-clear svg { width: 16px; height: 16px; }

.search-submit {
  flex: none;
  height: 44px;
  padding: 0 22px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-size: 13.5px;
  font-weight: 540;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-submit:hover { background: #e8e8e8; border-color: #e8e8e8; }

.search-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hero-meta {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.results-panel {
  max-width: 760px;
  margin: 44px auto 0;
  overflow: hidden;
}

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 16px;
}

.results-head h2 {
  font-size: 17px;
  font-weight: 560;
  letter-spacing: -0.015em;
}

.results-head p { margin-top: 2px; font-size: 13px; }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 20px;
  background: var(--accent-soft);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.notice-warn { background: rgba(255, 139, 139, 0.06); }

.notice p { display: flex; flex-wrap: wrap; gap: 6px; }

.notice strong { color: var(--text); font-weight: 560; }

.section-label {
  padding: 14px 20px 6px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- results */

.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 20px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.result-row:hover { background: var(--surface-2); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-3);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-lg { width: 44px; height: 44px; }

.result-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.result-name {
  font-size: 14.5px;
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-handle { font-size: 12.5px; color: var(--muted); }

.result-reason { font-size: 12px; color: var(--muted-2); }
.result-reason:empty { display: none; }

.result-cta { flex: none; color: var(--muted-2); }
.result-cta svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--surface-2); border-color: #3a3a43; }

.btn-primary {
  background: #fff;
  border-color: #fff;
  color: #000;
  font-weight: 540;
}

.btn-primary:hover { background: #e8e8e8; border-color: #e8e8e8; }

.btn-danger { color: var(--danger); border-color: transparent; padding-left: 6px; }

.btn-small { height: 30px; padding: 0 11px; font-size: 12.5px; flex: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn svg { width: 17px; height: 17px; }

.circle-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.circle-btn:hover { border-color: #3a3a43; background: var(--surface-2); }
.circle-btn:disabled { opacity: 0.32; cursor: default; }
.circle-btn svg { width: 16px; height: 16px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.segmented button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

.segmented button:hover { color: var(--text); }

.segmented button.is-active {
  background: var(--surface-3);
  color: var(--text);
}

.segmented-sm { padding: 2px; }
.segmented-sm button { height: 26px; font-size: 12px; }

/* ---------------------------------------------------------------- history */

.history-view { margin-top: 44px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.back-btn:hover { color: var(--text); }

.history-layout {
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.profile-panel { padding: 18px; }

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-names {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profile-names h2 {
  font-size: 17px;
  font-weight: 560;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.handle {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}

.handle:hover { color: var(--text); }

.profile-reason { font-size: 12px; color: var(--muted-2); }
.profile-reason:empty { display: none; }

.id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 8px 8px 11px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.id-label { font-size: 11.5px; color: var(--muted-2); flex: none; }

.id-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
}

.id-row .icon-btn { width: 24px; height: 24px; }

#viewToggle { margin-top: 14px; }

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  margin-top: 12px;
  aspect-ratio: 1 / 1;
  padding: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.preview-stage.is-body { aspect-ratio: 3 / 4; }

.preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.2s ease;
}

/* The CDN render has transparent padding around the figure; zoom past it. */
.preview-stage.is-body img { transform: scale(1.26); }

.preview-stage img.is-loading { opacity: 0.35; }

.preview-loader {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.preview-loader.is-visible { opacity: 1; }

.version-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.version-readout { font-size: 13.5px; }
.version-readout strong { font-weight: 560; }

.current-note {
  display: block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--accent);
  text-align: center;
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.fineprint {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-2);
}

.fineprint:empty { display: none; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.history-head h2 { font-size: 15px; font-weight: 560; }
.history-head p { margin-top: 2px; }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  max-height: 620px;
  padding: 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.history-grid::-webkit-scrollbar { width: 8px; }
.history-grid::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}

.version-card {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.version-card:hover { border-color: var(--line-strong); }

.version-card.is-active {
  border-color: var(--accent);
  background: #15111f;
}

.version-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  padding: 6px;
  overflow: hidden;
}

.history-grid.is-body .version-thumb { aspect-ratio: 3 / 4; }

.version-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.history-grid.is-body .version-thumb img { transform: scale(1.24); }

.version-download {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.14s ease;
}

.version-card:hover .version-download,
.version-card:focus-within .version-download,
.version-download:focus-visible { opacity: 1; }

.version-download svg { width: 13px; height: 13px; }

.version-foot {
  padding: 0 8px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.version-card.is-active .version-foot { color: var(--text); }

/* ---------------------------------------------------------------- footer */

.footer {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 40px 28px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 20;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #17171b;
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- narrow */

@media (max-width: 960px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand { padding: 0; }
  .brand-text span { display: none; }
  .nav { display: flex; align-items: center; gap: 2px; margin: 0 0 0 auto; }
  .nav-label, .sidebar-foot { display: none; }
  .nav-item { width: auto; margin: 0; padding: 0 10px; }
  .nav-state { margin-left: 4px; }

  .main { margin-left: 0; }
  .content { padding: 28px 20px 40px; }
  .hero { margin-top: 24px; }
  .history-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-stage { max-height: 420px; }
  .preview-stage.is-body { max-height: 520px; }
  .history-grid { max-height: none; }
  .footer { padding: 18px 20px 26px; }
}

@media (max-width: 560px) {
  .hero h1 { font-size: 42px; }
  .lede { font-size: 15px; }
  .search { height: 54px; padding-left: 16px; }
  .search-submit { height: 40px; padding: 0 16px; }
  .history-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
