:root {
  --bg: #07101e;
  --bg-accent: #10233b;
  --panel: rgba(9, 17, 31, 0.9);
  --panel-strong: rgba(13, 25, 43, 0.98);
  --bubble: #162336;
  --bubble-user: rgba(31, 94, 255, 0.24);
  --text: #e7eef8;
  --muted: #93a4bb;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --button: #1f5eff;
  --button-hover: #174ad1;
  --button-secondary: #1a2637;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, rgba(31, 94, 255, 0.22), transparent 26%),
    radial-gradient(circle at 82% 18%, rgba(29, 197, 255, 0.12), transparent 22%),
    radial-gradient(circle at center bottom, rgba(9, 136, 94, 0.1), transparent 30%),
    linear-gradient(180deg, #0d1728 0%, #060b14 100%);
}

.v2-shell {
  height: 100svh;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
}

.v2-phone {
  position: relative;
  width: 100%;
  max-width: 438px;
  height: min(864px, calc(100svh - 56px));
  max-height: min(864px, calc(100svh - 56px));
  max-height: min(864px, calc(100dvh - 56px));
  background:
    linear-gradient(180deg, rgba(11, 19, 35, 0.98) 0%, rgba(8, 15, 28, 0.98) 100%);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.v2-phone::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(31, 94, 255, 0.14), transparent 32%),
    radial-gradient(circle at 100% 20%, rgba(6, 182, 212, 0.1), transparent 24%);
  pointer-events: none;
}

.v2-topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 15, 28, 0.92);
  backdrop-filter: blur(14px);
}

.v2-history-button {
  margin-left: auto;
  min-width: 136px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.26), transparent 34%),
    linear-gradient(180deg, #2e73ff 0%, #1f5eff 58%, #1448c6 100%);
  border: 1px solid rgba(62, 132, 255, 0.52);
  box-shadow:
    0 0 0 2px rgba(31, 94, 255, 0.18),
    0 12px 26px rgba(31, 94, 255, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.v2-history-button:hover,
.v2-history-button:focus-visible {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.3), transparent 36%),
    linear-gradient(180deg, #3a7dff 0%, #2a69ff 56%, #1b53db 100%);
  border-color: rgba(115, 169, 255, 0.78);
  box-shadow:
    0 0 0 3px rgba(31, 94, 255, 0.22),
    0 16px 30px rgba(31, 94, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.v2-avatar-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  flex: 0 0 auto;
}

.v2-topbar-copy {
  display: grid;
  gap: 2px;
  line-height: 1.1;
}

.v2-topbar-copy strong {
  font-size: 15px;
  font-weight: 800;
}

.v2-topbar-copy span {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #87f0c6;
}

.v2-messages {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.v2-date-chip {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
}

.v2-msg,
.v2-typing {
  max-width: 92%;
}

.v2-msg {
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-line;
  animation: v2FadeIn 220ms ease;
}

.v2-msg.bot {
  align-self: flex-start;
  background: var(--bubble);
  border-top-left-radius: 8px;
}

.v2-msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border-top-right-radius: 8px;
}

.v2-msg-body {
  position: relative;
  z-index: 1;
}

.v2-image-card {
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: #0d213a;
}

.v2-hero {
  position: relative;
  width: 100%;
  height: 260px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 72%, rgba(72, 211, 132, 0.14) 0 18%, transparent 19%),
    radial-gradient(circle at 66% 22%, rgba(255, 255, 255, 0.06) 0 14%, transparent 15%),
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.04) 0 14%, transparent 15%),
    linear-gradient(140deg, #04316e 0%, #073c7c 22%, #0f8c6b 48%, #074080 66%, #119d44 100%);
}

.v2-hero::before,
.v2-hero::after {
  content: "";
  position: absolute;
  inset: -20% -10%;
  background:
    radial-gradient(circle at 18% 65%, transparent 0 10%, rgba(255, 255, 255, 0.06) 10.2% 10.8%, transparent 11%),
    radial-gradient(circle at 78% 18%, transparent 0 8%, rgba(255, 255, 255, 0.05) 8.2% 8.8%, transparent 9%),
    radial-gradient(circle at 28% 15%, transparent 0 8%, rgba(255, 255, 255, 0.04) 8.2% 8.8%, transparent 9%);
  pointer-events: none;
}

.v2-wave {
  position: absolute;
  width: 140%;
  height: 140%;
  left: -18%;
  top: -8%;
  border-radius: 50%;
  transform: rotate(-18deg);
  border: 34px solid transparent;
}

.v2-wave.wave-1 {
  border-top-color: rgba(0, 255, 145, 0.18);
}

.v2-wave.wave-2 {
  border-top-color: rgba(0, 170, 255, 0.22);
  top: -3%;
  left: -10%;
}

.v2-wave.wave-3 {
  border-top-color: rgba(0, 255, 145, 0.14);
  top: 10%;
  left: 16%;
}

.v2-check {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%) rotate(-45deg);
  width: 150px;
  height: 90px;
  border-left: 24px solid #fff;
  border-bottom: 24px solid #fff;
  border-radius: 6px;
}

.v2-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  width: 68px;
  padding: 12px 14px;
  background: var(--bubble);
  border-radius: 18px;
  border-top-left-radius: 8px;
  animation: v2FadeIn 180ms ease;
}

.v2-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: #95a5bc;
  animation: v2Blink 1s infinite ease-in-out;
}

.v2-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.v2-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

.v2-actions-wrap {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 15, 28, 0.18), rgba(8, 15, 28, 0.98) 20%);
  backdrop-filter: blur(16px);
  box-shadow: 0 -16px 40px rgba(3, 8, 18, 0.32);
}

.v2-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.v2-progress span {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.v2-progress span.active {
  background: linear-gradient(90deg, #1f5eff, #13b6b0);
}

.v2-actions {
  display: grid;
  gap: 6px;
}

.hidden {
  display: none !important;
}

.v2-chat-entry {
  margin-top: 8px;
}

.v2-chat-entry .v2-btn {
  width: 100%;
}

.v2-composer {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.v2-composer-text {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 18, 30, 0.95);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}

.v2-composer-text::placeholder {
  color: var(--muted);
}

.v2-composer-meta {
  min-height: 0;
}

.v2-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
}

.v2-file-chip button {
  border: 0;
  border-radius: 8px;
  padding: 2px 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font: inherit;
}

.v2-composer-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

#v2-composer-attach {
  min-width: 46px;
  padding-left: 12px;
  padding-right: 12px;
}

.v2-msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.v2-msg-attachment:hover,
.v2-msg-attachment:focus-visible {
  border-color: rgba(142, 220, 255, 0.5);
}

.v2-btn {
  border: 0;
  border-radius: 13px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--button);
  box-shadow: 0 12px 28px rgba(31, 94, 255, 0.24);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.v2-btn:hover,
.v2-btn:focus-visible {
  background: var(--button-hover);
  transform: translateY(-1px);
}

.v2-btn.secondary {
  background: var(--button-secondary);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line-strong);
}

.v2-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 9, 19, 0.72);
  backdrop-filter: blur(6px);
}

.v2-overlay-card {
  width: min(420px, 100%);
  max-height: min(82vh, 860px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #0e182a 0%, #0a1220 100%);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45);
}

.v2-results-head {
  flex: 0 0 auto;
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 18, 32, 0.94);
  backdrop-filter: blur(14px);
}

.v2-results-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px 12px;
}

.v2-results-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8edcff;
}

.v2-results-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.v2-results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.v2-results-image-wrap {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.v2-results-image {
  display: block;
  width: 100%;
  height: auto;
}

.v2-results-empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--muted);
  text-align: center;
}

.v2-results-actions {
  position: sticky;
  bottom: 0;
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  margin-top: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.82), rgba(10, 18, 32, 0.98) 24%);
  backdrop-filter: blur(14px);
}

.v2-results-actions .v2-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.v2-softask-card .v2-results-title {
  font-size: 21px;
  line-height: 1.2;
}

.v2-softask-copy {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.v2-softask-actions {
  display: grid;
  gap: 8px;
  justify-content: stretch;
}

@keyframes v2Blink {
  0%, 80%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes v2FadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .v2-shell {
    display: block;
    height: 100svh;
    min-height: 100svh;
    min-height: 100dvh;
    padding: 0;
  }

  .v2-phone {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    height: 100svh;
    max-height: none;
    min-height: 100svh;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .v2-topbar {
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }

  .v2-actions-wrap {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .v2-history-button {
    min-width: 124px;
    min-height: 34px;
    padding: 0 13px;
    font-size: 12px;
  }

  .v2-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .v2-composer-actions {
    grid-template-columns: 1fr auto;
  }

  .v2-composer-text {
    font-size: 16px;
  }

  .v2-overlay-card {
    width: 100%;
    max-height: 86vh;
    border-radius: 24px 24px 0 0;
  }

  .v2-results-head {
    padding-top: 20px;
  }

  .v2-results-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .v2-results-actions {
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}
