/* Vinkällaren – mörk källarstil, mobil först */
:root {
  --bg: #1B1517;
  --bg-header: #1F181A;
  --card: #251D1F;
  --sunken: #1B1517;
  --line: #3A2F31;
  --line-strong: #4A3D3F;
  --input-line: #5A4B4D;
  --text: #F3ECE7;
  --muted: #BBAEA8;
  --faint: #6E6062;
  --gold: #D4B26F;
  --gold-light: #E8CC92;
  --on-gold: #1B1517;
  --wine: #4A2A30;
  --danger-bg: #3A2224;
  --danger: #F4B5A6;
  --danger-line: #7A4A48;
  --ok-bg: #22302A;
  --ok: #CBE8C9;
  --ok-line: #3E5A4A;
  --dot-mine: #4CC38A;
  --dot-other: #F2555A;
  --dot-open: #F2C94C;
  --radius: 16px;
  --display: 'Cormorant Garamond', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
}
a { color: var(--gold); }
a:hover { color: var(--gold-light); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -9999px; top: 8px; }
.skip:focus { left: 16px; z-index: 10; background: var(--gold); color: var(--on-gold); padding: 8px 12px; border-radius: 8px; }

.display { margin: 0; font-family: var(--display); font-size: 40px; font-weight: 600; line-height: 1.1; }
.display--small { font-size: 26px; }
.display a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.note { font-style: italic; }
.gold-text { color: var(--gold); }
.break { overflow-wrap: anywhere; }
.center { text-align: center; }

/* ---------- Header ---------- */
.site-header { background: var(--bg-header); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.site-header__inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold); text-decoration: none; }
.brand span { font-family: var(--display); font-size: 26px; font-weight: 600; color: var(--text); }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav__link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.nav__link:hover { color: var(--text); border-color: var(--gold); }
.nav__link.is-active { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.who { display: flex; align-items: center; gap: 6px; }
.who__profile { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none; font-size: 14px; }
.who form { margin: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--wine);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}

/* ---------- Layout ---------- */
.page {
  max-width: 1120px; margin: 0 auto;
  padding: 32px 16px calc(64px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 24px;
}
.page-intro { display: flex; flex-direction: column; gap: 6px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split__main { flex: 999 1 540px; min-width: 0; }
.split__side { flex: 1 1 320px; min-width: 0; }
.split--even > * { flex: 1 1 360px; min-width: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; display: flex; flex-direction: column; gap: 20px;
}
.split__side.card { padding: 24px; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.stack-start { align-items: flex-start; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-fields { display: flex; flex-wrap: wrap; gap: 12px; }
.row-fields > .field { flex: 1 1 150px; }
.row-fields > .field--grow { flex: 2 1 180px; }
.row-fields > .field--narrow { flex: 0 1 120px; }
.field--narrow { max-width: 160px; }
.list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }

/* ---------- Formulär ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field label, .field legend { font-size: 13px; font-weight: 500; color: var(--muted); padding: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--sunken); border: 1px solid var(--input-line); border-radius: 10px;
  color: var(--text); font: 16px var(--sans);
}
textarea { padding: 12px 14px; line-height: 1.5; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23BBAEA8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.code-input { letter-spacing: 0.08em; text-transform: uppercase; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14px; }
.check input, .choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 10px; border: 1px solid transparent;
  font: 600 15px var(--sans); text-decoration: none; cursor: pointer; text-align: center;
}
.btn--primary { background: var(--gold); color: var(--on-gold); }
.btn--primary:hover { background: var(--gold-light); color: var(--on-gold); }
.btn--outline { background: transparent; color: var(--gold); border-color: var(--gold); }
.btn--outline-neutral { background: transparent; color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger-line); font-weight: 500; }
.btn--small { min-height: 44px; padding: 0 14px; font-size: 14px; }
.link-button {
  background: none; border: none; padding: 0 6px; min-height: 44px; display: inline-flex; align-items: center;
  color: var(--gold); font: 14px var(--sans); text-decoration: underline; cursor: pointer;
}
.link-button--danger { color: var(--danger); }
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px;
  font: 20px var(--sans); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--gold); }
.icon-btn.is-disabled, .icon-btn:disabled { opacity: 0.35; cursor: default; }

.alert { margin: 0; padding: 12px 14px; background: var(--danger-bg); border-radius: 10px; color: var(--danger); font-size: 14px; }
.notice { margin: 0; padding: 12px 14px; background: var(--ok-bg); border-radius: 10px; color: var(--ok); font-size: 14px; }
.flash {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border-radius: 12px; border: 1px solid;
}
.flash--success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.flash--error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.flash__close { min-width: 44px; min-height: 44px; margin: -10px -8px; background: none; border: none; color: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.badge--gold { background: var(--gold); color: var(--on-gold); font-weight: 600; }
.badge--gold-soft { background: #3A3020; color: var(--gold-light); }
.badge--open { background: var(--ok-bg); color: var(--ok); }
.badge--private { background: var(--danger-bg); color: var(--danger); font-weight: 600; }

/* ---------- Inloggning ---------- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: calc(48px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px 32px; display: flex; flex-direction: column; gap: 20px;
}
.auth-card__brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--gold); }
.auth-card__brand h1 { color: var(--text); }
.auth-card__intro { display: flex; flex-direction: column; gap: 8px; }
.auth-card__intro .display { font-size: 34px; }
.auth-card__links { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; text-align: center; }
.auth-card__links a { min-height: 36px; display: inline-flex; align-items: center; }
.error-card { align-items: flex-start; }

/* ---------- Bokning ---------- */
.step { display: flex; flex-direction: column; gap: 10px; border: 0; padding: 0; margin: 0; min-width: 0; }
.step__title { margin: 0 0 2px; padding: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.calendar { padding: 16px; background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 12px; }
.calendar__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.calendar__month { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 600; }
.calendar__weekdays, .calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar__weekdays { text-align: center; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.day {
  min-height: 52px; padding: 4px 0; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text); text-decoration: none; font-size: 16px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.day:hover { color: var(--text); border-color: var(--gold); }
.day.is-today { border-color: var(--gold); }
.day.is-selected { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.day.is-disabled { border-color: transparent; background: none; color: var(--faint); }
.dots { display: flex; gap: 3px; min-height: 7px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot--mine { background: var(--dot-mine); }
.dot--other { background: var(--dot-other); }
.dot--open { background: var(--dot-open); }
.is-selected .dot--mine { background: #1E6B3C; }
.is-selected .dot--other { background: #A4161A; }
.is-selected .dot--open { background: #FFF1C9; box-shadow: 0 0 0 1px #7A5A12; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.day-list { padding: 14px 16px; background: var(--bg-header); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; }
.day-list__title { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.day-list__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }

.choice-row { display: flex; flex-wrap: wrap; gap: 12px; }
.choice {
  flex: 1 1 220px; padding: 16px; background: var(--sunken); border: 2px solid var(--line); border-radius: 12px;
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
}
.choice input { margin-top: 2px; }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice:has(input:checked) { border-color: var(--gold); background: #2C2320; }

.rules { padding: 16px; background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; }
.rules ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.submit-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); }

.upcoming { padding: 12px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.upcoming__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.upcoming__top a { color: var(--text); text-decoration: none; }

.join { margin-top: 4px; }
.join summary { list-style: none; display: inline-flex; }
.join summary::-webkit-details-marker { display: none; }
.join[open] summary { display: none; }
.join__form { margin-top: 8px; padding: 12px; background: var(--sunken); border: 1px solid var(--gold); border-radius: 12px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.join__form .field { flex: 1 1 200px; }
.joined { display: flex; align-items: center; gap: 8px; }
.joined form { margin: 0; }
.day-list__row form, .upcoming form, .wine__actions form, .member__actions form { margin: 0; }

.booking-card { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; }
.booking-card__info { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Vinskåp ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip > span, .chip-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); font-size: 14px; cursor: pointer; text-decoration: none;
}
.chip-link:hover { color: var(--text); border-color: var(--gold); }
.chip input:checked + span, .chip-link.is-active { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.wine-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.wine-dot--big { width: 12px; height: 12px; margin-top: 6px; }
.wine-dot--rott { background: #C24A5A; }
.wine-dot--vitt { background: #E8D9A0; }
.wine-dot--rose { background: #EFA3B0; }
.wine-dot--mousserande { background: #BFE0E6; }
.wine-dot--sott { background: #E0A64A; }
.wine-dot--ovrigt { background: #9A8F8B; }
.search { display: flex; gap: 8px; }
.search input { flex: 1 1 auto; }
.list-empty { padding: 16px 0; border-top: 1px solid var(--line); }
.wine-list, .member-list { list-style: none; margin: 0; padding: 0; }
.wine { padding: 16px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; scroll-margin-top: 16px; }
.wine__info { flex: 1 1 260px; min-width: 0; display: flex; align-items: flex-start; gap: 12px; }
.wine__info > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wine__name { font-size: 16px; }
.wine__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wine__count { min-width: 52px; text-align: center; font-weight: 600; }

/* ---------- Admin ---------- */
.member { padding: 14px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.member__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.member__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

/* ---------- Mobil och surfplatta ---------- */
@media (max-width: 720px) {
  .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 600px) {
  .display { font-size: 32px; }
  .display--small { font-size: 24px; }
  .page { padding-top: 20px; gap: 18px; }
  .card, .split__side.card { padding: 18px; border-radius: 14px; }
  .booking-card { padding: 18px; }
  .auth-card { padding: 28px 20px; }
  .calendar { padding: 10px; }
  .calendar__weekdays, .calendar__grid { gap: 4px; }
  .day { min-height: 44px; border-radius: 8px; font-size: 15px; }
  .btn--wide { width: 100%; }
}
@media (max-width: 420px) {
  .who__name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
