:root {
  color-scheme: light dark;
  --bg: #0f1216;
  --panel: #171b21;
  --border: #2a2f38;
  --text: #e7eaee;
  --muted: #9aa4b2;
  --accent: #4f8cff;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 2rem 1rem 4rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

p.subtitle {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input, select, textarea {
  width: 100%;
  background: #10141a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  /* Must stay at 16px or larger. iOS Safari zooms the whole page in when
     you focus an input with smaller text, and it does not zoom back out --
     which reads as the page breaking rather than as a font size. */
  font-size: 1rem;
  min-height: 44px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 5.5rem;
}

.field {
  margin-bottom: 0.85rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.1rem;
  font-size: 1rem;
  min-height: 44px;
  cursor: pointer;
  margin: 0.25rem 0.5rem 0.25rem 0;
}

button:hover {
  filter: brightness(1.08);
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

details summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

#status {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.75rem 0;
}

#status.error {
  color: var(--danger);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.spec-row span:first-child {
  color: var(--muted);
}

.links li {
  margin-bottom: 0.4rem;
}

.links a {
  color: var(--accent);
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

.links .query-note {
  list-style: none;
  margin: 0 0 1rem -1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.links .query-note label {
  color: var(--muted);
  font-size: 0.85rem;
}

.links .query-note input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.links .query-note .hint {
  color: var(--muted);
  font-size: 0.78rem;
}

footer {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 2rem;
}

/* ---------------------------------------------------------------------
   Fallback panel: shown when a server lookup fails/times out. Points at
   the bookmarklet, which works for every part with no server involved.
   --------------------------------------------------------------------- */

.fallback {
  border-color: var(--accent);
}

.fallback h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.fallback-actions {
  margin-bottom: 0.5rem;
}

.bookmarklet-row {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  margin-top: 0.5rem;
}

/* A bookmarklet link must look and behave like a normal link (draggable,
   plain anchor) rather than a button, or dragging it to the bookmarks bar
   doesn't work the way people expect. */
.bookmarklet-link {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  min-height: 44px;
  line-height: 1.6rem;
  cursor: grab;
}

.bookmarklet-row .hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.6rem 0 0;
  line-height: 1.4;
}

#installPanel summary {
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------------
   Results panel
   --------------------------------------------------------------------- */

.result-header h2 {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.15rem 0;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

#resultMeta {
  margin: 0.4rem 0 0.9rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 1.1rem;
}

.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  min-height: 36px;
  cursor: pointer;
  margin: 0;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

h3 {
  font-size: 1rem;
  margin: 1.1rem 0 0.4rem;
}

.spec-group {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0.9rem 0 0.2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2rem;
}

#specsDetails {
  margin-top: 1.1rem;
}

#specsDetails summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------------
   Recent
   --------------------------------------------------------------------- */

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  min-height: 44px;
  text-align: left;
  cursor: pointer;
  margin: 0;
}

.recent-item:hover {
  border-color: var(--accent);
}

.recent-part {
  font-weight: 600;
  font-size: 0.92rem;
}

.recent-desc {
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------
   Phone width: keep every panel and its contents inside the viewport --
   long spec values, URLs and titles all get to wrap instead of forcing
   horizontal scroll.
   --------------------------------------------------------------------- */

.spec-row span,
.links a,
#resultCategory,
#resultTitle {
  overflow-wrap: anywhere;
}

@media (max-width: 420px) {
  .grid {
    grid-template-columns: 1fr;
  }
}
