@font-face {
  font-family: "Roboto Serif";
  src: url("../../fonts/RobotoSerif-Light.woff2") format("woff2");
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Roboto Serif";
  src: url("../../fonts/RobotoSerif-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Roboto Serif";
  src: url("../../fonts/RobotoSerif-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Roboto Serif";
  src: url("../../fonts/RobotoSerif-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Tangerine";
  src: url("../../fonts/Tangerine.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --rose:       #d99ea6;
  --rose-deep:  #b87c85;
  --rose-soft:  #e8bcb9;
  --rose-pale:  #f4e0de;
  --rose-mist:  #ecd0ce;

  --blue:   #b0c1c8;
  --sage:   #9da598;
  --yellow: #f6e4a6;

  --cream:      #fbf5ec;
  --paper:      #fefaf3;
  --ink:        #443134;
  --ink-soft:   #7c6265;

  --tint-bg:    #e6bfbb;
  --tint-text:  #402a2e;
  --backdrop:   #3a2225;

  --present:      #6e9d7a;
  --present-soft: rgba(110, 157, 122, 0.14);
  --absent:       #b8a9a9;
  --danger:       #b0555a;
  --danger-soft:  rgba(176, 85, 90, 0.12);

  --on-dark:    #fbf1ee;

  --line:         rgba(68, 49, 52, 0.12);
  --line-on-tint: rgba(64, 42, 46, 0.16);

  --serif:  "Roboto Serif", Georgia, serif;
  --script: "Tangerine", cursive;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-pill: 999px;
  --shadow-card:  0 12px 30px -22px rgba(58, 34, 37, 0.4);
  --shadow-float: 0 12px 28px -10px rgba(58, 34, 37, 0.5);
  --shadow-sheet: 0 -12px 40px -12px rgba(58, 34, 37, 0.35);

  --col: 520px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.icon {
  width: 24px; height: 24px;
  stroke: currentColor; stroke-width: 1.6;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

.eyebrow {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--rose-deep);
}

/* ============ LOCK ============ */
.lock {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: var(--tint-bg);
  color: var(--tint-text);
  position: relative;
}
.lock::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.28), transparent 60%);
  pointer-events: none;
}
.lock__card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  box-shadow: 0 24px 40px -18px rgba(58, 34, 37, 0.28);
}
.lock__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  border-radius: var(--r-pill);
  background: var(--rose-pale);
  border: 1px solid var(--rose);
  color: var(--rose-deep);
  margin-bottom: var(--sp-4);
}
.lock__badge .icon { width: 26px; height: 26px; }
.lock__title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.8rem;
  margin: var(--sp-2) 0 var(--sp-1);
  color: var(--ink);
}
.lock__sub {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin-bottom: var(--sp-5);
}
.lock__label {
  display: block;
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--rose-deep);
  margin-bottom: var(--sp-2);
  font-weight: 500;
}
.lock__input {
  width: 100%;
  min-height: 60px;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 var(--sp-3);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.lock__input:focus {
  outline: none;
  border-color: var(--rose-deep);
  box-shadow: 0 0 0 3px rgba(184, 124, 133, 0.18);
}
.lock__input::placeholder {
  color: rgba(124, 98, 101, 0.35);
  letter-spacing: 0.4em;
}
.lock__submit {
  width: 100%;
  min-height: 54px;
  margin-top: var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--rose-deep);
  color: var(--paper);
  font-weight: 500;
  font-size: 0.96rem;
  letter-spacing: 0.06em;
  transition: transform 0.18s var(--ease), background 0.2s var(--ease);
  touch-action: manipulation;
  box-shadow: 0 8px 24px -10px rgba(184, 124, 133, 0.5);
}
.lock__submit:active { transform: translateY(1px); background: #9a6570; }
.lock__submit[disabled] { opacity: 0.6; pointer-events: none; }
.lock__error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(176, 85, 90, 0.3);
  color: var(--danger);
  font-size: 0.88rem;
}
.lock__error .icon { width: 18px; height: 18px; }
.lock__error[hidden] { display: none; }

/* ============ APP ============ */
.app {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(env(safe-area-inset-top), 12px) var(--sp-4) calc(env(safe-area-inset-bottom) + var(--sp-6));
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
}
.topbar__title { min-width: 0; }
.topbar__h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.6rem;
  color: var(--ink);
  margin-top: var(--sp-1);
}
.topbar__actions { display: flex; gap: var(--sp-2); flex: none; }
.icon-btn {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  touch-action: manipulation;
}
.icon-btn:active { background: var(--rose-deep); color: var(--paper); }
.icon-btn.is-spinning .icon {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat__num {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--rose-deep);
  font-variant-numeric: tabular-nums;
}
.stat__label {
  display: block;
  margin-top: var(--sp-2);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.search {
  position: relative;
  margin-bottom: var(--sp-4);
}
.search__ic {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
}
.search__ic .icon { width: 20px; height: 20px; }
.search__input {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--sp-4) 0 44px;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  transition: border-color 0.2s var(--ease);
}
.search__input:focus {
  outline: none;
  border-color: var(--rose-deep);
  box-shadow: 0 0 0 3px rgba(184, 124, 133, 0.14);
}

.tabbar {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px;
  margin-bottom: var(--sp-4);
  position: sticky;
  top: max(env(safe-area-inset-top), 4px);
  z-index: 10;
  box-shadow: var(--shadow-card);
}

.event-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.event-seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 52px;
  padding: 0 var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
  touch-action: manipulation;
  box-shadow: var(--shadow-card);
}
.event-seg .icon { width: 20px; height: 20px; }
.event-seg.is-active {
  background: var(--rose-deep);
  color: var(--paper);
  border-color: var(--rose-deep);
}
.event-seg__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.06);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: inherit;
}
.event-seg.is-active .event-seg__count {
  background: rgba(255, 255, 255, 0.24);
}
.tab {
  flex: 1;
  min-height: 44px;
  border-radius: var(--r-pill);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  transition: background 0.24s var(--ease), color 0.24s var(--ease);
  touch-action: manipulation;
}
.tab.is-active {
  background: var(--rose-deep);
  color: var(--paper);
}
.tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
.tab.is-active .tab__count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--paper);
}

/* ============ CARDS ============ */
.list { position: relative; min-height: 240px; }
.cards {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-card);
  transition: opacity 0.25s var(--ease), filter 0.25s var(--ease);
  position: relative;
}
.card__body { flex: 1; min-width: 0; }
.card__name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.02rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-1);
  color: var(--ink-soft);
  font-size: 0.84rem;
}
.card__meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card__meta .icon { width: 14px; height: 14px; }
.card__ref {
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: var(--rose-deep);
  font-weight: 500;
}

.card__hand {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--absent);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--line);
  flex: none;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.card__hand .icon { width: 22px; height: 22px; stroke-width: 1.7; }
.card.is-present .card__hand {
  color: var(--present);
  background: var(--present-soft);
  border-color: rgba(110, 157, 122, 0.42);
}

.card__reject {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  border: 1px solid rgba(176, 85, 90, 0.3);
  background: var(--danger-soft);
  transition: background 0.2s var(--ease);
  flex: none;
  touch-action: manipulation;
}
.card__reject:active { background: rgba(176, 85, 90, 0.22); }
.card__reject .icon { width: 18px; height: 18px; stroke-width: 1.8; }

.card.is-invalide {
  filter: blur(0.6px) grayscale(0.5);
  opacity: 0.72;
}
.card.is-invalide .card__ref {
  color: var(--danger);
}
.card.is-invalide .card__reject { display: none; }

.card__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  margin-left: var(--sp-2);
}
.card__badge--rejected {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(176, 85, 90, 0.32);
}

.loading, .empty, .error {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--ink-soft);
}
.loading { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--rose-deep);
  animation: spin 0.8s linear infinite;
}
.error {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-3) auto;
  background: var(--danger-soft);
  border: 1px solid rgba(176, 85, 90, 0.28);
  border-radius: var(--r-sm);
  color: var(--danger);
  font-size: 0.88rem;
}
.error .icon { width: 18px; height: 18px; }

.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(58, 34, 37, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%; bottom: 0; z-index: 70;
  width: 100%; max-width: var(--col);
  transform: translate(-50%, 100%);
  background: var(--paper);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-sheet);
  padding: var(--sp-4) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  transition: transform 0.36s var(--ease);
  max-height: 80dvh;
  overflow-y: auto;
}
.sheet.is-open { transform: translate(-50%, 0); }
.sheet__grip {
  width: 44px; height: 4px;
  border-radius: var(--r-pill);
  background: var(--line);
  margin: 0 auto var(--sp-4);
}
.sheet__head { text-align: center; margin-bottom: var(--sp-5); }
.sheet__title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.4rem;
  margin-top: var(--sp-2);
}
.sheet__sub {
  color: var(--ink-soft);
  font-size: 0.94rem;
  margin-top: var(--sp-2);
  max-width: 32ch;
  margin-left: auto;
  margin-right: auto;
}
.sheet__close {
  position: absolute;
  top: var(--sp-3); right: var(--sp-3);
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
}
.sheet__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.btn-danger, .btn-cancel {
  width: 100%;
  min-height: 52px;
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: 0.94rem;
  letter-spacing: 0.04em;
  touch-action: manipulation;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn-danger {
  background: var(--danger);
  color: var(--paper);
}
.btn-danger:active { transform: translateY(1px); background: #8a3d42; }
.btn-danger[disabled] { opacity: 0.6; pointer-events: none; }
.btn-cancel {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-cancel:active { background: rgba(0, 0, 0, 0.04); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translate(-50%, 20px);
  max-width: calc(var(--col) - 40px);
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px var(--sp-4);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.86rem;
  box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { width: 18px; height: 18px; color: var(--rose-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
