:root {
  --black: #070503;
  --graphite: #1f150e;
  --chocolate: #3d2b20;
  --bronze: #634634;
  --copper: #8a644d;
  --warm-copper: #b48363;
  --light-bronze: #d4af90;
  --ivory: #ede2d4;
  --accent: #ff6a00;
  --success: #a3ff9a;
  --info: #6ea8ff;
  --error: #ff5b5b;
  --ai: #c9a6ff;

  --font-display: "Outfit", sans-serif;
  --font-body: "Manrope", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  height: 100%;
  min-height: 100dvh;
  background: var(--black);
}

body {
  font-family: var(--font-body);
  color: var(--ivory);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  opacity: 0.04;
  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='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--app-h, 100svh);
  max-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 90% 45% at 50% 18%, rgba(255, 106, 0, 0.16), transparent 55%),
    radial-gradient(ellipse 70% 40% at 50% 72%, rgba(138, 100, 77, 0.18), transparent 55%),
    linear-gradient(180deg, var(--black) 0%, var(--graphite) 55%, #120c08 100%);
  overflow: hidden;
}

@media (min-width: 900px) {
  body {
    display: grid;
    place-items: center;
    background:
      radial-gradient(ellipse 50% 40% at 50% 30%, rgba(255, 106, 0, 0.08), transparent),
      #050403;
  }

  .app {
    position: relative;
    inset: auto;
    width: min(440px, 100%);
    height: min(880px, 96dvh);
    border-radius: 2rem;
    border: 1px solid rgba(180, 131, 99, 0.28);
    box-shadow:
      0 40px 100px rgba(0, 0, 0, 0.65),
      0 0 80px rgba(255, 106, 0, 0.08);
  }
}

/* ——— Top bar ——— */
.topbar {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  z-index: 2;
  animation: rise 0.7s var(--ease) both;
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  color: var(--light-bronze);
  border-radius: 50%;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

.icon-btn:hover {
  color: var(--ivory);
  background: rgba(255, 255, 255, 0.04);
}

.icon-btn svg {
  width: 1.35rem;
  height: 1.35rem;
}

.logo {
  justify-self: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  text-decoration: none;
  color: var(--ivory);
  text-shadow: 0 0 24px rgba(237, 226, 212, 0.25);
}

.logo span {
  color: var(--accent);
  background: linear-gradient(180deg, #ff8a33, var(--accent) 55%, var(--copper));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ——— Stage ——— */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(0.5rem, 3vh, 1.5rem);
  gap: clamp(0.65rem, 2vh, 1.25rem);
  text-align: center;
  z-index: 1;
  min-height: 0;
}

.stage__glow {
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  top: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 106, 0, 0.22), transparent 68%);
  filter: blur(36px);
  animation: breathe 5.5s ease-in-out infinite;
  pointer-events: none;
}

.infinity {
  position: relative;
  z-index: 0;
  width: min(78%, 300px);
  margin: 0;
  aspect-ratio: 1;
  animation: float-in 1s 0.1s var(--ease) both, float 7s 1s ease-in-out infinite;
  filter: drop-shadow(0 18px 36px rgba(255, 106, 0, 0.28));
  -webkit-mask-image: radial-gradient(ellipse 72% 68% at 50% 50%, #000 38%, transparent 72%);
  mask-image: radial-gradient(ellipse 72% 68% at 50% 50%, #000 38%, transparent 72%);
  transition: width 0.35s var(--ease), opacity 0.35s var(--ease);
}

.stage.has-reply .infinity {
  width: min(42%, 160px);
  opacity: 0.85;
}

.stage:has(.reply.is-final) .infinity {
  display: none;
}

.stage:has(.reply.is-final) .reply {
  max-height: 32vh;
}

.stage.has-reply .headline {
  display: none;
}

/* iPhone 12 mini: видимая высота ~630px вместе с панелью Safari */
@media (max-height: 740px) {
  .infinity {
    width: min(48%, 176px);
  }

  .stage {
    padding-top: 0;
    gap: 0.35rem;
  }

  .headline {
    font-size: 0.92rem;
    letter-spacing: 0.01em;
  }

  .mic {
    width: 4.5rem;
    height: 4.5rem;
  }

  .voice {
    gap: 0.4rem;
    margin-bottom: 0.2rem;
  }
}

.brief {
  width: min(100%, 22rem);
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  background: rgba(31, 21, 14, 0.75);
  border: 1px solid rgba(138, 100, 77, 0.4);
  text-align: left;
  z-index: 2;
  animation: rise 0.4s var(--ease) both;
}

.brief[hidden] {
  display: none;
}

.brief__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warm-copper);
}

.brief__count {
  color: var(--accent);
  letter-spacing: 0.04em;
}

.brief__fields {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.brief__fields li {
  display: grid;
  grid-template-columns: 1.1rem 4.5rem 1fr 1.4rem;
  gap: 0.4rem;
  align-items: baseline;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--light-bronze);
}

.brief__fields li.is-done {
  color: var(--ivory);
}

.brief__fields li.is-done .brief__mark {
  color: var(--success);
}

.brief__fields li.is-open .brief__mark {
  color: var(--accent);
}

.brief__fields li.is-empty {
  opacity: 0.45;
}

.brief__mark {
  font-size: 0.75rem;
}

.brief__label {
  color: var(--warm-copper);
}

.brief__value {
  white-space: normal;
}

.brief__clear {
  justify-self: end;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  color: var(--error);
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.brief__clear:hover {
  background: rgba(255, 91, 91, 0.15);
}

.brief__clear--empty {
  visibility: hidden;
}

.brief__value:empty::after {
  content: "—";
  opacity: 0.5;
}

.reply.is-final {
  max-height: 46vh;
}

.reply {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  width: min(100%, 22rem);
  max-height: 36vh;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: rgba(18, 12, 8, 0.94);
  border: 1px solid rgba(180, 131, 99, 0.45);
  backdrop-filter: blur(12px);
  text-align: left;
  animation: rise 0.4s var(--ease) both;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

@media (max-height: 800px) {
  .stage.has-reply .infinity {
    width: min(40%, 132px);
    margin-bottom: -2.6rem;
  }

  .stage.has-reply .reply {
    margin-top: 0;
  }

  .stage.has-reply .brief {
    min-height: 0;
    max-height: 38vh;
    overflow: auto;
  }

  .brief__fields li {
    font-size: 0.75rem;
  }
}

.infinity img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: screen;
}

.headline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(0.95rem, 3.8vw, 1.15rem);
  letter-spacing: 0.01em;
  line-height: 1.45;
  color: var(--light-bronze);
  max-width: 22rem;
  animation: rise 0.8s 0.2s var(--ease) both;
  transition: opacity 0.35s var(--ease);
}

.headline.is-dim {
  opacity: 0.35;
}

.reply[hidden] {
  display: none;
}

.reply.is-thinking {
  border-color: rgba(201, 166, 255, 0.45);
  color: var(--ai);
}

.reply__text {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ivory);
  white-space: pre-wrap;
}

.reply.is-thinking .reply__text {
  color: var(--light-bronze);
}

/* ——— Voice ——— */
.voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: auto;
  margin-bottom: clamp(0.25rem, 2vh, 1rem);
  animation: rise 0.8s 0.35s var(--ease) both;
}

.mic {
  position: relative;
  width: 5.75rem;
  height: 5.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--light-bronze);
  background: radial-gradient(circle at 40% 35%, rgba(61, 43, 32, 0.25), rgba(7, 5, 3, 0.7));
  border: 1.5px solid rgba(138, 100, 77, 0.55);
  box-shadow:
    0 0 0 8px rgba(138, 100, 77, 0.06),
    0 0 20px rgba(0, 0, 0, 0.35);
  opacity: 0.72;
  transition:
    transform 0.3s var(--ease),
    box-shadow 0.3s var(--ease),
    opacity 0.3s var(--ease),
    border-color 0.3s var(--ease),
    color 0.3s var(--ease);
}

.mic:hover {
  opacity: 0.92;
  color: var(--ivory);
  border-color: rgba(180, 131, 99, 0.75);
}

.mic:disabled {
  opacity: 0.45;
  cursor: wait;
  animation: none;
}

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

.mic svg {
  width: 1.7rem;
  height: 1.7rem;
  position: relative;
  z-index: 1;
}

.mic__ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 106, 0, 0.35);
  animation: ring 2.6s ease-out infinite;
  opacity: 0;
}

.mic__ring--delay {
  animation-delay: 1.3s;
}

.mic.is-active {
  color: var(--ivory);
  opacity: 1;
  border-color: var(--accent);
  background: radial-gradient(circle at 40% 35%, rgba(61, 43, 32, 0.35), rgba(7, 5, 3, 0.85));
  box-shadow:
    0 0 0 12px rgba(255, 106, 0, 0.14),
    0 0 48px rgba(255, 106, 0, 0.55),
    inset 0 0 28px rgba(255, 106, 0, 0.12);
  animation: none;
}

.mic.is-active .mic__ring {
  opacity: 1;
}

@keyframes mic-idle {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 8px rgba(138, 100, 77, 0.06),
      0 0 20px rgba(0, 0, 0, 0.35);
  }
  50% {
    transform: scale(1.03);
    box-shadow:
      0 0 0 12px rgba(255, 106, 0, 0.1),
      0 0 28px rgba(255, 106, 0, 0.18);
  }
}

.voice__prompt {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--ivory);
}

/* ——— Listen pill ——— */
.listen {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  background: rgba(31, 21, 14, 0.72);
  border: 1px solid rgba(138, 100, 77, 0.32);
  color: var(--light-bronze);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  backdrop-filter: blur(12px);
  animation: rise 0.8s 0.45s var(--ease) both;
  z-index: 2;
  opacity: 0.72;
  transition: opacity 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.listen.is-active {
  opacity: 1;
  border-color: rgba(255, 106, 0, 0.45);
  box-shadow: 0 0 24px rgba(255, 106, 0, 0.18);
}

.wave {
  display: none;
  align-items: center;
  gap: 2px;
  height: 14px;
}

.listen.is-active .wave {
  display: flex;
}

.wave i {
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
  animation: wave 0.9s ease-in-out infinite;
}

.wave i:nth-child(1) {
  height: 5px;
}
.wave i:nth-child(2) {
  height: 10px;
  animation-delay: 0.1s;
}
.wave i:nth-child(3) {
  height: 14px;
  animation-delay: 0.18s;
}
.wave i:nth-child(4) {
  height: 8px;
  animation-delay: 0.28s;
}
.wave i:nth-child(5) {
  height: 5px;
  animation-delay: 0.36s;
}

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

@keyframes float-in {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.08);
  }
}

@keyframes ring {
  0% {
    transform: scale(0.85);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes wave {
  0%,
  100% {
    transform: scaleY(0.55);
  }
  50% {
    transform: scaleY(1);
  }
}

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