:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --text: #18181b;
  --text-2: #71717a;
  --text-3: #a1a1aa;
  --border: #e4e4e7;
  --border-subtle: #f0f0ee;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.07);
  --btn-bg: #18181b;
  --btn-text: #ffffff;
  --btn-hover: #27272a;
  --brand: #f5c542;
  --success: #2f9e44;
  --success-bg: #e8f7ec;
  --danger: #b00020;
}

[data-theme="dark"] {
  --bg: #111110;
  --surface: #1c1c1a;
  --surface-2: #242422;
  --text: #fafaf9;
  --text-2: #a8a29e;
  --text-3: #78716c;
  --border: #2c2c2a;
  --border-subtle: #242422;
  --shadow-sm:
    0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-md:
    0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --btn-bg: #fafaf9;
  --btn-text: #111110;
  --btn-hover: #e7e5e4;
  --success: #5bd97a;
  --success-bg: rgba(91, 217, 122, 0.12);
  --danger: #ff6b81;
}

* {
  box-sizing: border-box;
}
html {
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner {
  max-width: 700px;
  margin: 0 auto;
  min-height: 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
}
.site-header .logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.site-header .logo:hover {
  opacity: 0.7;
}
.logo-icon {
  display: block;
  height: 2.1rem;
  width: 2.1rem;
  border-radius: 22%;
  flex-shrink: 0;
}
.logo-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.0625rem;
  line-height: 1.15;
}
.logo-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand);
}
.logo-tagline {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-3);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.header-nav a {
  color: var(--text-2);
  text-decoration: none;
}
.header-nav a:hover {
  color: var(--text);
}
.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  min-height: unset;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition:
    background 0.15s,
    color 0.15s;
}
.header-icon-btn:hover {
  background: var(--border-subtle);
  color: var(--text);
  box-shadow: none;
}

.icon-sun {
  display: none;
}
.icon-moon {
  display: block;
}
[data-theme="dark"] .icon-sun {
  display: block;
}
[data-theme="dark"] .icon-moon {
  display: none;
}

/* Account menu */
.hh-menu {
  position: relative;
}
.hh-menu > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  user-select: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.hh-menu > summary::-webkit-details-marker {
  display: none;
}
.hh-menu > summary:hover {
  background: var(--border-subtle);
  color: var(--text);
}
.hh-chevron {
  opacity: 0.5;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.hh-menu[open] .hh-chevron {
  transform: rotate(180deg);
}
.hh-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  min-width: 12rem;
  z-index: 200;
  overflow: hidden;
}
.hh-dropdown-section {
  padding: 0.75rem;
}
.hh-dropdown-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.375rem;
}
.hh-dropdown-section div:last-child {
  word-break: break-all;
}
.hh-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
}
.hh-dropdown .hh-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  min-height: unset;
  letter-spacing: 0;
  box-shadow: none;
  text-decoration: none;
  transition: background 0.1s;
}
.hh-dropdown .hh-menu-item:hover {
  background: var(--border-subtle);
  box-shadow: none;
}
.hh-dropdown .hh-logout {
  color: #e11d48;
}
.hh-dropdown .hh-logout:hover {
  background: #fff1f2;
  box-shadow: none;
}
[data-theme="dark"] .hh-dropdown .hh-logout:hover {
  background: rgba(225, 29, 72, 0.1);
}

/* Layout */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
}

h1 {
  margin-top: 0;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--text);
}
h2 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  margin: 1.5rem 0 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Panels */
.panel {
  background: var(--surface);
  border-radius: 14px;
  padding: 1.375rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="number"] {
  width: 100%;
  font-size: 0.9375rem;
  font-family: inherit;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  min-height: 2.375rem;
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  outline: none;
}
input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}
[data-theme="dark"] input:focus {
  box-shadow: 0 0 0 3px rgba(250, 250, 249, 0.1);
}

button {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  min-height: 2.375rem;
  border-radius: 8px;
  border: 1.5px solid transparent;
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition:
    background 0.15s,
    opacity 0.15s,
    box-shadow 0.15s;
}
button:hover {
  background: var(--btn-hover);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
button:active {
  opacity: 0.8;
}

form.lookup {
  display: flex;
  gap: 0.5rem;
}
form.lookup input[type="text"] {
  flex: 1;
  font-size: 1.1rem;
}
form.lookup button {
  font-size: 1.1rem;
  padding: 0.6rem 1rem;
}

.error {
  color: var(--danger);
}
p.hint {
  color: var(--text-2);
  font-size: 0.9rem;
}

/* My sets */
.my-sets-list {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 0.75rem;
  margin: 1rem 0;
}
@media (max-width: 480px) {
  .my-sets-list {
    grid-template-columns: 1fr;
  }
}
.my-set-card {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
  min-width: 0;
}
.my-set-card:hover {
  box-shadow: var(--shadow-md);
}
.my-set-card img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
}
.my-set-info {
  flex: 1;
  min-width: 0;
}
.my-set-name {
  font-weight: 600;
}
.my-set-meta {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

/* Set header */
.back-link {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--text-2);
  text-decoration: none;
  margin-bottom: 0.75rem;
}
.back-link:hover {
  color: var(--text);
}

.set-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.set-photo {
  background: #ffffff;
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  line-height: 0;
}
.set-photo img {
  display: block;
  width: 76px;
  height: 76px;
  object-fit: contain;
}
.set-header-info {
  flex: 1;
  min-width: 0;
}
.set-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.part-list-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
.btn-text {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.25rem;
  min-height: unset;
}
.btn-text:hover {
  background: none;
  box-shadow: none;
  color: var(--text);
  text-decoration: underline;
}
.part-list.hide-completed .part-row.complete {
  display: none;
}

/* Summary */
.summary {
  margin: 1rem 0;
}
.summary-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.summary-stats strong {
  font-size: 1.1rem;
}
.progress-bar {
  background: var(--border-subtle);
  border-radius: 999px;
  height: 0.75rem;
  overflow: hidden;
}
.progress-fill {
  background: var(--success);
  height: 100%;
  transition: width 0.2s ease;
}
.progress-label {
  font-size: 0.85rem;
  color: var(--text-2);
  margin-top: 0.25rem;
  text-align: right;
}

/* Part list */
.part-list {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.color-group-label {
  padding: 0.4rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-subtle);
}
.part-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.part-row:last-child {
  border-bottom: none;
}
.part-row.complete {
  background: var(--success-bg);
}
.part-row img.part {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
  cursor: zoom-in;
}
.part-info {
  flex: 1;
  min-width: 0;
}
.part-info .part-name {
  font-weight: 600;
}
.part-info .part-meta {
  color: var(--text-2);
  font-size: 0.9rem;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.stepper button {
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.5rem;
  line-height: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.stepper button:hover {
  background: var(--surface-2);
  box-shadow: none;
}
.stepper button:active {
  background: var(--border-subtle);
  opacity: 1;
}
.stepper button:disabled {
  opacity: 0.35;
}
.stepper .count {
  min-width: 2.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .part-row {
    flex-wrap: wrap;
  }
  .stepper {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}
.modal-overlay.open {
  display: flex;
}
.modal-content {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
}
.modal-content img {
  max-width: 80vw;
  max-height: 60vh;
  object-fit: contain;
}
.modal-caption {
  margin-top: 0.75rem;
  color: var(--text-2);
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  min-height: unset;
  box-shadow: none;
}

/* Color search */
.part-row.color-mismatch {
  display: none;
}
.color-search-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.color-search-overlay.visible {
  opacity: 1;
}
.color-search-overlay-text {
  background: rgba(0, 0, 0, 0.78);
  color: #ffffff;
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 1.25rem 2.25rem;
  border-radius: 20px;
  text-transform: uppercase;
  max-width: 90vw;
  text-align: center;
  word-break: break-word;
}
.color-search-status {
  display: none;
  align-items: center;
  gap: 0.35rem;
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  z-index: 900;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.color-search-status.visible {
  display: flex;
}
.color-search-status strong {
  color: var(--text);
  text-transform: uppercase;
}

/* Footer */
.site-footer {
  margin-top: 1rem;
  padding: 2.5rem 1rem 3rem;
  border-top: 1px solid var(--border-subtle);
}
.footer-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  text-align: center;
}
.footer-tagline {
  font-size: 0.875rem;
  color: var(--text-2);
  margin: 0;
  max-width: 34rem;
  line-height: 1.65;
}
.footer-meta {
  font-size: 0.8rem;
  color: var(--text-3);
  margin: 0;
}
.footer-meta a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-meta a:hover {
  color: var(--text);
}
.footer-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.footer-badges img {
  display: block;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.footer-badges a:hover img {
  opacity: 1;
}

/* Gate page (sign-in) */
body.gate-page {
  background: var(--brand);
  min-height: 100vh;
}
body.gate-page .site-header {
  background: transparent;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}
body.gate-page .site-header .logo-title {
  color: white;
}
body.gate-page .site-header .logo-tagline {
  color: rgba(255, 255, 255, 0.85);
}
body.gate-page .site-footer {
  border-top-color: rgba(255, 255, 255, 0.2);
}
body.gate-page .footer-tagline,
body.gate-page .footer-meta,
body.gate-page .site-footer a {
  color: rgba(255, 255, 255, 0.95);
}
