:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #6b7370;
  --primary: #1f6f43;
  --primary-dark: #185936;
  --danger: #b3392f;
  --border: #e3e1db;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}
.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.nav-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}
.nav-link:hover { color: var(--primary); }
.inline-form { display: inline; margin: 0; }
.nav-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

main.container { padding-top: 1.5rem; padding-bottom: 3rem; }

.page-title { font-size: 1.3rem; margin: 0 0 1rem; }

/* Produktgrid – anpassar sig till fönsterbredden */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
a.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.card-image {
  display: block;
  aspect-ratio: 4 / 3;
  background: #edece8;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-body { padding: 0.7rem 0.85rem 0.85rem; }
.card-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-price { color: var(--primary); font-weight: 700; margin-top: 0.15rem; }

/* Produktsida */
.product {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 760px) {
  .product { grid-template-columns: 1fr; }
}
.product-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.product-info h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.product-price { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 0 0 1rem; }
.product-description { white-space: pre-line; margin: 0 0 1rem; }
.product-meta { color: var(--muted); font-size: 0.85rem; }
.product-meta a { color: var(--muted); }

/* Formulär */
.auth-box {
  max-width: 460px;
  margin: 1rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-box h1 { margin-top: 0; font-size: 1.4rem; }
.auth-box label { display: block; font-weight: 600; margin: 1rem 0 0.3rem; }
.auth-box input[type="text"],
.auth-box input[type="email"],
.auth-box input[type="number"],
.auth-box input[type="file"],
.auth-box textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--bg);
}
.auth-box textarea { resize: vertical; }
.auth-box .btn { margin-top: 1.25rem; width: 100%; }
.pin-input {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
}
.required { color: var(--danger); font-weight: 400; font-size: 0.85rem; }
.optional { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.error {
  background: #fbe9e7;
  border: 1px solid #f0c4bf;
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}

/* Knappar */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

/* Waiting state while a form is being submitted */
button.is-loading {
  cursor: progress;
  opacity: 0.85;
}
button.is-loading:disabled { cursor: progress; }
.spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.5em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
}
.link-button.danger { color: var(--danger); }
.resend-form { margin-top: 1rem; text-align: center; }

/* Visningsnamn */
.name-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.name-box h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.name-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.name-form input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--bg);
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.35rem 0 0; }
.notice {
  background: #e7f3ec;
  border: 1px solid #bcdcc8;
  color: var(--primary-dark);
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  margin: 0.6rem 0 0;
}
.seller { font-weight: 600; color: var(--text); }

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--surface);
}
