:root {
  --primary: #c99a52;
  --primary-soft: #e0bd83;
  --sage: #93ab7c;
  --bg: #201c15;
  --panel: #2c2719;
  --panel-glass: rgba(44, 39, 25, 0.72);
  --text: #ece3d0;
  --muted: #a89b7e;
  --danger: #c98f86;
  --ok: #9ab68a;
  --border: rgba(236, 227, 208, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(160deg, #1d1a13 0%, #242c1e 50%, #241f16 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Cormorant Garamond", "Segoe UI", serif;
  font-size: 1.05rem;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- App shell: left sidebar + content ---- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: rgba(30, 27, 18, 0.6);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.sidebar.hidden { display: none; }

.sidebar a, .sidebar button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  border: none;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.08rem;
  cursor: pointer;
}
.sidebar a:hover, .sidebar button:hover { background: rgba(184, 134, 63, 0.14); }
.sidebar a.active { background: rgba(184, 134, 63, 0.2); color: var(--primary-soft); font-weight: 600; }

.mobile-menu-btn { display: none; }
.mobile-menu-btn.hidden { display: none !important; }

.content-col { flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(30, 27, 18, 0.5);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
  gap: 12px;
}

.topbar.hidden { display: none; }

.brand {
  margin: 0;
  font-family: "Cinzel", serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 1.25rem;
  color: var(--primary-soft);
  text-transform: uppercase;
}

.auth-btn {
  color: var(--text);
  background: rgba(236, 227, 208, 0.08);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: "Cormorant Garamond", serif;
  font-size: 1rem;
  font-weight: 600;
}
.auth-btn:hover { background: rgba(236, 227, 208, 0.16); }

main { padding: 20px 28px; width: 100%; margin: 0; }
body.landing main { padding: 0; max-width: none; }
body.landing { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td:first-child { white-space: normal; min-width: 160px; }
td:last-child { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-family: "Playfair Display", serif; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }

.card-panel {
  background: var(--panel-glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 16px;
  box-shadow: 0 6px 20px rgba(74, 69, 52, 0.08);
  overflow-x: auto;
}

input, select, textarea, button.btn {
  background: rgba(236, 227, 208, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 1rem;
  font-family: "Cormorant Garamond", serif;
}

button.btn {
  cursor: pointer;
  background: var(--primary);
  border: none;
  font-weight: 600;
  color: #201c15;
}
button.btn.secondary { background: rgba(236,227,208,0.1); color: var(--text); }
button.btn.danger { background: var(--danger); color: #201c15; }
button.btn:disabled { opacity: 0.5; cursor: default; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.badge.in { background: rgba(111, 138, 92, 0.16); color: var(--ok); }
.badge.in_deck { background: rgba(184, 134, 63, 0.18); color: var(--primary-soft); }
.badge.gone { background: rgba(165, 96, 92, 0.16); color: var(--danger); }

.printing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.printing-card { background: rgba(236,227,208,0.06); border-radius: 10px; padding: 10px; cursor: pointer; border: 2px solid var(--border); }
.printing-card:hover { border-color: var(--primary-soft); }
.printing-card img { width: 100%; border-radius: 8px; }

.steps { list-style: decimal; padding-left: 22px; }
.steps li { margin-bottom: 8px; }

.muted { color: var(--muted); font-size: 0.9rem; }

.img-hover { display: inline-flex; vertical-align: middle; color: var(--muted); cursor: pointer; margin-right: 6px; }
.img-hover svg { width: 15px; height: 15px; }
.img-hover:hover { color: var(--primary-soft); }

/* ---- Modal ---- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, 0.65);
  z-index: 5000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ---- Search suggestions dropdown ---- */

.suggest-list {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
  z-index: 6000;
  overflow: hidden;
}
.suggest-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: rgba(201, 154, 82, 0.12); }

.card-preview-popup {
  display: none;
  position: fixed;
  z-index: 9999;
  width: 240px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  pointer-events: none;
}

details.inline-manage { margin-top: 10px; }
details.inline-manage summary { cursor: pointer; color: var(--muted); font-size: 0.92rem; }
details.inline-manage[open] summary { margin-bottom: 10px; }

/* ---- Landing / hero ---- */

.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 700px at 82% 8%, rgba(236, 227, 208, 0.10), transparent 60%),
    radial-gradient(ellipse 1000px 800px at 50% 100%, rgba(0, 0, 0, 0.35), transparent 60%),
    linear-gradient(150deg, #1c2016 0%, #232a1c 45%, #1b1f14 100%);
}

.hero-emblem {
  width: 110px;
  height: auto;
  color: var(--primary-soft);
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 0 10px rgba(201, 154, 82, 0.25));
}

.hero-center {
  position: relative;
  z-index: 2;
  text-align: center;
  width: 100%;
  max-width: 640px;
}

.hero-title {
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: 2.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
  color: var(--primary-soft);
}

.hero-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px auto 38px;
  color: var(--sage);
  max-width: 380px;
}
.hero-divider span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(184,134,63,0.5), transparent); }
.hero-divider i { font-style: normal; font-size: 0.8rem; opacity: 0.85; }

.hero-cards {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
}

.portal-card {
  position: relative;
  font-family: "Cormorant Garamond", serif;
  width: 210px;
  padding: 30px 20px;
  background: rgba(30, 33, 22, 0.6);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.portal-card:hover {
  border-color: rgba(201, 154, 82, 0.35);
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.portal-card:hover .corner { border-color: var(--primary-soft); }

.portal-card .corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--primary);
  opacity: 0.9;
  transition: border-color 0.2s ease;
}
.portal-card .corner.tl { top: 7px; left: 7px; border-right: none; border-bottom: none; }
.portal-card .corner.tr { top: 7px; right: 7px; border-left: none; border-bottom: none; }
.portal-card .corner.bl { bottom: 7px; left: 7px; border-right: none; border-top: none; }
.portal-card .corner.br { bottom: 7px; right: 7px; border-left: none; border-top: none; }

.portal-card svg { width: 26px; height: 26px; margin-bottom: 14px; color: var(--primary-soft); }

.portal-label {
  font-family: "Playfair Display", serif;
  letter-spacing: 0.18em;
  font-size: 0.92rem;
}

.leaf-flourish {
  position: absolute;
  width: 130px;
  height: 130px;
  color: rgba(147, 171, 124, 0.4);
  z-index: 1;
  pointer-events: none;
}
.leaf-flourish.corner-tl { top: 18px; left: 18px; }
.leaf-flourish.corner-br { bottom: 18px; right: 18px; transform: rotate(180deg); }

.book-stack {
  position: absolute;
  bottom: 0;
  left: 24px;
  width: 150px;
  height: auto;
  color: rgba(201, 154, 82, 0.4);
  z-index: 1;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  color: rgba(224, 189, 131, 0.55);
  z-index: 1;
  pointer-events: none;
}

@media (max-width: 600px) {
  .leaf-flourish { width: 80px; height: 80px; }
  .hero-emblem { width: 80px; }
  .book-stack { width: 100px; left: 8px; }
}

/* ---- Login ---- */

.login-wrap {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--panel-glass);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 16px 40px rgba(74, 69, 52, 0.15);
}

.login-card h2 { margin: 0 0 4px; text-align: center; font-family: "Cinzel", serif; font-size: 1.3rem; color: var(--primary-soft); }
.login-card .muted { text-align: center; margin-bottom: 22px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.85rem; color: var(--muted); }
.field input { width: 100%; }

.login-card .btn { width: 100%; padding: 11px; border-radius: 10px; }
.login-card .error { color: var(--danger); font-size: 0.9rem; margin-top: 10px; text-align: center; }
.back-link { display: block; text-align: center; margin-top: 14px; color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.back-link:hover { color: var(--text); }

@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 20px 0 40px rgba(0,0,0,0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn {
    display: inline-flex;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 7px 11px;
    cursor: pointer;
  }
}

@media (max-width: 600px) {
  .hero-title { font-size: 1.9rem; }
  .hero-cards { flex-direction: column; align-items: center; }
  .portal-card { width: 100%; max-width: 280px; padding: 24px 16px; }
  main { padding: 10px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { margin-bottom: 12px; background: var(--panel); border-radius: 10px; padding: 8px; }
  td { border: none; padding: 4px 6px; white-space: normal; }
  td::before { content: attr(data-label); color: var(--muted); display: block; font-size: 0.72rem; }
}
