:root {
  --bg: #070b14;
  --surface: #101726;
  --surface-alt: #141f34;
  --text: #f5f8ff;
  --muted: #9cb0d7;
  --border: #273659;
}

* {
  box-sizing: border-box;
}

/* Dashboard only: keep layout within the viewport so the chat composer stays visible */
body:has(.app-shell) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: Outfit, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(108, 66, 255, 0.16), transparent 30%),
    radial-gradient(circle at 82% 30%, rgba(0, 235, 186, 0.14), transparent 24%),
    radial-gradient(circle at 55% 84%, rgba(255, 106, 53, 0.18), transparent 30%),
    var(--bg);
  color: var(--text);
}

.login-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vh, 36px) clamp(18px, 3vw, 48px);
  overflow-x: hidden;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(109, 81, 255, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 60%, rgba(0, 235, 186, 0.08), transparent 50%),
    linear-gradient(165deg, rgba(7, 11, 20, 0.4) 0%, transparent 45%);
}

.login-layout {
  position: relative;
  z-index: 1;
  width: min(1540px, 94vw);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, min(560px, 46vw));
  gap: clamp(36px, 5.5vw, 88px);
  align-items: center;
}

.login-hero {
  padding-right: clamp(0px, 2vw, 32px);
}

.login-hero-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(22px, 3vw, 40px);
  margin-bottom: clamp(28px, 4vh, 48px);
}

.login-hero-logo {
  display: block;
  width: auto;
  height: auto;
  max-height: clamp(128px, min(22vh, 20vw), 200px);
  max-width: min(620px, 52vw);
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 14px 40px rgba(0, 0, 0, 0.42));
}

.login-hero-logo-divider {
  width: 1px;
  height: clamp(88px, min(18vh, 14vw), 140px);
  align-self: center;
  background: linear-gradient(180deg, transparent, rgba(156, 176, 215, 0.55), transparent);
}

.login-hero-eyebrow {
  margin: 0 0 14px;
  font-size: clamp(13px, 1.35vw, 16px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c8d6f5;
  font-weight: 600;
}

.login-hero-title {
  margin: 0;
  font-family: Sora, sans-serif;
  font-size: clamp(34px, 4.2vw, 56px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.login-hero-lede {
  margin: clamp(16px, 2.2vh, 24px) 0 0;
  max-width: min(52ch, 100%);
  color: var(--muted);
  font-size: clamp(18px, 1.85vw, 23px);
  line-height: 1.55;
}

.login-hero-points {
  margin: clamp(24px, 3vh, 36px) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: clamp(12px, 1.8vh, 18px);
  max-width: min(50ch, 100%);
}

.login-hero-points li {
  position: relative;
  padding-left: clamp(24px, 2.5vw, 30px);
  color: #d6e4ff;
  font-size: clamp(16px, 1.65vw, 20px);
  line-height: 1.5;
}

.login-hero-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: clamp(9px, 1vw, 11px);
  height: clamp(9px, 1vw, 11px);
  border-radius: 999px;
  background: linear-gradient(135deg, #6d51ff, #00ebba);
  box-shadow: 0 0 0 3px rgba(109, 81, 255, 0.22);
}

.login-card {
  position: relative;
  width: 100%;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(18, 28, 47, 0.98), rgba(10, 16, 29, 0.98));
  border: 1px solid var(--border);
  padding: clamp(40px, 4.5vh, 52px) clamp(40px, 4vw, 52px) clamp(44px, 5vh, 56px);
  box-shadow:
    0 26px 68px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  overflow: hidden;
}

.login-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #6d51ff, #00d4aa, #ff6a35);
  opacity: 0.95;
}

.login-card-title {
  margin: 8px 0 0;
  font-family: Sora, sans-serif;
  font-size: clamp(28px, 2.4vw, 34px);
  font-weight: 700;
}

.login-card-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 1.5vw, 19px);
  line-height: 1.45;
}

.login-form {
  margin-top: clamp(26px, 3.5vh, 34px);
  display: grid;
  gap: 14px;
}

.login-form label {
  font-size: clamp(16px, 1.35vw, 18px);
  font-weight: 600;
  color: #c5d6ec;
}

.login-form > input {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1222;
  color: var(--text);
  font-size: clamp(17px, 1.45vw, 19px);
  padding: 16px 18px;
}

.login-password-field {
  position: relative;
  display: block;
}

.login-password-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1222;
  color: var(--text);
  font-size: clamp(17px, 1.45vw, 19px);
  padding: 16px 54px 16px 18px;
}

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #a8bddf;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.login-password-toggle:hover {
  color: #e8f0ff;
  background: rgba(255, 255, 255, 0.06);
}

.login-password-toggle:focus-visible {
  outline: 2px solid #7b4dff;
  outline-offset: 2px;
}

.login-password-toggle svg {
  grid-area: 1 / 1;
}

.login-form button[type="submit"] {
  margin-top: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(90deg, #6d51ff, #ff6a35);
  color: #fff;
  font-weight: 700;
  font-size: clamp(17px, 1.45vw, 19px);
  padding: 16px 18px;
  cursor: pointer;
}

.error-box {
  background: rgba(255, 78, 78, 0.12);
  border: 1px solid rgba(255, 78, 78, 0.5);
  border-radius: 14px;
  color: #ffc8c8;
  padding: 12px 14px;
  margin-top: 16px;
  font-size: clamp(15px, 1.35vw, 17px);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
    width: min(640px, 100%);
    gap: 36px;
  }

  .login-hero {
    padding-right: 0;
    text-align: center;
  }

  .login-hero-logos {
    justify-content: center;
  }

  .login-hero-logo {
    object-position: center;
    max-width: min(520px, 90vw);
    max-height: min(172px, 32vw);
  }

  .login-hero-logo-divider {
    height: min(120px, 26vw);
  }

  .login-hero-lede,
  .login-hero-points {
    margin-left: auto;
    margin-right: auto;
    text-align: left;
  }

  .login-hero-points li {
    text-align: left;
  }
}

.app-shell {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: minmax(0, 1fr);
  box-sizing: border-box;
}

.history-sidebar {
  background: linear-gradient(180deg, rgba(12, 20, 36, 0.98), rgba(8, 14, 26, 0.98));
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-family: Sora, sans-serif;
}

.brand p,
.brand small {
  margin: 6px 0 0;
  color: var(--muted);
}

.history-title {
  margin: 0 2px -6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7c8ea;
}

.history-list {
  display: grid;
  gap: 10px;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.history-entry {
  position: relative;
}

.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid #2d4068;
  border-radius: 12px;
  background: linear-gradient(180deg, #12213a, #0d1b33);
  color: #fff;
  cursor: pointer;
  padding: 12px;
}

.history-item h4 {
  margin: 0;
  font-size: 14px;
}

.history-item p {
  margin: 6px 0;
  font-size: 12px;
  color: #d6e4ff;
}

.history-item small {
  color: #9cb0d7;
}

.history-item.active {
  border-color: #7b4dff;
  box-shadow: 0 0 0 2px rgba(123, 77, 255, 0.28);
}

.history-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid rgba(255, 120, 120, 0.82);
  background: linear-gradient(145deg, rgba(121, 17, 17, 0.94), rgba(86, 8, 24, 0.94));
  color: #ffe9e9;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  line-height: 20px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 59, 59, 0.25), 0 6px 14px rgba(0, 0, 0, 0.4);
}

.history-delete:hover {
  background: linear-gradient(145deg, rgba(168, 20, 20, 0.96), rgba(122, 15, 32, 0.95));
  border-color: rgba(255, 150, 150, 0.95);
  transform: scale(1.05);
}

.history-delete:focus-visible {
  outline: 2px solid #ff7d7d;
  outline-offset: 2px;
}

.toast-area {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1100;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
}

.toast {
  border-radius: 12px;
  border: 1px solid #4c679d;
  background: linear-gradient(180deg, rgba(22, 39, 66, 0.98), rgba(10, 22, 42, 0.98));
  color: #eef5ff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 11px 12px;
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(4px);
}

.toast-success {
  border-color: rgba(54, 236, 166, 0.88);
  background: linear-gradient(180deg, rgba(8, 74, 58, 0.98), rgba(8, 48, 39, 0.98));
  color: #d7fff0;
}

.toast-error {
  border-color: rgba(255, 114, 114, 0.95);
  background: linear-gradient(180deg, rgba(103, 22, 36, 0.98), rgba(67, 15, 30, 0.98));
  color: #ffe9ea;
}

.toast-info {
  border-color: rgba(124, 162, 255, 0.95);
  background: linear-gradient(180deg, rgba(32, 57, 99, 0.98), rgba(20, 39, 75, 0.98));
  color: #ebf3ff;
}

.toast-confirm .toast-text {
  color: #ffeff1;
  margin-bottom: 9px;
  font-weight: 600;
}

.toast-danger {
  border-color: rgba(255, 118, 118, 0.98);
  background: linear-gradient(180deg, rgba(97, 18, 30, 0.99), rgba(63, 9, 22, 0.99));
  box-shadow: 0 0 0 1px rgba(255, 72, 92, 0.3), 0 18px 42px rgba(0, 0, 0, 0.55);
}

.toast-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-actions button {
  border: none;
  border-radius: 9px;
  padding: 7px 11px;
  font-weight: 600;
  cursor: pointer;
}

.toast-btn-cancel {
  background: #314774;
  color: #edf3ff;
}

.toast-btn-delete {
  background: linear-gradient(90deg, #dc1d41, #ff4d32);
  color: #fff;
  box-shadow: 0 6px 14px rgba(178, 17, 45, 0.42);
}

.toast-btn-delete:hover {
  background: linear-gradient(90deg, #f0294f, #ff5d37);
}

.toast-hide {
  opacity: 0;
  transform: translateY(-6px);
}

.history-empty {
  color: var(--muted);
  font-size: 14px;
}

.main-pane {
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.personas-top {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(20, 31, 52, 0.95), rgba(12, 20, 35, 0.95));
}

.personas-top h2 {
  margin: 0 0 12px;
  font-family: Sora, sans-serif;
  font-size: 18px;
}

.personas-top-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.secondary-action {
  border: 1px solid #4f6ea8;
  border-radius: 10px;
  background: linear-gradient(180deg, #173056, #112542);
  color: #e7f0ff;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.secondary-action:disabled {
  opacity: 0.72;
  cursor: wait;
}

.persona-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.persona-card {
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--persona-color), #1f2e4d 60%);
  border-radius: 14px;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--persona-color), #18263f 78%),
    #111a2c
  );
  color: #fff;
  cursor: pointer;
  padding: 14px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.persona-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
}

.persona-card.active {
  border-color: color-mix(in srgb, var(--persona-color), #fff 30%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--persona-color), transparent 60%);
}

.persona-card.pending {
  transform: scale(0.99);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--persona-color), #ffffff 55%);
  opacity: 0.88;
}

.persona-card:disabled {
  cursor: wait;
}

.persona-card h3 {
  margin: 0;
  font-size: 16px;
}

.persona-card p {
  margin: 8px 0 0;
  font-size: 13px;
  color: #e7edff;
  opacity: 0.94;
}

.persona-setup-form {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: grid;
  gap: 14px;
}

.persona-setup-form.is-locked {
  opacity: 0.58;
}

.persona-setup-form textarea {
  resize: vertical;
  min-height: 56px;
  border-radius: 10px;
  border: 1px solid #2d4068;
  background: #0a1322;
  color: #fff;
  padding: 10px;
  font-size: 14px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.feature-control {
  display: grid;
  gap: 8px;
  border: 1px solid #2d4068;
  border-radius: 10px;
  padding: 10px;
  background: rgba(12, 20, 34, 0.7);
  color: #dce9ff;
  font-size: 13px;
}

.feature-control > span {
  font-weight: 600;
  color: #f1f6ff;
}

.feature-control select {
  width: 100%;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #375182;
  background: #0d1729;
  color: #eef5ff;
  padding: 8px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.slider-row input[type="range"] {
  width: 100%;
}

.slider-row output {
  min-width: 24px;
  text-align: right;
  color: #8ee7d4;
  font-weight: 700;
}


#startSimulationBtn {
  justify-self: start;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(90deg, #7b4dff, #ff6f41);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
}

.sidebar-partners {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 18px;
  padding: 16px 12px;
  border: 1px solid rgba(90, 118, 168, 0.5);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(22, 34, 56, 0.95), rgba(12, 20, 36, 0.9));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.sidebar-partner-logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  object-position: center;
  opacity: 0.98;
  transition: opacity 160ms ease, filter 160ms ease;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.4));
}

.sidebar-partner-logo:hover {
  opacity: 1;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, 0.5));
}

.sidebar-partner-logo--unipd {
  max-width: 132px;
  height: 50px;
}

.manager-box {
  padding-top: 0;
  border-top: none;
}

.manager-box p {
  margin: 0;
  color: var(--muted);
}

.manager-box a {
  display: inline-block;
  margin-top: 8px;
  color: #8ac8ff;
  text-decoration: none;
}

.chat-pane {
  padding: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 31, 52, 0.95), rgba(12, 20, 35, 0.95));
  padding: 16px;
}

.chat-header h2 {
  margin: 0;
  font-family: Sora, sans-serif;
}

.chat-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.chat-log {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(11, 17, 30, 0.82);
  padding: 16px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}

.bubble {
  max-width: 85%;
  border-radius: 14px;
  padding: 12px;
}

.bubble .role {
  display: block;
  font-size: 12px;
  color: #c5d6ff;
  margin-bottom: 6px;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.4;
}

.bubble.user {
  justify-self: end;
  background: linear-gradient(135deg, #2448ff, #4c2cf7);
}

.bubble.assistant {
  justify-self: start;
  background: linear-gradient(135deg, #193043, #0f6f6a);
}

.bubble.typing {
  min-width: 84px;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 14px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(219, 246, 255, 0.92);
  animation: typing-bounce 1.1s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.empty-state {
  place-self: center;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  flex-shrink: 0;
  align-self: stretch;
}

.chat-form textarea {
  resize: vertical;
  min-height: 76px;
  max-height: 200px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a1322;
  color: #fff;
  font-size: 15px;
  padding: 12px;
}

.chat-form button {
  border: none;
  border-radius: 12px;
  padding: 0 24px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(90deg, #7b4dff, #ff6f41);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .history-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: min(280px, 36vh);
    flex: 0 1 auto;
  }

  .persona-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .persona-list {
    grid-template-columns: 1fr;
  }
}
