:root {
  --bg:          #0f0f1a;
  --surface:     #1a1a2e;
  --surface2:    #16213e;
  --border:      #2a2a4a;
  --accent:      #e94560;
  --text:        #e0e0e0;
  --muted:       #8888aa;
  --input-bg:    #0a0a14;
  --success:     #4caf50;
  --success-dim: rgba(76, 175, 80, 0.12);
  --error:       #f44336;
  --error-dim:   rgba(244, 67, 54, 0.12);
  --info:        #42a5f5;
  --info-dim:    rgba(66, 165, 245, 0.10);
}

:root[data-theme="light"] {
  --bg:          #f4f5fa;
  --surface:     #ffffff;
  --surface2:    #eceef5;
  --border:      #d7d9e6;
  --accent:      #d6294a;
  --text:        #1a1a2e;
  --muted:       #6b6b85;
  --input-bg:    #eceef5;
  --success:     #2e7d32;
  --success-dim: rgba(46, 125, 50, 0.12);
  --error:       #c62828;
  --error-dim:   rgba(198, 40, 40, 0.12);
  --info:        #1976d2;
  --info-dim:    rgba(25, 118, 210, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  background: var(--surface2);
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.header-bar {
  max-width: 32rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-titles {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.app-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.app-sub {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--border);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.94);
}

main {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.search-box {
  margin: 0.75rem 0;
}

#initial-load {
  margin: 0.75rem 0 0;
  text-align: center;
}

#initial-load .status-text {
  min-height: 0;
}

#initial-load .primary-btn {
  margin-top: 0.75rem;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

.search-box input[type="search"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
}

.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}

ul.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.result-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.result-row:active { transform: scale(0.99); }

.result-row .mark {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.result-row .model {
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

li.empty {
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0 0.5rem;
}

.section-heading h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0;
}

button {
  font: inherit;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-left: 0.4rem;
  font-size: inherit;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 1.5rem;
}

.card-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 14px;
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 13px 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.primary-btn:active:not(:disabled) { opacity: 0.8; }
.primary-btn:disabled { opacity: 0.6; cursor: default; }

.status-text {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.meta-text {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

#detail,
#settings-view {
  padding-top: 1rem;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  padding: 0.4rem 0;
  cursor: pointer;
}

.view-title {
  font-size: 1.6rem;
  letter-spacing: 0.03em;
  margin: 0.5rem 0 1rem;
}

#detail-body dl {
  margin: 0;
  border-top: 1px solid var(--border);
}

#detail-body dt {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 0.7rem;
}

#detail-body dd {
  margin: 0.1rem 0 0;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .sr-info { flex: 1; }
.settings-row .sr-label { font-size: 0.9rem; }
.settings-row .sr-hint { font-size: 0.73rem; color: var(--muted); margin-top: 2px; }

.settings-row select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 28px 10px 12px;
  width: 88px;
  text-align: right;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238888aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.settings-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.changelog-wrap {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.changelog-wrap summary {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 10px 14px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}
.changelog-wrap summary::-webkit-details-marker { display: none; }
.changelog-wrap summary::after {
  content: '›';
  font-size: 1rem;
  transition: transform 0.2s;
  display: inline-block;
}
.changelog-wrap[open] summary::after { transform: rotate(90deg); }

.changelog-content {
  padding: 0 14px 14px;
}

.cl-version { margin-bottom: 12px; }
.cl-version:last-child { margin-bottom: 0; }

.cl-version-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.cl-ver {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.cl-date {
  font-size: 0.7rem;
  color: var(--muted);
}

.cl-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cl-items li {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 2px 0 2px 12px;
  position: relative;
  line-height: 1.5;
}

.cl-items li::before {
  content: '–';
  position: absolute;
  left: 0;
}

.cl-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem;
}
