/* =========================================================================
   Whiskykalendern – stil
   ========================================================================= */

:root {
  color-scheme: dark;
  --bg: #0e0a09;
  --ink: #f7efe4;
  --muted: #cdbca7;
  --faint: #9c8a76;
  --gold: #d8a446;
  --gold-hi: #f4d48a;
  --gold-lo: #9c6f22;
  --panel: rgba(24, 17, 14, 0.84);
  --panel-solid: #1c1411;
  --panel-2: #241915;
  --line: rgba(244, 212, 138, 0.18);
  --line-strong: rgba(244, 212, 138, 0.34);
  --field: rgba(255, 255, 255, 0.05);
  --field-line: rgba(244, 212, 138, 0.26);
  --ok: #8fd19e;
  --warn: #efbe6a;
  --bad: #f08a7c;
  --radius: 16px;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", "URW Palladio L", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  overflow-x: hidden;
}
main { flex: 1; outline: none; }
a { color: var(--gold-hi); }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Bakgrund ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #120c0a;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.bg.ready { opacity: 1; }
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(14, 10, 9, 0.05), rgba(14, 10, 9, 0.45) 80%),
    linear-gradient(180deg, rgba(14, 10, 9, 0.18), rgba(14, 10, 9, 0.32));
}
body:not([data-view="calendar"]) .bg::after { background: rgba(14, 10, 9, 0.78); }

/* ---------- Toppen ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(14, 10, 9, 0.9), rgba(14, 10, 9, 0.62));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark img { display: block; width: 32px; height: 32px; }
.brand-text { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.brand-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-family: var(--serif); font-size: 21px; letter-spacing: 0.02em; }
.brand-year { flex: none; font-family: var(--serif); font-size: 19px; color: var(--gold-hi); }
.brand-mark { flex: none; }
/* Smala mobiler: krymp loggan, namnet och inloggningsknappen så att allt får plats på en rad */
@media (max-width: 440px) {
  .topbar { gap: 8px; }
  .brand { gap: 8px; }
  .brand-mark img { width: 28px; height: 28px; }
  .brand-title { font-size: 18px; letter-spacing: 0; }
  .brand-year { display: none; }
  .btn-login { min-height: 38px; padding: 7px 14px; gap: 6px; font-size: 14px; }
  .btn-login .icon svg { width: 16px; height: 16px; }
}
@media (max-width: 360px) {
  .btn-login .icon { display: none; }
}
@media (max-width: 340px) {
  .brand-mark img { width: 24px; height: 24px; }
  .brand-title { font-size: 16px; }
}

.topnav { display: none; gap: 2px; }
@media (min-width: 860px) { .topnav { display: flex; } }
.navlink {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.navlink:hover { color: var(--ink); background: rgba(244, 212, 138, 0.08); }
.navlink.active { color: var(--ink); background: rgba(244, 212, 138, 0.14); }

.account { position: relative; flex: none; }
.btn-login .icon svg { width: 18px; height: 18px; display: block; }

.user-menu { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.user-btn:hover { background: rgba(244, 212, 138, 0.1); }
.user-btn .chev svg { width: 16px; height: 16px; display: block; color: var(--muted); }
.user-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .user-name { display: none; } }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(150deg, #a3302f, #5e1518);
  box-shadow: inset 0 0 0 1px rgba(244, 212, 138, 0.45);
  color: var(--gold-hi);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  flex: none;
}
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 230px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 8px; font-size: 14px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(244, 212, 138, 0.1); outline: none; }
.menu-item.active { color: var(--gold-hi); }

/* ---------- Knappar ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-gold {
  background: linear-gradient(180deg, #f3cd78, #c9923b);
  color: #24160a;
  box-shadow: 0 6px 18px rgba(201, 146, 59, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.07); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--field-line);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) { background: rgba(244, 212, 138, 0.1); }
.btn-danger { background: #9e2b2b; color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn-danger-ghost { color: var(--bad); border-color: rgba(240, 138, 124, 0.35); }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-block { width: 100%; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ---------- Kalendern: en bild att leta i ---------- */

body[data-view="calendar"] { height: 100vh; height: 100dvh; overflow: hidden; }
body[data-view="calendar"] main { display: flex; flex-direction: column; min-height: 0; }
body[data-view="calendar"] .footer { display: none; }
body[data-view="calendar"] .bg { filter: blur(24px) brightness(0.55); transform: scale(1.12); }

.notice {
  display: inline-block;
  margin: 14px 0 0;
  padding: 6px 14px;
  border: 1px solid rgba(239, 190, 106, 0.45);
  border-radius: 999px;
  background: rgba(239, 190, 106, 0.12);
  color: var(--warn);
  font-size: 14px;
}
.notice-inline { display: block; border-radius: 12px; }

/* Välkomstsida för den som inte är inloggad */
body[data-view="welcome"] .bg::after {
  background: radial-gradient(ellipse at 50% 45%, rgba(14, 10, 9, 0.35), rgba(14, 10, 9, 0.7) 75%);
}
.welcome { display: grid; place-items: center; min-height: calc(100dvh - 140px); padding: 32px 16px; }
.welcome-card { max-width: 440px; text-align: center; padding: 30px 26px 28px; }
.welcome-icon { width: 64px; margin: 0 auto 6px; }
.welcome-icon svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 18px rgba(217, 139, 43, 0.45)); }
.welcome-card h1 { margin: 0 0 8px; color: var(--gold-hi); font-size: clamp(28px, 6vw, 40px); line-height: 1.1; }
.welcome-card p { margin: 0 0 20px; color: var(--ink); }
.welcome-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.scene { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.viewer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.viewer.is-panning { cursor: grabbing; }
.board {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: var(--bg) center / 100% 100% no-repeat;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}

/* En lucka är en utstansad bit av bilden med perforerad kant */
.door {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  perspective: 520px;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
}
.door:focus-visible { outline: none; }
.door-inside {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: 3px;
  background: radial-gradient(circle at 50% 40%, #3d2617, #0d0705 80%);
  box-shadow: inset 0 6px 16px rgba(0, 0, 0, 0.85), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.door-inside img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.inside-glass { position: absolute; left: 24%; right: 24%; top: 50%; display: block; transform: translateY(-50%); }
.inside-glass svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 3px 10px rgba(217, 139, 43, 0.5)); }
.door-panel {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(0.3, 0.75, 0.25, 1);
}
.door-front, .door-back {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.door-front {
  display: grid;
  place-items: center;
  background-image: var(--bg);
  background-repeat: no-repeat;
  background-origin: border-box;
  border: 1px dashed rgba(255, 243, 222, 0.3);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}
.door-num {
  color: rgba(255, 238, 205, 0.6);
  font-family: var(--serif);
  font-size: 20px;
  font-size: 24cqw;
  font-weight: 500;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.door-back {
  transform: rotateY(180deg);
  background: linear-gradient(90deg, #bfa77b, #e4d3ae 55%, #c8b287);
  box-shadow: inset 0 0 0 1px rgba(90, 60, 30, 0.4);
}
.door:focus-visible .door-front {
  border-color: rgba(255, 228, 165, 0.8);
  box-shadow: 0 0 14px rgba(255, 210, 130, 0.35);
  filter: brightness(1.06);
}
@media (hover: hover) {
  .door:hover .door-front {
    border-color: rgba(255, 228, 165, 0.8);
    box-shadow: 0 0 14px rgba(255, 210, 130, 0.35);
    filter: brightness(1.06);
  }
}
.door.is-open { z-index: 2; }
.door.is-open .door-panel { transform: rotateY(-110deg); }
.door.shake .door-panel { animation: door-shake 0.55s ease; }
.door.flash .door-front { animation: door-flash 1s ease-in-out 3; }
.door-eve .door-front { border-color: rgba(244, 212, 138, 0.42); }
.door-eve .door-num { color: rgba(255, 227, 160, 0.72); }
.door-resize { display: none; }

@keyframes door-shake {
  0%, 100% { transform: rotateY(0); }
  20% { transform: rotateY(-12deg); }
  40% { transform: rotateY(4deg); }
  60% { transform: rotateY(-7deg); }
  80% { transform: rotateY(2deg); }
}
@keyframes door-flash {
  50% {
    border-color: #ffe7a8;
    box-shadow: 0 0 0 3px rgba(255, 231, 168, 0.9), 0 0 36px rgba(255, 210, 130, 0.85);
    filter: brightness(1.25);
  }
}

/* Admin: flytta luckor */
.scene.editing .viewer { cursor: default; }
.scene.editing .door { cursor: move; touch-action: none; }
.scene.editing .door .door-panel { transform: none; transition: none; }
.scene.editing .door-front {
  border: 2px solid rgba(255, 226, 160, 0.95);
  box-shadow: inset 0 0 0 999px rgba(20, 10, 5, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.scene.editing .door-resize {
  position: absolute;
  right: -10px;
  bottom: -10px;
  z-index: 3;
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid #2a1a0c;
  border-radius: 50%;
  background: var(--gold-hi);
  cursor: nwse-resize;
}
.door.dragging { z-index: 6; }

@media (prefers-reduced-motion: reduce) {
  .door-panel { transition: none; }
  .door.shake .door-panel, .door.flash .door-front { animation: none; }
}

/* Överlägg ovanpå bilden */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-top { top: 0; }
.hud-card {
  max-width: min(560px, 100%);
  padding: 10px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(14, 10, 9, 0.74);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  text-align: center;
  transition: padding 0.3s ease;
}
.hud-title { margin: 0; color: var(--gold-hi); font-size: clamp(20px, 3.2vw, 30px); line-height: 1.15; }
.hud-sub { margin: 4px 0 0; font-size: 14px; }
.hud-note { margin: 6px 0 0; color: var(--warn); font-size: 13px; }
.hud-card .year-select { margin-top: 8px; min-height: 34px; padding: 4px 30px 4px 10px; font-size: 14px; }
.hud-top.compact .hud-card { padding: 6px 14px; }
.hud-top.compact .hud-title { font-size: 17px; }
.hud-top.compact .hud-sub, .hud-top.compact .hud-note, .hud-top.compact .year-select { display: none; }
.hud-bottom {
  bottom: 0;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.hud-hint {
  max-width: 320px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 10, 9, 0.8);
  font-size: 14px;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.hud-hint.fade { opacity: 0; transform: translateY(8px); pointer-events: none; }
.hud-controls {
  display: flex;
  gap: 6px;
  margin-left: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 10, 9, 0.8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.hud-btn {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.hud-btn:hover { background: rgba(244, 212, 138, 0.16); }
.hud-btn svg { width: 18px; height: 18px; }
.hud-btn-text { color: var(--gold-hi); font-size: 14px; font-weight: 600; white-space: nowrap; }
.hud-controls { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
/* Inga synliga knappar (t.ex. utanför december) – visa ingen tom ruta */
.hud-controls:not(:has(> :not([hidden]))) { display: none; }
/* Smala telefoner: man zoomar med fingrarna, så − och + behövs inte, och knapparna krymper */
@media (max-width: 480px) and (pointer: coarse) { .hud-zoom { display: none; } }
@media (max-width: 400px) {
  .hud-controls { padding: 4px; gap: 4px; }
  .hud-btn { min-width: 36px; height: 36px; padding: 0 8px; font-size: 19px; }
  .hud-btn-text { font-size: 13px; }
}
.hud-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(14, 10, 9, 0.9);
  box-shadow: var(--shadow);
}
.hud-edit-text { flex: 1; min-width: 220px; font-size: 14px; }
.hud-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Låga skärmar, t.ex. mobil i liggande läge: krymp toppen och överläggen */
@media (max-height: 520px) {
  body[data-view="calendar"] .topbar { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  body[data-view="calendar"] .brand-mark img { width: 24px; height: 24px; }
  body[data-view="calendar"] .brand-title { font-size: 17px; }
  body[data-view="calendar"] .btn-login { min-height: 34px; padding: 5px 12px; }
  body[data-view="calendar"] .avatar { width: 28px; height: 28px; font-size: 13px; }
  .hud { padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .hud-card { padding: 4px 12px; border-radius: 12px; }
  .hud-title { font-size: 15px; }
  .hud-sub, .hud-note, .hud-card .year-select { display: none; }
  .hud-controls { padding: 3px; gap: 4px; }
  .hud-btn { min-width: 34px; height: 34px; padding: 0 9px; font-size: 18px; }
  .hud-btn-text { font-size: 13px; }
  .hud-hint { padding: 6px 10px; font-size: 13px; }
}

/* ---------- Dialoger ---------- */

.dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
}
.dialog-sm { width: min(420px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(6, 4, 3, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialog-in 0.28s ease; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.dialog-body { padding: 28px 24px 24px; }
.dialog-title { margin: 0 0 4px; font-size: 26px; color: var(--gold-hi); }
.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.dialog-close:hover { background: rgba(0, 0, 0, 0.7); }

.dialog-door { width: min(860px, calc(100vw - 24px)); }
.dm { display: grid; }
.dm-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3d2617, #120b08 75%);
}
.dm-img { position: relative; display: block; width: 100%; max-height: 48vh; object-fit: contain; }
.dm-blur { position: absolute; inset: -20px; width: calc(100% + 40px); height: calc(100% + 40px); object-fit: cover; filter: blur(26px) saturate(1.2); opacity: 0.45; }
.dm-glass { width: 120px; }
.dm-glass svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 22px rgba(217, 139, 43, 0.45)); }
.dm-text { padding: 24px 24px 28px; }
.dm-day { margin: 0 0 6px; color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.dm-name { margin: 0 0 12px; color: var(--gold-hi); font-size: clamp(26px, 4.2vw, 36px); line-height: 1.12; }
.dm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dm-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 14px; }
.dm-facts dt { color: var(--faint); font-size: 14px; }
.dm-facts dd { margin: 0; }
.dm-desc { margin: 0; white-space: pre-line; }
.dm-owner { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.dm-owner strong { color: var(--ink); }
.dm-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
@media (min-width: 720px) {
  .dm { grid-template-columns: 5fr 6fr; min-height: 440px; }
  .dm-img { position: absolute; inset: 0; height: 100%; max-height: none; }
  .dm-text { padding: 34px 30px; align-self: center; }
}

/* ---------- Sidor ---------- */

.page { max-width: 1000px; margin: 0 auto; padding: 26px 16px 64px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 8px; color: var(--gold-hi); font-size: clamp(28px, 5vw, 42px); line-height: 1.1; }
.lead { margin: 0 0 12px; max-width: 64ch; color: var(--ink); font-size: 17px; }
.lead strong { color: var(--gold-hi); }
.stack { display: grid; gap: 18px; }
.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.card h2 { margin: 0 0 6px; font-size: 22px; color: var(--gold-hi); }
.card > p:first-of-type { margin-top: 0; }
@media (min-width: 720px) { .card { padding: 24px 26px; } }

.loading { padding: 80px 16px; text-align: center; color: var(--muted); }
.empty-state { display: grid; justify-items: center; gap: 4px; padding: 24px 8px; text-align: center; }
.empty-state h2 { margin: 8px 0 0; }
.empty-state p { max-width: 46ch; }
.empty-icon { width: 64px; }
.empty-icon svg { display: block; width: 100%; height: auto; }

/* ---------- Formulär ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; align-content: start; }
.field > label { color: var(--muted); font-size: 14px; font-weight: 600; }
.field-end { align-content: end; justify-items: start; padding-bottom: 6px; }
.field-check { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-check > label { color: var(--ink); font-size: 15px; font-weight: 500; cursor: pointer; }
.field-check .hint { flex-basis: 100%; }
.hint { color: var(--faint); font-size: 13px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: 11px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
select { cursor: pointer; }
select option { background: var(--panel-solid); color: var(--ink); }
input::placeholder, textarea::placeholder { color: rgba(205, 188, 167, 0.45); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216, 164, 70, 0.22); }
select.invalid { border-color: var(--bad); }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; }
input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px var(--field-line);
  transition: background 0.2s ease;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f7efe4;
  transition: transform 0.2s ease;
}
input.switch:checked { background: var(--gold); }
input.switch:checked::after { transform: translateX(20px); }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1; min-width: 0; }
.input-row > .btn { flex: none; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-error { margin: 0; color: var(--bad); font-size: 14px; }
.dialog-body .field { margin-top: 14px; }
.dialog-body .form-error { margin-top: 12px; }
.dialog-body .btn-block { margin-top: 20px; }
.save-state { color: var(--faint); font-size: 14px; }
.save-state.pending { color: var(--warn); }
.save-state.ok { color: var(--ok); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.chip-ok { color: var(--ok); border-color: rgba(143, 209, 158, 0.4); background: rgba(143, 209, 158, 0.1); }
.chip-partial { color: var(--warn); border-color: rgba(239, 190, 106, 0.4); background: rgba(239, 190, 106, 0.1); }
.chip-empty { color: var(--faint); border-color: rgba(156, 138, 118, 0.4); }
.chip-gold { color: var(--gold-hi); border-color: rgba(244, 212, 138, 0.4); background: rgba(244, 212, 138, 0.08); }

/* ---------- Luckredigering ---------- */

.slot-list { display: grid; gap: 18px; }
.slot-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.slot-head .chip { margin-left: auto; }
.slot-title h3 { margin: 0; font-size: 22px; }
.slot-title p { margin: 0; color: var(--muted); font-size: 14px; }
.day-badge {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(155deg, var(--t1, #a5312f), var(--t2, #5c1417));
  box-shadow: inset 0 0 0 1px rgba(244, 212, 138, 0.4);
  color: var(--gold-hi);
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
}
.slot-body { display: grid; gap: 18px; }
@media (min-width: 760px) { .slot-body { grid-template-columns: 230px 1fr; gap: 24px; } }
.photo-col { display: grid; gap: 10px; align-content: start; }
.photo {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px dashed var(--field-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
}
@media (min-width: 760px) { .photo { aspect-ratio: 3 / 4; } }
.photo img { width: 100%; height: 100%; object-fit: contain; }
.photo-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 16px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.photo-empty small { color: var(--faint); font-size: 13px; }
.photo-icon { width: 48px; margin-bottom: 6px; opacity: 0.85; }
.photo-icon svg { display: block; width: 100%; height: auto; }
.photo-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 10, 9, 0.7);
  color: var(--gold-hi);
  font-weight: 600;
}
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.slot-compact { padding: 8px 4px 20px; }

/* ---------- Arkiv ---------- */

.arch-tools { display: grid; gap: 12px; margin-bottom: 8px; }
.arch-tools input[type="search"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--field-line);
  border-radius: 999px;
  background: rgba(14, 10, 9, 0.7);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.arch-tools input[type="search"]:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216, 164, 70, 0.22); }
.arch-years { display: flex; flex-wrap: wrap; gap: 6px; }
.arch-years .chip { text-decoration: none; font-size: 14px; padding: 4px 12px; }
.arch-status { margin: 4px 0 14px; font-size: 14px; }
.arch-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.arch-head h2 { margin: 0; }
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.arch-year.is-current { border-color: var(--line-strong); }
.arch-wait { margin: 0; }
.arch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  font: inherit;
  text-align: left;
}
button.arch-card { cursor: pointer; }
button.arch-card:hover { border-color: var(--line-strong); background: rgba(244, 212, 138, 0.06); }
.arch-card.is-empty { opacity: 0.55; }
.arch-img { width: 56px; height: 72px; flex: none; border-radius: 8px; object-fit: cover; background: #120b08; }
.arch-img-empty { display: grid; place-items: center; padding: 14px; }
.arch-img-empty svg { width: 100%; height: auto; opacity: 0.7; }
.arch-text { display: grid; gap: 1px; min-width: 0; }
.arch-day { color: var(--gold); font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.arch-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.arch-meta, .arch-owner { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.arch-owner { color: var(--faint); }

/* ---------- Administration ---------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 10, 9, 0.55);
  width: max-content;
  max-width: 100%;
  scrollbar-width: none;
}
.tab {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { background: linear-gradient(180deg, #f3cd78, #c9923b); color: #24160a; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 22px 0 14px; }
.toolbar-title { margin: 0 auto 0 0; font-size: 24px; color: var(--ink); }
.year-select { width: auto; min-height: 40px; padding: 7px 34px 7px 12px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(14, 10, 9, 0.55); }
.segmented button {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.segmented button.active { background: rgba(244, 212, 138, 0.16); color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.stat-value { color: var(--gold-hi); font-family: var(--serif); font-size: clamp(22px, 4vw, 30px); font-weight: 600; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; }

.callout { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.callout h3 { margin: 0 0 4px; font-size: 20px; color: var(--gold-hi); }
.callout p { margin: 0; max-width: 60ch; }
.callout-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head + .card { margin-top: 18px; }

.ov-list { display: grid; gap: 14px; }
.ov-card { padding-top: 14px; padding-bottom: 6px; }
.ov-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.ov-head h3 { margin: 0; font-size: 19px; }
.ov-head p { margin: 0; font-size: 14px; }
.pos-badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(244, 212, 138, 0.08);
  color: var(--gold-hi);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}
.ov-item + .ov-item, .ov-head + .ov-item { border-top: 1px solid var(--line); }
.ov-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 2px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ov-row:hover .ov-name { color: var(--gold-hi); }
.ov-day {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(244, 212, 138, 0.07);
  color: var(--gold-hi);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}
.ov-main { min-width: 0; }
.ov-name { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ov-name::first-letter { text-transform: uppercase; }
.ov-name.is-empty { color: var(--faint); font-weight: 500; font-style: italic; }
.ov-meta { display: block; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ov-thumb { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; }
.ov-thumb.is-empty { border: 1px dashed var(--line); }
.ov-chev svg { display: block; width: 18px; height: 18px; color: var(--faint); transform: rotate(-90deg); transition: transform 0.2s ease; }
.ov-item.open .ov-chev svg { transform: rotate(0deg); }
@media (max-width: 560px) {
  .ov-row { grid-template-columns: 38px minmax(0, 1fr) auto 18px; gap: 10px; }
  .ov-thumb { display: none; }
  .ov-date { display: none; } /* dagen står redan i rutan till vänster */
}

.assign-list { display: grid; gap: 8px; margin: 16px 0; }
.assign-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(150px, 260px);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}
.assign-days { display: grid; gap: 4px; }
.assign-label { font-weight: 600; }
.assign-nums { display: flex; gap: 5px; }
.mini-door {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 5px;
  border-radius: 6px;
  background: linear-gradient(155deg, #8c5b33, #3f2511);
  box-shadow: inset 0 0 0 1px rgba(244, 212, 138, 0.35);
  color: var(--gold-hi);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
}
@media (max-width: 560px) {
  .assign-row { grid-template-columns: 36px minmax(0, 1fr); }
  .assign-row select { grid-column: 1 / -1; }
}

.bg-preview {
  aspect-ratio: 16 / 9;
  max-width: 520px;
  margin: 14px 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: #120c0a;
  background-position: center;
  background-size: cover;
}

.placeholder-list { display: grid; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.placeholder-list code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(244, 212, 138, 0.1);
  color: var(--gold-hi);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.mode-list { display: grid; gap: 10px; margin: 14px 0; }
.mode-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.mode-option:has(input:checked) { border-color: var(--gold); background: rgba(216, 164, 70, 0.1); }
.mode-option input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--gold); cursor: pointer; }
.mode-text { display: grid; gap: 2px; }
.mode-text .muted { font-size: 14px; }

.member-list { display: grid; gap: 10px; margin-top: 14px; }
.member {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}
.member-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.member-main { flex: 1; min-width: 180px; }
.member-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 17px; font-weight: 600; }
.member-meta { color: var(--muted); font-size: 14px; }
.member-actions { display: flex; gap: 8px; }
.member-edit { padding: 4px 0; }
.cred-box {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(143, 209, 158, 0.35);
  border-radius: 12px;
  background: rgba(143, 209, 158, 0.07);
}
.cred-box p { margin: 0 0 8px; }
.cred-text {
  margin: 0 0 12px;
  padding: 12px;
  overflow-x: auto;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.sr-copy { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- Toasts & fot ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(28, 20, 17, 0.96);
  box-shadow: var(--shadow);
  font-size: 15px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { border-color: rgba(143, 209, 158, 0.5); }
.toast-early {
  border-color: rgba(244, 212, 138, 0.6);
  background: linear-gradient(160deg, rgba(60, 24, 20, 0.97), rgba(28, 20, 17, 0.97));
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
  text-align: center;
}
.toast-error { border-color: rgba(240, 138, 124, 0.6); color: #ffd9d3; }

.footer {
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

/* Underrubrik i ett kort (t.ex. Luckornas placering under Bakgrundsbild) */
.card-subhead { margin: 22px 0 6px; padding-top: 18px; border-top: 1px solid var(--line); font-family: var(--serif); font-size: 18px; font-weight: 600; }

/* ---------- Flera kalendrar ---------- */

.menu-label { padding: 6px 12px 2px; color: var(--faint); font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.menu-cal { display: flex; align-items: center; gap: 8px; }
.menu-check { width: 1em; flex: none; color: var(--gold-hi); }
.cal-select { max-width: 100%; }
.page-head > .cal-select { display: block; margin: 0 0 12px; }
.admin-cal { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 14px; }
.admin-cal strong { color: var(--gold-hi); }

/* ---------- Betyg: glencairnglas ---------- */

.glencairn { display: block; width: 100%; height: 100%; overflow: visible; }
.glencairn .g-glass { fill: rgba(255, 255, 255, 0.05); stroke: currentColor; stroke-width: 1.3; stroke-linejoin: round; }
.glencairn .g-liquid { fill: #d98b2b; opacity: 0; transition: opacity 0.15s ease; }
.is-on .glencairn .g-liquid { opacity: 1; }
.glasses { display: inline-flex; gap: 2px; flex: none; color: var(--gold); }
.glasses .glass { width: 14px; height: 19px; }
.glasses .glass:not(.is-on) { color: var(--faint); opacity: 0.75; }
.glasses-sm .glass { width: 15px; height: 20px; }
.glasses-xs .glass { width: 10px; height: 13px; }

.dm-rating { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.dm-rating .field { margin-top: 4px; }
.dm-rating textarea { min-height: 84px; }
.rate-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.rate-title { margin: 0; color: var(--ink); font-size: 18px; }
.rate-input { display: flex; gap: 2px; margin: 0 -4px; }
.rate-glass {
  width: 42px;
  height: 50px;
  padding: 5px 7px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--gold);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rate-glass:not(.is-on) { color: var(--faint); }
.rate-glass:hover { background: rgba(244, 212, 138, 0.08); }
.rate-glass:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 0; }
.rate-summary { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.rate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 22px; margin-top: 6px; }

.arch-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.arch-avg { display: inline-flex; align-items: center; gap: 5px; }
.arch-mine { color: var(--gold-hi); font-weight: 600; }
.arch-note { overflow: hidden; color: var(--faint); font-size: 12.5px; font-style: italic; text-overflow: ellipsis; white-space: nowrap; }
