@font-face {
  font-family: "BridgeDisplay";
  src: url("assets/text/ProstoOne-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "BridgeSans";
  src: url("assets/text/Roboto-VariableFont_wdth,wght.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #edf3f7;
  --bg-strong: #e6edf4;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --panel-soft: #f5f8fb;
  --text: #162132;
  --muted: #66758b;
  --line: rgba(22, 33, 50, 0.1);
  --line-strong: rgba(22, 33, 50, 0.16);
  --brand: #1463ff;
  --brand-strong: #0e49bc;
  --brand-soft: rgba(20, 99, 255, 0.12);
  --accent: #e8f0ff;
  --client-bubble: #ffffff;
  --agent-bubble: linear-gradient(180deg, #eef5ff 0%, #e6f0ff 100%);
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.12);
  --scroll-track: rgba(22, 33, 50, 0.08);
  --scroll-thumb: rgba(20, 99, 255, 0.34);
  --scroll-thumb-hover: rgba(20, 99, 255, 0.48);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1724;
  --bg-strong: #0a111b;
  --panel: rgba(17, 24, 39, 0.92);
  --panel-strong: #111827;
  --panel-soft: #182131;
  --text: #edf3ff;
  --muted: #9aacbf;
  --line: rgba(154, 172, 191, 0.18);
  --line-strong: rgba(154, 172, 191, 0.28);
  --brand: #53a2ff;
  --brand-strong: #2e7de0;
  --brand-soft: rgba(83, 162, 255, 0.16);
  --accent: rgba(83, 162, 255, 0.12);
  --client-bubble: #172132;
  --agent-bubble: linear-gradient(180deg, #172845 0%, #122239 100%);
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.36);
  --scroll-track: rgba(154, 172, 191, 0.1);
  --scroll-thumb: rgba(83, 162, 255, 0.32);
  --scroll-thumb-hover: rgba(83, 162, 255, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "BridgeSans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(20, 99, 255, 0.12), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

input[type="checkbox"] {
  accent-color: var(--brand);
}

button {
  border: 0;
  cursor: pointer;
}

.screen {
  display: none;
}

.screen.active {
  display: flex;
}

#auth-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 0 84px;
  position: relative;
}

.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 12, 20, 0.58);
  backdrop-filter: blur(10px);
  z-index: 40;
}

.modal {
  width: min(100%, 560px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.dialog-modal {
  padding: 28px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-shell {
  width: min(1100px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 24px;
  align-items: stretch;
}

.app-legal-footer,
.chat-legal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.app-legal-footer a,
.chat-legal-row a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.app-legal-footer a:hover,
.chat-legal-row a:hover {
  color: var(--brand);
}

.app-legal-footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  justify-content: center;
}

.auth-brand,
.auth-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.auth-brand {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.auth-brand h1 {
  margin: 0;
  font-family: "BridgeDisplay", "BridgeSans", sans-serif;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
}

.auth-brand p {
  margin: 0;
  max-width: 40ch;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.auth-card {
  padding: 32px;
  align-self: center;
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-card h2 {
  margin: 0;
  font-family: "BridgeDisplay", "BridgeSans", sans-serif;
  font-size: 28px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--text);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--brand), #3a8cff);
  color: #fff;
  padding: 14px 18px;
  font-weight: 700;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(20, 99, 255, 0.24);
}

.checkbox-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.checkbox-row input {
  margin-top: 3px;
}

.checkbox-row span {
  color: var(--text);
  line-height: 1.6;
}

#login-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--brand), #3a8cff);
  color: #fff;
  padding: 14px 18px;
  font-weight: 700;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(20, 99, 255, 0.24);
}

#login-btn:hover,
.composer-send-btn:hover {
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
}

.auth-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  color: var(--text);
  pointer-events: auto;
  animation: toast-enter 0.2s ease;
}

.toast i {
  margin-top: 2px;
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 14px;
}

.toast span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast.error i,
.toast.error strong {
  color: #dc2626;
}

.toast.success i,
.toast.success strong {
  color: #0f9f6e;
}

.toast.info i,
.toast.info strong {
  color: var(--brand);
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#chat-screen {
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.chat-header-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.chat-header h2 {
  margin: 0;
  font-family: "BridgeDisplay", "BridgeSans", sans-serif;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1;
}

.chat-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.ghost-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--text);
}

.messages-container {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(980px, calc(100% - 16px));
  margin: 0 auto;
  padding: 18px 12px 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.messages-container::-webkit-scrollbar {
  width: 12px;
}

.messages-container::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

.msg {
  max-width: min(78%, 640px);
  border-radius: 24px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.msg.client {
  margin-right: auto;
  background: var(--client-bubble);
}

.msg.agent {
  margin-left: auto;
  margin-right: 6px;
  background: var(--agent-bubble);
}

.msg-text {
  margin-bottom: 8px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.msg-author {
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.msg-time {
  font-size: 12px;
  color: var(--muted);
}

.msg-file,
.msg img,
.msg video,
.msg audio {
  margin-top: 10px;
}

.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.msg img,
.msg video {
  max-width: 100%;
  border-radius: 16px;
}

.msg audio {
  width: 100%;
}

.input-area {
  width: min(980px, calc(100% - 20px));
  margin: 0 auto 14px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  gap: 10px;
  position: sticky;
  bottom: 10px;
  z-index: 9;
}

.chat-legal-row {
  padding: 0 4px 2px;
}

.consent-modal h3 {
  margin: 16px 0 8px;
  font-family: "BridgeDisplay", "BridgeSans", sans-serif;
  font-size: 30px;
}

.consent-lead {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.consent-row {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.consent-links {
  margin-top: 4px;
  margin-bottom: 20px;
}

body.chat-mode {
  overflow: hidden;
}

.composer-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 8px;
  border-radius: 22px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.composer-shell.dragover {
  border-color: var(--brand);
  background: var(--accent);
}

.composer-icon-btn,
.composer-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-icon-btn {
  background: transparent;
  color: var(--muted);
}

.composer-send-btn {
  background: linear-gradient(135deg, var(--brand), #3a8cff);
  color: #fff;
  box-shadow: 0 12px 26px rgba(20, 99, 255, 0.22);
}

#message-input {
  width: 100%;
  min-height: 46px;
  max-height: 140px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 0;
  outline: none;
  line-height: 1.5;
}

.pending-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  min-width: 0;
}

.pending-chip i {
  color: var(--brand);
}

.pending-chip-copy {
  min-width: 0;
}

.pending-chip-copy strong,
.pending-chip-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-chip-copy strong {
  font-size: 13px;
}

.pending-chip-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pending-chip button {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.copyright-toast {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(420px, calc(100vw - 28px));
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.copyright-toast-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.copyright-toast-copy strong {
  font-size: 14px;
}

.copyright-toast-copy a {
  color: var(--brand);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding: 24px 0;
  }
}

@media (max-width: 680px) {
  .auth-brand,
  .auth-card {
    border-radius: 24px;
    padding: 22px;
  }

  #auth-screen {
    padding: 18px 0 88px;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .chat-header-main {
    display: grid;
    gap: 4px;
  }

  .chat-header-actions {
    gap: 8px;
  }

  .status {
    display: none;
  }

  .messages-container,
  .input-area {
    width: calc(100% - 12px);
  }

  .messages-container {
    padding: 14px 10px 10px 8px;
  }

  .input-area {
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 22px;
  }

  .chat-legal-row {
    gap: 8px 12px;
  }

  .dialog-modal {
    padding: 22px;
    border-radius: 24px;
  }

  .consent-modal h3 {
    font-size: 24px;
  }

  .msg {
    max-width: 100%;
  }

  .msg.agent {
    margin-right: 2px;
  }

  .composer-shell {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: 6px;
    border-radius: 18px;
  }

  .composer-icon-btn,
  .composer-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    flex: 0 0 40px;
  }

  #message-input {
    min-height: 40px;
    padding: 9px 0;
    font-size: 16px;
    line-height: 1.4;
  }

  .pending-files {
    gap: 6px;
  }

  .pending-chip {
    padding: 8px 10px;
    border-radius: 14px;
    gap: 8px;
  }

  .pending-chip button {
    width: 26px;
    height: 26px;
    border-radius: 10px;
  }

  .toast-stack {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  .copyright-toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .messages-container,
  .input-area {
    width: calc(100% - 8px);
  }

  .messages-container {
    padding: 12px 8px 8px 6px;
  }

  .chat-header {
    padding: 10px 12px;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .ghost-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 14px;
  }

  .composer-shell {
    gap: 4px;
    padding: 5px;
  }

  .composer-icon-btn,
  .composer-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }
}
