:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2d2a26;
  --muted: #8a8178;
  --accent: #e8622c;
  --accent-dark: #cf5021;
  --green: #2e9e5b;
  --blue: #3a7bd5;
  --red: #d64545;
  --border: #ece5db;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(45, 42, 38, .07);
}

* { box-sizing: border-box; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5;
  padding-bottom: 110px;
}
.muted { color: var(--muted); }
.small { font-size: .82rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 1.15rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 32px 20px; }
.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-size: 2rem; margin-bottom: 8px; }
.hero p { margin-bottom: 20px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 9px 16px; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: .15s;
}
.btn:hover { border-color: #d8cfc2; transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.big { font-size: 1.05rem; padding: 13px 26px; border-radius: 12px; }
.btn.small { font-size: .8rem; padding: 5px 10px; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; justify-content: center; }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  position: relative; background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: .15s;
  display: flex; flex-direction: column;
}
.card.checked { border-color: var(--accent); box-shadow: 0 4px 16px rgba(232, 98, 44, .18); }
.card.card-error { opacity: .75; }
.card-body { cursor: pointer; display: block; flex: 1; }
.card-check { position: absolute; opacity: 0; pointer-events: none; }
.check-badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; border: 2px solid var(--border);
  transition: .15s;
}
.card.checked .check-badge { background: var(--accent); border-color: var(--accent); color: #fff; }

.card-img { position: relative; aspect-ratio: 4/3; background: #f0e9de; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img-placeholder {
  width: 100%; height: 100%; display: flex;
  align-items: center; justify-content: center; font-size: 3rem;
}
.badge {
  position: absolute; left: 10px; bottom: 10px;
  font-size: .7rem; font-weight: 700; color: #fff;
  padding: 4px 9px; border-radius: 20px; backdrop-filter: blur(4px);
}
.badge-mealie { background: rgba(46, 158, 91, .92); }
.badge-web { background: rgba(58, 123, 213, .92); }

.card-text { padding: 12px 14px 14px; }
.card-text h3 { font-size: .98rem; line-height: 1.3; margin-bottom: 4px; }
.card-error-msg { color: var(--red); font-size: .8rem; }
.source-link { font-size: .75rem; color: var(--blue); text-decoration: none; }
.source-link:hover { text-decoration: underline; }
.card .regen { margin: 0 10px 10px; align-self: flex-end; }

.action-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 18px; z-index: 60;
  display: flex; align-items: center; gap: 18px;
  background: rgba(45, 42, 38, .94); color: #fff;
  padding: 12px 20px; border-radius: 40px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25); backdrop-filter: blur(6px);
  max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center;
}
.action-bar .btn.primary { border-radius: 30px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 40px 36px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-card .logo { font-size: 2.6rem; }
.login-card input {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; background: var(--bg);
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.error-box {
  background: #fdecea; color: var(--red); border: 1px solid #f5c6c4;
  border-radius: 10px; padding: 12px 16px; margin: 12px 0; font-size: .9rem;
}

.progress-card {
  max-width: 640px; margin: 40px auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px;
}
.progress-card h2 { margin-bottom: 16px; }
.progress-card h3 { margin: 18px 0 8px; font-size: 1rem; }
.steps { list-style: none; padding: 0; }
.steps li { padding: 5px 0; font-size: .9rem; border-bottom: 1px dashed var(--border); }
.steps-details { margin-top: 16px; font-size: .85rem; }
.result-list { list-style: none; padding: 0; }
.result-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.result-list .badge { position: static; }
.result-list.failures li { color: var(--red); font-size: .88rem; }
.result-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.spinner {
  width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, .4);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .8s linear infinite; display: inline-block;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { display: inline-block; }
.big-spinner {
  width: 34px; height: 34px; margin: 22px auto 0;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
button.regen .spinner { border-color: var(--border); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .hero h1 { font-size: 1.5rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .action-bar { gap: 10px; font-size: .85rem; padding: 10px 14px; }
}
