/* Shared header, hero, filter-row, and UI-component styles */

:root {
  --ink: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --panel: #ffffff;
  --accent: #475569;
  --accent-hover: #334155;
  --warn: #b91c1c;
  --surface: #f4f4f5;
  --sentence: #52525b;
}

[x-cloak] {
  display: none !important;
}

.page-header {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.hero {
  display: grid;
  gap: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.hero-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.hero-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.hero-mode {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.hero-logo {
  display: inline-flex;
  flex-shrink: 0;
}

.hero-logo img {
  display: block;
  width: 72px;
  height: 72px;
}

.hero-set-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  min-width: 0;
}

.hero-set-inline .hero-select-wrap {
  width: min(12rem, 25vw);
}

.hero-advanced-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
}

.hero-advanced-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

.hero-advanced-btn.active {
  background: #eef2f7;
  color: var(--accent);
  border-color: #cbd5e1;
}

.gear-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-1px);
}

.hero-advanced-panel {
  width: min(38rem, 100%);
  justify-self: end;
  margin: -0.15rem 0 0;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-select-wrap {
  position: relative;
}

.hero-set-selector {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 0.5rem 2.15rem 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hero-set-selector:focus,
.ghost-btn:focus,
.icon-btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.hero-select-wrap::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0.8rem;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem;
  border: none;
  border-right: 1px solid #e7e5e4;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.mode-btn:first-child {
  border-top-left-radius: 9px;
  border-bottom-left-radius: 9px;
}

.mode-btn:last-child {
  border-top-right-radius: 9px;
  border-bottom-right-radius: 9px;
  border-right: none;
}

.mode-btn:hover {
  background: #eef2f7;
  color: var(--ink);
}

.mode-btn.active {
  background: var(--accent);
  color: white;
}

.mode-btn.active:hover {
  background: var(--accent-hover);
  color: white;
}

.mode-link {
  color: var(--ink);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #fafafa);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.toggle-seg {
  padding: 0.45rem 0.72rem;
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}

.toggle-seg:last-child {
  border-right: none;
}

.toggle-seg.active {
  background: var(--accent);
  color: white;
}

.search-inline {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 16rem;
  min-width: 13rem;
  max-width: 23rem;
}

.search-inline svg {
  position: absolute;
  left: 0.75rem;
  width: 0.95rem;
  height: 0.95rem;
  color: var(--muted);
  pointer-events: none;
}

.search-inline input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fafafa);
  padding: 0.48rem 0.72rem 0.48rem 2.1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.search-inline input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 16rem;
  min-width: 12rem;
  margin-left: auto;
  padding: 0.05rem 0;
}

.progress-inline strong {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.progress-meter {
  height: 6px;
  border-radius: 3px;
  background: var(--surface);
  overflow: hidden;
  width: 100%;
}

.progress-inline .progress-meter {
  flex: 1 1 auto;
  min-width: 5.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.ghost-btn-sm {
  padding: 0.42rem 0.62rem;
  font-size: 0.75rem;
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.ghost-btn:hover {
  background: var(--surface);
}

.ghost-btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.ghost-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.advanced-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 0.75rem;
}

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

.advanced-block {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.advanced-block h2 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.advanced-copy {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

.advanced-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.advanced-about {
  align-items: center;
  justify-items: center;
  text-align: center;
  cursor: pointer;
}

.advanced-about-logo {
  width: 80px;
  height: 80px;
  border-radius: 14px;
}

.advanced-about-tagline {
  margin: 0;
  font-size: 0.875rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.3;
}

.advanced-info-btn {
  justify-self: center;
}

.advanced-about-credit {
  display: block;
  margin-top: 0.5rem;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.advanced-about-credit:hover {
  color: var(--accent);
  text-decoration: underline;
}

.reshuffle-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: #555;
}

.reshuffle-btn:hover {
  background: #f0f0f0;
  color: #222;
  border-color: #aaa;
}

/* Auth bar */

/* ---- Account menu (top-right circle + dropdown) ---- */

.account-menu {
  position: relative;
  flex: 0 0 auto;
}

.account-circle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.account-circle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.1);
}

.account-circle.loading {
  cursor: default;
  opacity: 0.4;
}

.account-circle.logged-in {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.account-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  width: min(20rem, calc(100vw - 2rem));
  padding: 0.75rem;
}

.account-identity {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-bottom: 0.25rem;
}

.account-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.account-email {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-divider {
  height: 1px;
  background: var(--line);
  margin: 0.5rem 0;
}

.account-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.25rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.account-link:hover {
  background: var(--surface);
}

.account-anon-info {
  padding-bottom: 0.25rem;
}

.account-anon-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.35rem;
}

.account-anon-detail {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.account-cta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.account-signin-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.account-signin-btn:hover {
  background: var(--surface);
}

.account-signin-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.account-google-btn {
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.account-signin-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.account-or {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.15rem 0;
}

.account-or::before,
.account-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.account-or span {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-magic-form {
  display: flex;
  gap: 0.35rem;
}

.account-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  min-width: 0;
}

.account-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.account-magic-form .account-signin-btn {
  width: auto;
  flex-shrink: 0;
}

.account-message {
  margin: 0;
  font-size: 0.75rem;
  color: var(--accent);
}

.account-error {
  margin: 0;
  font-size: 0.75rem;
  color: var(--warn);
}

.account-merge {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.account-merge-summary {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: var(--ink);
  line-height: 1.5;
}

.account-merge-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.45;
}

.account-merge-actions {
  display: flex;
  gap: 0.35rem;
}

.account-merge-actions .account-signin-btn {
  flex: 1;
}

.account-discard-btn {
  background: transparent;
  color: var(--muted);
}

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

@media (max-width: 640px) {
  .hero {
    gap: 0.7rem;
  }

  .hero-head {
    width: 100%;
    align-items: flex-start;
  }

  .hero-top {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto;
    gap: 0.5rem;
    align-items: center;
  }

  .hero-head {
    display: contents;
  }

  .hero-top {
    display: contents;
  }

  .hero {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
  }

  /* Row 1: logo ... gear account */
  .hero-logo {
    grid-column: 1;
    grid-row: 1;
  }

  .hero-advanced-btn {
    grid-column: 3;
    grid-row: 1;
  }

  .account-menu {
    grid-column: 4;
    grid-row: 1;
  }

  /* Row 2: advanced panel (when open) */
  .hero-advanced-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-self: stretch;
    margin-top: 0;
  }

  /* Row 3+: mode, set span full width */
  .hero-mode {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .hero-mode > .ghost-btn {
    width: 100%;
  }

  .hero-set-inline {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-left: 0;
    width: 100%;
  }

  .hero-set-inline .hero-select-wrap {
    width: 100%;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-btn {
    flex: 1 1 0;
    text-align: center;
    padding: 0.6rem 0.4rem;
    font-size: 0.875rem;
  }

  .toggle-group {
    width: 100%;
    display: flex;
  }

  .toggle-seg {
    flex: 1 1 0;
    padding: 0.6rem 0.5rem;
    font-size: 0.875rem;
    text-align: center;
  }

  .ghost-btn {
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
  }

  .ghost-btn-sm {
    padding: 0.55rem 0.75rem;
    font-size: 0.8125rem;
  }

  .filter-row {
    flex-direction: column;
    gap: 0.35rem;
  }

  .search-inline {
    min-width: 100%;
    max-width: none;
    flex: 0 0 auto;
  }

  .progress-inline {
    min-width: 100%;
    margin-left: 0;
    padding: 0.35rem 0;
    flex: 0 0 auto;
  }
}

/* ---- Welcome modal ---- */

.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.welcome-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2rem 2rem 1.75rem;
  width: min(32rem, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.14);
  text-align: center;
}

.welcome-logo img {
  display: block;
  width: 168px;
  height: 168px;
}

.welcome-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin: 0;
}

.welcome-tagline {
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
  max-width: 26rem;
}

.welcome-features {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  text-align: left;
}

.welcome-features li {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.welcome-features li:last-child {
  border-bottom: none;
}

.welcome-feature-label {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.welcome-feature-desc {
  color: var(--muted);
  line-height: 1.4;
}

.welcome-cta {
  padding: 0.6rem 1.75rem;
  font-size: 0.9375rem;
  border-radius: 6px;
  margin-top: 0.25rem;
}

@media (max-width: 480px) {
  .welcome-overlay {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .welcome-modal {
    padding: 1.25rem 1rem 1rem;
    gap: 0.65rem;
    max-height: calc(100dvh - 3rem);
    overflow-y: auto;
  }

  .welcome-logo img {
    width: 80px;
    height: 80px;
  }

  .welcome-title {
    font-size: 1.2rem;
  }

  .welcome-tagline {
    font-size: 0.85rem;
  }

  .welcome-features li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
  }
}
