@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #f4f1ea;
  --ink: #1d1b18;
  --muted: #6d675d;
  --surface: #fffdf8;
  --field: #f6f2ea;
  --line: rgba(29, 27, 24, 0.1);
  --coral: #ff6a4d;
  --pink: #e24bb5;
  --violet: #6d4dff;
  --lime: #b8e62f;
  --danger: #e5484d;
  --screen: #0f0f10;
  --glass: rgba(24, 22, 28, 0.8);
  --glass-ink: #f3efe8;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 40px 80px -32px rgba(60, 30, 110, 0.35), 0 14px 28px -16px rgba(60, 30, 110, 0.22);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius-card: 32px;
  --radius-control: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131116;
    --ink: #f3efe8;
    --muted: #a8a094;
    --surface: #1d1a21;
    --field: #26222b;
    --line: rgba(243, 239, 232, 0.1);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 40px 80px -32px rgba(0, 0, 0, 0.7);
  }
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Figtree", ui-sans-serif, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body[data-view="viewer"] {
  background: var(--screen);
  overflow: hidden;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  isolation: isolate;
}

.aura {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: bloom 1.6s var(--ease-out) both;
}

.blob.coral {
  width: 520px;
  height: 520px;
  left: -160px;
  top: -180px;
  background: radial-gradient(circle at 40% 40%, var(--coral), transparent 68%);
}

.blob.violet {
  width: 620px;
  height: 620px;
  right: -220px;
  bottom: -240px;
  background: radial-gradient(circle at 50% 50%, var(--violet), transparent 66%);
  animation-delay: 0.08s;
}

.blob.lime {
  width: 300px;
  height: 300px;
  right: 12%;
  top: 14%;
  background: radial-gradient(circle, var(--lime), transparent 70%);
  opacity: 0.4;
  animation-delay: 0.16s;
}

.card {
  width: min(100%, 368px);
  padding: 36px 28px 28px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  animation: rise 0.7s var(--ease-out) both;
  transition: transform 0.28s var(--ease-out), opacity 0.28s ease;
}

.card > * {
  animation: fade-up 0.6s var(--ease-out) both;
}

.card > :nth-child(2) { animation-delay: 0.06s; }
.card > :nth-child(3) { animation-delay: 0.12s; }
.card > :nth-child(5) { animation-delay: 0.18s; }

.card.shake {
  animation: shake 0.44s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.card.leaving {
  transform: scale(1.04);
  opacity: 0;
}

.emblem {
  align-self: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  box-shadow: 0 16px 30px -12px rgba(226, 75, 181, 0.55);
  animation: pop 0.75s var(--ease-spring) 0.1s both;
}

.emblem svg {
  display: block;
  stroke: none;
}

.emblem svg g {
  stroke: #fff;
}

h1 {
  margin: 6px 0 8px;
  text-align: center;
  font-family: "EB Garamond", ui-serif, serif;
  font-weight: 500;
  font-size: clamp(2.8rem, 12vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  border-radius: var(--radius-control);
  background: var(--field);
  box-shadow: 0 0 0 1px var(--line) inset;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.field:focus-within {
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--violet) inset, 0 0 0 6px rgba(109, 77, 255, 0.14);
}

.field-icon {
  width: 20px;
  height: 20px;
  margin-left: 16px;
  color: var(--muted);
  flex: none;
}

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px 0 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 500 17px/1 "Figtree", ui-sans-serif, sans-serif;
  letter-spacing: 0.01em;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.reveal {
  width: 44px;
  height: 44px;
  margin-right: 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s var(--ease-spring);
}

.reveal:hover {
  background: var(--line);
  color: var(--ink);
}

.reveal:active {
  transform: scale(0.9);
}

.reveal svg {
  width: 20px;
  height: 20px;
}

.reveal .eye-closed,
.reveal[aria-pressed="true"] .eye-open {
  display: none;
}

.reveal[aria-pressed="true"] .eye-closed {
  display: block;
}

.message {
  margin: -4px 4px 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  opacity: 0;
  transition: max-height 0.3s var(--ease-out), opacity 0.2s ease, margin 0.3s var(--ease-out);
}

.message.visible {
  max-height: 60px;
  margin: 0 4px;
  opacity: 1;
}

.primary {
  position: relative;
  height: 56px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--radius-control);
  background: linear-gradient(135deg, var(--ink), #3a2f52);
  color: #fffdf8;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  overflow: hidden;
  box-shadow: 0 14px 26px -14px rgba(58, 47, 82, 0.8);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease, filter 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .primary {
    background: linear-gradient(135deg, var(--violet), var(--pink));
    color: #fff;
  }
}

.primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.22) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease-out);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px -14px rgba(109, 77, 255, 0.7);
}

.primary:hover::before {
  transform: translateX(120%);
}

.primary:active {
  transform: scale(0.97);
}

.primary:focus-visible,
.tool:focus-visible,
.handle:focus-visible,
.send:focus-visible,
.reveal:focus-visible,
.toast button:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

.primary .arrow {
  width: 20px;
  height: 20px;
  transition: transform 0.25s var(--ease-spring);
}

.primary:hover .arrow {
  transform: translateX(4px);
}

.primary .busy-ring {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--lime);
  opacity: 0;
}

.primary.busy .label,
.primary.busy .arrow {
  opacity: 0;
}

.primary.busy .busy-ring {
  opacity: 1;
  animation: spin 0.8s linear infinite;
}

.primary:disabled {
  cursor: default;
}

.viewer {
  position: fixed;
  left: 0;
  top: var(--viewport-top, 0px);
  width: 100%;
  height: var(--viewport-h, 100dvh);
  background: var(--screen);
  overflow: hidden;
  touch-action: none;
  animation: viewer-in 0.45s var(--ease-out) both;
}

#screen {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sink {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  pointer-events: none;
}

.bar {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
}

.handle {
  width: 76px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  transition: opacity 0.2s ease;
}

.handle::before {
  content: "";
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.tools {
  position: absolute;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--glass-ink);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-140%) scale(0.92);
  pointer-events: none;
  transition: transform 0.38s var(--ease-spring), opacity 0.2s ease;
}

.bar.open .tools {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.bar.open .handle {
  opacity: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin: 0 6px 0 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(184, 230, 47, 0.18);
}

.status-dot.offline {
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(255, 106, 77, 0.2);
}

.tool {
  height: 38px;
  padding: 0 14px 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.18s var(--ease-spring);
}

.tool svg {
  width: 17px;
  height: 17px;
}

.tool:hover,
.tool[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
}

.tool:active {
  transform: scale(0.94);
}

.tool.danger:hover {
  background: rgba(229, 72, 77, 0.28);
}

.touch-only {
  display: none;
}

@media (pointer: coarse) {
  .touch-only {
    display: flex;
  }

  .tool span {
    display: none;
  }

  .tool {
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
  }

  .handle {
    width: 96px;
    height: 28px;
  }
}

.compose {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line);
  animation: slide-up 0.32s var(--ease-out) both;
}

.compose textarea {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 11px 16px;
  border: 0;
  border-radius: 22px;
  outline: 0;
  resize: none;
  background: var(--field);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line) inset;
  font: 400 16px/1.35 "Figtree", ui-sans-serif, sans-serif;
}

.compose textarea:focus {
  box-shadow: 0 0 0 2px var(--violet) inset;
}

.send {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--pink));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px -10px rgba(109, 77, 255, 0.8);
  transition: transform 0.2s var(--ease-spring);
}

.send:active {
  transform: scale(0.88) rotate(-8deg);
}

.send svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(15, 15, 16, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.overlay-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 14px 16px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--glass-ink);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.8);
  transform: scale(0.94);
  transition: transform 0.35s var(--ease-spring);
}

.overlay.show .overlay-pill {
  transform: none;
}

.ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--lime);
  animation: spin 0.8s linear infinite;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(18px + var(--compose-h, 0px));
  z-index: 5;
  max-width: min(92vw, 520px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--glass-ink);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.75);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 24px) scale(0.96);
  transition: transform 0.36s var(--ease-spring), opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-action {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--lime);
  color: #1d1b18;
  font-weight: 700;
  flex: none;
}

.toast-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  flex: none;
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.96);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-14deg);
  }
}

@keyframes bloom {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}

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

@keyframes viewer-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }

  .ring,
  .primary.busy .busy-ring {
    animation-duration: 1.6s !important;
  }
}
