:root {
  --ink: #1a2332;
  --muted: #5b6573;
  --line: rgba(26, 35, 50, 0.12);
  --surface: rgba(255, 252, 247, 0.88);
  --surface-solid: #fffaf3;
  --accent: #0f6b5c;
  --accent-deep: #0a4f44;
  --accent-soft: #d8efe9;
  --warn: #9a3412;
  --shadow: 0 18px 50px rgba(26, 35, 50, 0.1);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --page-pad: 1rem;
  --touch: 2.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.5;
  background:
    radial-gradient(1200px 600px at 10% -10%, #c8e7df 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f3d9b8 0%, transparent 50%),
    linear-gradient(165deg, #f7f1e8 0%, #e8eef2 55%, #dfe8e4 100%);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bg-glow {
  position: fixed;
  inset: auto -10% -20% auto;
  width: min(420px, 70vw);
  height: min(420px, 70vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 107, 92, 0.18), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.site-header,
.shell {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - (var(--page-pad) * 2)));
  margin-inline: auto;
}

.site-header {
  padding: 2.5rem 0 1.25rem;
  padding-top: max(2.5rem, env(safe-area-inset-top, 0px));
  animation: rise 0.55s ease both;
}

.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-deep);
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 6vw, 2.7rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lede {
  margin: 0.75rem 0 0;
  color: var(--muted);
  max-width: 42rem;
}

.shell {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.5rem;
  animation: rise 0.65s ease both;
  animation-delay: 0.05s;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.35rem;
  background: rgba(26, 35, 50, 0.05);
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.mode-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  min-height: var(--touch);
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.is-active {
  background: var(--surface-solid);
  color: var(--accent-deep);
  box-shadow: 0 4px 14px rgba(26, 35, 50, 0.08);
}

.panel[hidden] {
  display: none !important;
}

.slip-form label,
.inline-amount {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.slip-form label span,
.inline-amount span,
.format-pills legend {
  color: var(--ink);
}

.hint {
  font-style: normal;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.85em;
}

input,
textarea,
select {
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  min-height: var(--touch);
  width: 100%;
  max-width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.15);
}

input.is-invalid,
textarea.is-invalid {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(154, 52, 18, 0.15);
}

textarea {
  resize: vertical;
  min-height: 4.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.pilgrims {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1rem;
  margin: 0.5rem 0 1rem;
}

.pilgrims legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.pilgrim-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.pilgrim-row .idx {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.total-preview {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.total-preview strong {
  color: var(--accent-deep);
  font-size: 1.15rem;
  word-break: break-word;
}

.dropzone {
  border: 1.5px dashed rgba(15, 107, 92, 0.35);
  background: linear-gradient(180deg, rgba(216, 239, 233, 0.45), rgba(255, 255, 255, 0.5));
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  margin-bottom: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.drop-title {
  margin: 0;
  font-weight: 700;
}

.drop-sub {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.bulk-summary {
  margin: 0;
  font-weight: 600;
  color: var(--accent-deep);
  overflow-wrap: anywhere;
}

.linkish {
  border: 0;
  background: none;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.35rem;
  min-height: var(--touch);
}

.actions-bar {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.format-pills {
  border: 0;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.format-pills legend {
  width: 100%;
  margin-bottom: 0.35rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.format-pills label {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch);
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  -webkit-tap-highlight-color: transparent;
}

.format-pills input {
  width: auto;
  min-height: 1.1rem;
  accent-color: var(--accent);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.8rem 1.3rem;
  min-height: var(--touch);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 107, 92, 0.25);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-deep);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--accent-deep);
  padding: 0.55rem 0.95rem;
  font-size: 0.92rem;
}

.btn.ghost:hover {
  background: var(--accent-soft);
}

.btn.danger-ghost {
  background: transparent;
  border: 0;
  color: var(--warn);
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  min-height: var(--touch);
}


.status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status.is-busy {
  color: var(--accent-deep);
}

.status.is-ok {
  color: var(--accent);
}

.status.is-err {
  color: var(--warn);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  :root {
    --page-pad: 0.75rem;
  }

  body {
    font-size: 1rem;
  }

  .site-header {
    padding: 1.35rem 0 1rem;
    padding-top: max(1.35rem, env(safe-area-inset-top, 0px));
  }

  .lede {
    font-size: 0.95rem;
  }

  .shell {
    padding: 1rem 0.9rem 1.15rem;
    border-radius: 16px;
  }

  .mode-tabs {
    border-radius: 14px;
    gap: 0.3rem;
  }

  .mode-tab {
    border-radius: 12px;
    padding: 0.65rem 0.5rem;
    font-size: 0.92rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .pilgrims {
    padding: 0.75rem 0.75rem 0.85rem;
  }

  .pilgrim-row {
    grid-template-columns: 1.75rem 1fr;
    gap: 0.4rem 0.5rem;
  }

  .pilgrim-row .btn.danger-ghost {
    grid-column: 2;
    justify-self: start;
    padding-left: 0;
  }

  .format-pills {
    gap: 0.45rem;
  }

  .format-pills label {
    flex: 1 1 calc(33.33% - 0.45rem);
    justify-content: center;
    min-width: 4.5rem;
  }

  .action-row {
    display: block;
  }

  .btn.primary {
    width: 100%;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    font-size: 1.05rem;
    padding: 0.95rem 1rem;
  }

  .btn.ghost {
    width: 100%;
    margin-top: 0.35rem;
  }

  .dropzone {
    padding: 1.35rem 1rem;
  }

  .bg-glow {
    opacity: 0.65;
  }
}

@media (max-width: 380px) {
  .format-pills label {
    flex: 1 1 100%;
  }

  .site-header h1 {
    font-size: 1.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
