:root {
  --bg0: #0c0d0f;
  --bg1: #14161a;
  --bg2: #1c1f26;
  --line: rgba(255, 236, 200, 0.08);
  --text: #f3efe6;
  --muted: #9a958a;
  --accent: #e8b86d;
  --accent-2: #f0d5a0;
  --ok: #6fbf8a;
  --warn: #e0a85c;
  --danger: #e07a6a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body {
  position: relative;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
input, textarea, button, code { user-select: text; -webkit-user-select: text; }

.bg-photo {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    url("/static/pepe.png") center center / cover no-repeat;
  transform: scale(1.03);
  filter: saturate(0.92) brightness(0.78);
}
.bg-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(6, 7, 9, 0.72) 0%, rgba(8, 9, 12, 0.88) 55%, rgba(5, 6, 8, 0.94) 100%),
    rgba(4, 5, 7, 0.55);
}
.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 1;
}
.glow {
  pointer-events: none;
  position: fixed;
  width: 60vw;
  height: 60vw;
  top: -20vw;
  right: -15vw;
  background: radial-gradient(circle, rgba(232, 184, 109, 0.1), transparent 65%);
  z-index: 1;
}

.view { position: relative; z-index: 2; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: min(420px, 100%);
  padding: clamp(24px, 5vw, 36px) clamp(20px, 4vw, 32px);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.05), transparent 42%),
    rgba(16, 18, 22, 0.82);
  border: 1px solid rgba(255, 236, 200, 0.12);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: rise 0.55s ease both;
}
.brand {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--accent);
}
.brand.sm { margin-bottom: 4px; }
.login-card h1, .top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -0.03em;
}
.sub, .hint {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}
.sub { margin: 10px 0 28px; word-break: break-word; }
.hint { margin: 0 0 16px; }
.hint code, .meta code, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--accent-2);
}

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field span { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 14px;
  font: 500 15px/1.3 var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { resize: vertical; min-height: 100px; }
input:focus, textarea:focus {
  border-color: rgba(232, 184, 109, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 184, 109, 0.12);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 16px;
  min-height: 46px;
  font: 600 14px/1 var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #c9924a);
  color: #1a1208;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { border-color: rgba(232,184,109,0.35); }
.btn-ok { background: rgba(111,191,138,0.12); color: var(--ok); border-color: rgba(111,191,138,0.25); }
.btn-warn { background: rgba(224,168,92,0.12); color: var(--warn); border-color: rgba(224,168,92,0.25); }
.btn-danger { background: rgba(224,122,106,0.12); color: var(--danger); border-color: rgba(224,122,106,0.25); }

.err {
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.app-view {
  max-width: 980px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  animation: rise 0.45s ease both;
}
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.top-actions { display: flex; gap: 8px; }

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: rgba(16, 18, 22, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg2);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(111,191,138,0.0);
}
.pill.on .dot {
  background: var(--ok);
  box-shadow: 0 0 12px rgba(111,191,138,0.7);
  animation: pulse 1.8s ease infinite;
}
.pill.off .dot { background: var(--danger); }
.meta { color: var(--muted); font-size: 13px; margin-left: auto; word-break: break-word; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 34%),
    rgba(16, 18, 22, 0.8);
  border: 1px solid rgba(255, 236, 200, 0.1);
  border-radius: var(--radius);
  padding: clamp(16px, 4vw, 22px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  animation: rise 0.5s ease both;
}
.panel:nth-child(2) { animation-delay: 0.05s; }
.panel:nth-child(3) { animation-delay: 0.1s; }
.panel:nth-child(4) { animation-delay: 0.15s; }
.panel:nth-child(5) { animation-delay: 0.2s; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.02em;
}
.stack { display: grid; gap: 10px; }
.row-form {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.field.inline {
  display: grid;
  gap: 6px;
}
.field.inline span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.label {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.admin-list-wrap { margin: 14px 0; }
.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-empty {
  color: var(--muted);
  font-size: 14px;
}
.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  font-size: 14px;
}
.admin-chip.main {
  border-color: rgba(232,184,109,0.45);
  background: rgba(232,184,109,0.08);
}
.admin-remove {
  border: none;
  background: rgba(224,122,106,0.15);
  color: #ffd2cb;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.admin-remove:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row .btn { flex: 1 1 120px; }

.file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed rgba(232,184,109,0.3);
  border-radius: 14px;
  background: rgba(232,184,109,0.04);
  cursor: pointer;
}
.file input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.file span { color: var(--accent-2); font-weight: 500; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  text-align: center;
  background: #1f232b;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: rise 0.25s ease both;
}
.toast.bad { border-color: rgba(224,122,106,0.4); color: #ffd2cb; }
.toast.ok { border-color: rgba(111,191,138,0.4); color: #d6ffe2; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111,191,138,0.55); }
  50% { box-shadow: 0 0 0 8px rgba(111,191,138,0); }
}

.welcome-splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.welcome-splash.is-active { opacity: 1; }
.welcome-splash.is-fading { opacity: 0; }

.welcome-splash__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 77, 109, 0.12), transparent 55%),
    rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.welcome-splash__stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(92vw, 520px);
  min-height: 180px;
  padding: 24px;
}

.welcome-splash__text {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-family: var(--font-display);
  line-height: 1.15;
}

.welcome-word {
  display: block;
  opacity: 0;
  transform: translateY(18px) scale(0.92);
  filter: blur(6px);
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.welcome-splash.is-active .welcome-word {
  animation: welcome-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.welcome-splash.is-active .welcome-word:nth-child(1) { animation-delay: 0.05s; }
.welcome-splash.is-active .welcome-word:nth-child(2) { animation-delay: 0.22s; }
.welcome-splash.is-active .welcome-word:nth-child(3) { animation-delay: 0.42s; }

.welcome-word--accent {
  font-size: clamp(18px, 4.8vw, 26px);
  font-weight: 600;
  color: var(--accent-2);
  letter-spacing: 0.01em;
}
.welcome-word--name {
  font-size: clamp(34px, 10vw, 56px);
  font-weight: 800;
  background: linear-gradient(135deg, #ff4d6d, #ffb3c6, #e8b86d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 24px rgba(255, 77, 109, 0.35));
}
.welcome-splash.is-bursting .welcome-word--name {
  animation: welcome-pop 0.45s ease forwards;
}

.heart-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.burst-heart {
  position: absolute;
  left: 0;
  top: 0;
  color: #ff4d6d;
  text-shadow: 0 0 16px rgba(255, 77, 109, 0.6);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.2);
  animation: heart-burst-out ease-out forwards;
  will-change: transform, opacity;
}
.burst-heart.alt { color: #ff8fab; }
.burst-heart.soft { color: #ffb3c6; }
.burst-heart.glow { color: #ff758f; filter: drop-shadow(0 0 8px rgba(255, 117, 143, 0.8)); }

@keyframes welcome-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}
@keyframes welcome-pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.08); }
}
@keyframes heart-burst-out {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.15);
  }
  12% { opacity: 1; }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)))
      rotate(var(--rot))
      scale(var(--scale, 1));
  }
}

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }
  .top h1 { font-size: clamp(24px, 7vw, 32px); }
  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .top-actions .btn { width: 100%; }
  .meta {
    margin-left: 0;
    width: 100%;
    font-size: 12px;
    order: 3;
  }
  .status-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    margin-bottom: 16px;
  }
  .status-bar .pill { justify-content: center; }
  .status-bar .meta { text-align: center; }
  .panel h2 { font-size: 18px; }
  .hint, .sub { font-size: 13px; }
  .row { flex-direction: column; }
  .row .btn { flex: 1 1 auto; width: 100%; }
  .row-form {
    grid-template-columns: 1fr;
  }
  .row-form .btn { width: 100%; }
  .admin-chip { font-size: 13px; max-width: 100%; }
  .login-card h1 { font-size: clamp(24px, 7vw, 32px); }
  .sub { margin-bottom: 22px; }
  input, textarea {
    font-size: 16px;
    padding: 15px 14px;
  }
  .glow {
    width: 100vw;
    height: 100vw;
    top: -30vw;
    right: -40vw;
  }
}

@media (max-width: 380px) {
  .brand { letter-spacing: 0.18em; }
  .welcome-word--name { font-size: clamp(30px, 11vw, 44px); }
}
