/* ---------- icons ---------- */
.icon {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  vertical-align: -0.22em;
}

.art {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.art-letter {
  display: grid;
  place-items: center;
  border-radius: 30%;
  background: linear-gradient(135deg, var(--sunny), var(--tangerine));
  color: var(--white);
  font-weight: 900;
  font-size: 1.6em;
  aspect-ratio: 1;
}

/* ---------- topbar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0
    max(var(--gutter), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 253, 248, 0.72);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.topbar:empty {
  display: none;
}

.tb-title {
  flex: 1;
  font-size: clamp(20px, 3vw, 28px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.tb-countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.tb-countdown.ending {
  background: #fff1e3;
  color: #c45f1c;
  animation: bob 1.6s ease-in-out infinite;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--white);
  background: var(--accent);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000);
  text-decoration: none;
  transition: transform 0.15s var(--spring);
}

.tb-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.tb-admin {
  background: var(--tangerine);
  box-shadow: 0 3px 0 #c45f1c;
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow:
      0 3px 0 #c45f1c,
      0 0 0 0 rgba(255, 138, 61, 0.5);
  }
  100% {
    box-shadow:
      0 3px 0 #c45f1c,
      0 0 0 14px rgba(255, 138, 61, 0);
  }
}

.lang-switch {
  display: flex;
  background: rgba(45, 42, 74, 0.07);
  border-radius: 14px;
  padding: 3px;
}

.lang-switch button {
  padding: 8px 10px;
  border-radius: 11px;
  font-weight: 900;
  font-size: 14px;
  color: var(--ink-soft);
}

.lang-switch button.on {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-s);
}

/* ---------- surfaces ---------- */
.glass {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-m);
}

.panel {
  padding: clamp(16px, 2.5vw, 26px);
  margin-bottom: 18px;
}

.muted {
  color: var(--ink-soft);
  font-weight: 700;
}

.small {
  font-size: 14px;
}

.center {
  text-align: center;
}

.error-text {
  color: var(--coral);
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.row > .field {
  flex: 1 1 140px;
}

.row.end {
  justify-content: flex-end;
}

.row.between {
  justify-content: space-between;
  align-items: center;
}

.row.tight {
  gap: 4px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 18px;
  font-weight: 900;
  font-size: 16px;
  text-decoration: none;
  transition:
    transform 0.15s var(--spring),
    box-shadow 0.15s;
}

.btn:active {
  transform: translateY(3px) scale(0.98);
}

.btn.primary {
  background: linear-gradient(180deg, #a184ff, var(--grape));
  color: var(--white);
  box-shadow:
    0 4px 0 #6a4fd6,
    0 10px 20px rgba(142, 108, 255, 0.35);
}

.btn.primary:active {
  box-shadow: 0 1px 0 #6a4fd6;
}

.btn.ghost {
  background: var(--white);
  color: var(--ink);
  box-shadow:
    0 3px 0 rgba(45, 42, 74, 0.12),
    inset 0 0 0 2px rgba(45, 42, 74, 0.08);
}

.btn.danger,
.round-btn.danger {
  background: #ffe3e6;
  color: #d43b4c;
}

.btn.big {
  padding: 16px 28px;
  font-size: 20px;
  border-radius: 22px;
}

.btn.huge {
  padding: 22px 46px;
  font-size: 34px;
  border-radius: 30px;
}

.btn:disabled {
  opacity: 0.55;
}

.round-btn {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--white);
  box-shadow: var(--shadow-s);
  transition: transform 0.15s var(--spring);
}

.round-btn:active {
  transform: scale(0.9);
}

.round-btn.go {
  background: var(--leaf);
  color: var(--white);
  box-shadow: 0 3px 0 #3faf52;
}

.mini-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(45, 42, 74, 0.06);
  font-size: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--white);
  box-shadow: var(--shadow-s);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
}

.chip.big {
  padding: 10px 16px;
  font-size: 16px;
}

.coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe07a, var(--sunny));
  color: #7a4a00;
  font-weight: 900;
  font-size: 18px;
  box-shadow:
    0 2px 0 #e0a516,
    inset 0 -2px 0 rgba(255, 255, 255, 0.4);
}

.coin.small {
  min-width: 36px;
  font-size: 13px;
  padding: 2px 8px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(45, 42, 74, 0.07);
}

.segmented button {
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 800;
  color: var(--ink-soft);
}

.segmented button.on {
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-s);
}

/* ---------- forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 800;
}

.input {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(45, 42, 74, 0.12);
  background: var(--white);
  color: var(--ink);
  width: 100%;
  min-width: 0;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.input:focus {
  border-color: var(--grape);
  box-shadow: 0 0 0 4px rgba(142, 108, 255, 0.18);
}

/* iOS WebKit gives date/time inputs a native look with an intrinsic width and centred text, so they overflow a
   row and stand out from the other fields; flatten them and keep the height when empty. */
input[type="date"].input,
input[type="time"].input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-height: 52px;
  text-align: left;
}

input[type="date"].input::-webkit-date-and-time-value,
input[type="time"].input::-webkit-date-and-time-value {
  text-align: left;
}

input[type="color"].input {
  padding: 4px;
  height: 50px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--grape);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.form-error {
  color: var(--coral);
  min-height: 1.2em;
  margin: 0;
}

/* ---------- modal ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(45, 42, 74, 0.38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.25s ease both;
}

.backdrop-out {
  animation: fade-out 0.25s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 26px;
  border-radius: var(--radius-l);
  background: var(--paper);
  box-shadow: var(--shadow-l);
  animation: pop-in 0.45s var(--spring) both;
}

.modal-wide {
  width: min(860px, 100%);
}

.modal-text {
  font-size: 19px;
  margin: 0;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.85);
  }
}

/* ---------- PIN pad ---------- */
.modal-pin {
  width: min(380px, 100%);
}

.pin {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pin p {
  margin: 0;
}

.pin-lock {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: var(--white);
  background: linear-gradient(135deg, var(--tangerine), var(--coral));
  box-shadow: 0 4px 0 #c94352;
}

.pin-dots {
  display: flex;
  gap: 12px;
  margin: 10px 0 0;
  min-height: 22px;
}

.pin-dots span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(45, 42, 74, 0.12);
  transition: transform 0.2s var(--spring);
}

.pin-dots span.on {
  background: var(--grape);
  transform: scale(1.2);
}

.pin-msg {
  min-height: 1.3em;
  color: var(--coral);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 12px;
}

.pin-key {
  height: 64px;
  border-radius: 20px;
  font-size: 26px;
  font-weight: 900;
  background: var(--white);
  box-shadow: 0 3px 0 rgba(45, 42, 74, 0.14);
}

.pin-key:active {
  transform: translateY(3px);
  box-shadow: none;
}

.pin-ok {
  background: var(--leaf);
  color: var(--white);
  box-shadow: 0 3px 0 #3faf52;
}

/* ---------- toast ---------- */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow-m);
  animation: pop-in 0.4s var(--spring) both;
}

.toast-success {
  background: #2f9e57;
}

.toast-error {
  background: #d43b4c;
}

.toast-out {
  animation: fade-out 0.4s ease both;
}

/* ---------- loader ---------- */
.loader {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 80px 0;
}

.loader span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grape);
  animation: hop 0.9s var(--spring) infinite;
}

.loader span:nth-child(2) {
  background: var(--sunny);
  animation-delay: 0.12s;
}

.loader span:nth-child(3) {
  background: var(--teal);
  animation-delay: 0.24s;
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-18px);
  }
}

.empty {
  text-align: center;
  font-size: 64px;
  padding: 80px 0;
}

/* ---------- fx ---------- */
.fly-points {
  position: fixed;
  z-index: 950;
  pointer-events: none;
  font-size: 44px;
  font-weight: 900;
  color: #ffb300;
  -webkit-text-stroke: 3px var(--white);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(45, 42, 74, 0.25);
}

.rays {
  position: absolute;
  inset: -50%;
  z-index: -1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 200, 61, 0.22) 0 10deg, transparent 10deg 20deg);
  animation: spin 18s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 62%);
  mask: radial-gradient(circle, #000 20%, transparent 62%);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- drag and drop ---------- */
.drag-ghost {
  position: fixed;
  z-index: 990;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: var(--shadow-l) !important;
}

.drag-source {
  opacity: 0.35;
}

.is-dragging,
.is-dragging * {
  cursor: grabbing !important;
}

.drop-over {
  background: rgba(142, 108, 255, 0.08) !important;
  outline: 3px dashed rgba(142, 108, 255, 0.5);
  outline-offset: -3px;
}

.drop-marker {
  height: 6px;
  border-radius: 3px;
  background: var(--grape);
  margin: 2px 0;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  white-space: nowrap;
  color: var(--ink-soft);
  box-shadow: var(--shadow-s);
}

.tab.on {
  background: var(--tangerine);
  color: var(--white);
  box-shadow: 0 3px 0 #c45f1c;
}

/* ---------- table ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(45, 42, 74, 0.08);
}

.table th {
  color: var(--ink-soft);
  font-size: 13px;
}

.table td:not(:first-child),
.table th:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- chart ---------- */
.chart {
  position: relative;
}

.chart-scroll {
  overflow-x: auto;
}

.chart-svg {
  width: 100%;
  min-width: 560px;
  height: auto;
  overflow: visible;
}

.chart .grid {
  stroke: rgba(45, 42, 74, 0.08);
  stroke-width: 1;
}

.chart .axis {
  stroke: rgba(45, 42, 74, 0.2);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
}

.chart .peak {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.chart .mark-star {
  fill: #e0a516;
  font-size: 10px;
}

.chart .hit {
  fill: transparent;
}

.chart .col.hover .hit {
  fill: rgba(45, 42, 74, 0.05);
}

.chart .col:focus {
  outline: none;
}

.chart-tip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--white);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 8px;
}

.chart-tip.on {
  opacity: 1;
}

.avatar-photo {
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid #fff;
  box-shadow: 0 0 0 3px rgba(45, 42, 74, 0.85);
  background: #fff;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
