:root {
  color-scheme: dark;
  --bg: #070a0f;
  --panel: rgba(20, 27, 38, 0.9);
  --panel-strong: #151d29;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f8fb;
  --muted: #96a3b6;
  --accent: #7cf2c3;
  --accent-dark: #071a13;
  --blue: #8db8ff;
  --danger: #ff8f97;
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 8% -8%, rgba(64, 111, 255, 0.24), transparent 30rem),
    radial-gradient(circle at 108% 16%, rgba(52, 255, 181, 0.13), transparent 26rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans",
    "Yu Gothic UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

.shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 18px
    max(32px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 4px 25px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.7rem, 12vw, 5.1rem);
  line-height: 0.88;
  letter-spacing: -0.065em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.42rem;
  letter-spacing: -0.035em;
}

.lead {
  max-width: 510px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

.privacy-badge {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(124, 242, 195, 0.22);
  border-radius: 999px;
  background: rgba(124, 242, 195, 0.07);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(124, 242, 195, 0.9);
}

.install-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(141, 184, 255, 0.22);
  border-radius: 18px;
  background: rgba(68, 106, 174, 0.1);
}

.install-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.install-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--blue);
  color: #07101d;
  font-size: 1.25rem;
  font-weight: 900;
}

#dismissInstall {
  align-self: start;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
}

.card {
  margin-bottom: 17px;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.23);
  backdrop-filter: blur(18px);
}

fieldset {
  min-width: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
}

.mode-option span {
  display: flex;
  min-height: 106px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.mode-option b {
  font-size: 1.15rem;
  letter-spacing: 0.05em;
}

.mode-option small,
.picker small {
  color: var(--muted);
  line-height: 1.45;
}

.mode-option input:checked + span {
  border-color: rgba(124, 242, 195, 0.75);
  background: rgba(124, 242, 195, 0.09);
  box-shadow: inset 0 0 0 1px rgba(124, 242, 195, 0.17);
}

.mode-option:active span {
  transform: scale(0.985);
}

.picker {
  display: flex;
  min-height: 160px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 20px;
  border: 1px dashed rgba(141, 184, 255, 0.48);
  border-radius: 19px;
  background: rgba(77, 121, 202, 0.08);
  text-align: center;
}

.picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.picker-plus {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 7px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #07101e;
  font-size: 1.7rem;
}

.source-wrap {
  margin-top: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #020304;
}

.source-wrap img {
  display: block;
  width: 100%;
  max-height: 430px;
  object-fit: contain;
}

.source-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.76rem;
}

.source-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-list {
  display: grid;
  max-height: 230px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.selection-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.045);
  color: #c3ccda;
  font-size: 0.72rem;
}

.selection-item:first-child {
  border-top: 0;
}

.selection-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-item small,
.selection-more {
  color: #697689;
}

.selection-more {
  padding: 10px 13px;
  font-size: 0.72rem;
  text-align: center;
}

.text-button {
  flex: 0 0 auto;
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 750;
}

.primary,
.secondary {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.primary {
  width: 100%;
  margin-top: 18px;
  border: 0;
  background: var(--accent);
  color: var(--accent-dark);
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

.primary:not(:disabled):active,
.secondary:active {
  transform: translateY(1px);
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

.memory-note {
  margin: 10px 0 0;
  color: #697689;
  font-size: 0.68rem;
  line-height: 1.5;
  text-align: center;
}

.status-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-pill,
.hit-count {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(141, 184, 255, 0.12);
  color: var(--blue);
  font-size: 0.73rem;
  font-weight: 850;
}

.progress-track {
  height: 7px;
  margin: 20px 0 13px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--accent));
  transition: width 240ms ease;
}

.progress-bar.indeterminate {
  width: 34%;
  animation: travel 1.15s ease-in-out infinite;
}

@keyframes travel {
  from { transform: translateX(-110%); }
  to { transform: translateX(300%); }
}

.status-message {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.section-title {
  margin: 29px 4px 13px;
}

.batch-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.batch-actions .primary {
  min-height: 54px;
  margin: 0;
}

.batch-actions .secondary {
  min-height: 54px;
}

.batch-actions button {
  width: 100%;
}

.results-grid {
  display: grid;
  gap: 15px;
}

.result-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--panel-strong);
}

.result-card > img {
  display: block;
  width: 100%;
  max-height: 560px;
  background: #020304;
  object-fit: contain;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding: 14px;
}

.result-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.result-text strong {
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-text small {
  color: var(--muted);
  font-size: 0.68rem;
}

.result-buttons {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.mini-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
}

.result-error {
  padding: 17px;
  border-color: rgba(255, 143, 151, 0.3);
  background: rgba(255, 143, 151, 0.075);
}

.result-error strong {
  color: var(--danger);
}

.result-error p {
  margin: 7px 0 0;
  color: #d99ca2;
  font-size: 0.75rem;
  line-height: 1.55;
}

.offline-card {
  display: grid;
  gap: 8px;
  margin-top: 19px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.offline-card p {
  margin: 0;
  color: #748195;
  font-size: 0.72rem;
  line-height: 1.55;
}

.offline-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.offline-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667286;
}

.offline-status.ready {
  color: var(--accent);
}

.offline-status.ready span {
  background: var(--accent);
  box-shadow: 0 0 11px rgba(124, 242, 195, 0.85);
}

footer {
  padding: 23px 8px 0;
  color: #647185;
  font-size: 0.7rem;
  line-height: 1.6;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 560px) {
  .hero {
    display: block;
  }

  .privacy-badge {
    width: fit-content;
    margin-top: 17px;
  }

  .card {
    padding: 17px;
    border-radius: 21px;
  }

  .mode-option span {
    min-height: 116px;
    padding: 13px;
  }

  .batch-actions {
    grid-template-columns: 1fr;
  }

  .result-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-buttons {
    width: 100%;
  }

  .mini-button {
    flex: 1;
  }
}
