* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #070711;
  color: #f8fafc;
}

.hidden {
  display: none !important;
}

/* LOGIN */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.35), transparent 35%),
    radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.25), transparent 35%),
    linear-gradient(135deg, #070711, #111122);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 36px;
  border-radius: 28px;
  background: rgba(16, 16, 32, 0.82);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 30px 90px rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
}

.brand-orb,
.empty-orb,
.mini-orb,
.logo-img,
.login-logo {
  background: linear-gradient(135deg, #8b5cf6, #d946ef);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.55);
}

.brand-orb {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  font-weight: 800;
  font-size: 28px;
  margin-bottom: 24px;
}

.login-card h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.04em;
}

.subtitle {
  color: #a1a1aa;
  margin: 10px 0 28px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  color: #c4b5fd;
  font-size: 13px;
  margin-bottom: 8px;
}

input,
textarea,
select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 14px 16px;
  outline: none;
  font-size: 15px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 4px rgba(167,139,250,0.12);
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  box-shadow: 0 14px 34px rgba(124,58,237,0.35);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.otp-block {
  display: none;
  margin-top: 18px;
}

.status-msg {
  margin-top: 14px;
  color: #c4b5fd;
  font-size: 14px;
}

/* APP */

.app-shell {
  height: 100vh;
  display: flex;
  background: #09090f;
}

.sidebar {
  width: 315px;
  background: rgba(10,10,18,0.96);
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.app-logo {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.logo-img {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  flex: 0 0 auto;
}

.login-logo {
  width: 66px;
  height: 66px;
  border-radius: 20px;
  display: block;
  margin-bottom: 24px;
}

.mini-orb {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.app-logo strong {
  display: block;
  font-size: 15px;
}

.app-logo span {
  color: #8b8ba3;
  font-size: 12px;
}

.new-chat {
  width: 100%;
  padding: 13px;
  border-radius: 14px;
  border: 1px solid rgba(167,139,250,0.3);
  background: rgba(139,92,246,0.14);
  color: #ede9fe;
  cursor: pointer;
  font-weight: 700;
}

.new-chat:hover {
  background: rgba(139,92,246,0.24);
}

.session-label {
  color: #71717a;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.12em;
  margin: 24px 0 10px;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
}

.empty-sessions {
  color: #71717a;
  font-size: 13px;
  padding: 12px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px 11px 14px;
  border-radius: 14px;
  color: #d4d4d8;
  cursor: pointer;
  margin-bottom: 6px;
  font-size: 14px;
  position: relative;
}

.session-item:hover {
  background: rgba(255,255,255,0.06);
}

.session-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.35), rgba(192,38,211,0.22));
  color: #fff;
}

.session-content {
  min-width: 0;
  flex: 1;
}

.session-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.session-time {
  margin-top: 4px;
  color: #8b8ba3;
  font-size: 11px;
}

.session-delete {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  border: none;
  color: #a1a1aa;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  opacity: 0;
  transition: 0.15s ease;
  font-size: 18px;
  line-height: 1;
}

.session-item:hover .session-delete {
  opacity: 1;
}

.session-delete:hover {
  background: rgba(239,68,68,0.22);
  color: #fecaca;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
}

.sidebar-footer button {
  width: 100%;
  background: transparent;
  color: #a1a1aa;
  border: none;
  padding: 10px;
  cursor: pointer;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(circle at 70% 10%, rgba(124,58,237,0.12), transparent 28%),
    #0d0d16;
}

.chat-header {
  height: 82px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
}

.chat-header p {
  margin: 5px 0 0;
  color: #8b8ba3;
  font-size: 13px;
}

.model-select {
  width: 230px;
  background: #171728;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: #a1a1aa;
}

.empty-state > div {
  max-width: 560px;
}

.empty-orb {
  width: 70px;
  height: 70px;
  margin: 0 auto 22px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 30px;
}

.empty-state h3 {
  color: #fff;
  font-size: 30px;
  margin: 0 0 10px;
  letter-spacing: -0.04em;
}

.message-row {
  display: flex;
  margin-bottom: 22px;
}

.message-row.user {
  justify-content: flex-end;
}

.message {
  max-width: 780px;
  padding: 16px 18px;
  border-radius: 20px;
  line-height: 1.6;
  font-size: 15px;
}

.message.user {
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  color: white;
  border-bottom-right-radius: 6px;
}

.message.assistant {
  background: rgba(255,255,255,0.065);
  border: 1px solid rgba(255,255,255,0.08);
  color: #f4f4f5;
  border-bottom-left-radius: 6px;
}

.message.streaming {
  white-space: pre-wrap;
}

.message table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
}

.message th,
.message td {
  border: 1px solid rgba(255,255,255,0.14);
  padding: 10px;
}

.message th {
  background: rgba(255,255,255,0.08);
}

.message pre {
  background: #050508;
  padding: 14px;
  border-radius: 14px;
  overflow-x: auto;
}

.composer-wrap {
  position: relative;
  padding: 14px 28px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.drop-zone {
  position: absolute;
  inset: 12px 28px 92px;
  z-index: 12;
  display: grid;
  place-items: center;
  border-radius: 24px;
  border: 1.5px dashed rgba(196,181,253,0.72);
  background: rgba(12, 12, 24, 0.82);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 22px 70px rgba(0,0,0,0.38);
}

.drop-zone-card {
  text-align: center;
  padding: 26px;
  border-radius: 24px;
  background: rgba(139,92,246,0.14);
  border: 1px solid rgba(167,139,250,0.24);
  max-width: 420px;
}

.drop-zone-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  box-shadow: 0 18px 45px rgba(124,58,237,0.36);
  font-size: 26px;
}

.drop-zone-card strong {
  display: block;
  color: #fff;
  font-size: 18px;
  margin-bottom: 6px;
}

.drop-zone-card span {
  color: #c4b5fd;
  font-size: 13px;
  line-height: 1.5;
}

body.drag-active .composer {
  border-color: rgba(196,181,253,0.75);
  box-shadow: 0 0 0 4px rgba(167,139,250,0.12);
}


.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 280px;
  padding: 8px 9px;
  border-radius: 14px;
  background: rgba(139,92,246,0.16);
  border: 1px solid rgba(167,139,250,0.22);
  color: #ede9fe;
}

.attachment-chip strong {
  display: block;
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 185px;
}

.attachment-chip small {
  display: block;
  color: #a1a1aa;
  font-size: 11px;
}

.attachment-chip button {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.09);
  color: #fff;
  cursor: pointer;
}

.composer {
  display: flex;
  gap: 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px;
  border-radius: 22px;
}

.attach-btn {
  width: 48px !important;
  min-width: 48px;
  border: none;
  border-radius: 16px;
  color: #fff;
  background: rgba(255,255,255,0.08) !important;
  cursor: pointer;
  font-size: 18px;
}

.attach-btn:hover {
  background: rgba(139,92,246,0.28) !important;
}

.composer textarea {
  resize: none;
  border: none;
  background: transparent;
  min-height: 48px;
  max-height: 160px;
}

.composer textarea:focus {
  box-shadow: none;
}

.composer button#sendBtn {
  width: 92px;
  border: none;
  border-radius: 16px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  color: #71717a;
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

.loading {
  color: #c4b5fd;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.5; }
}

@media (max-width: 800px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 210px;
  }

  .sessions-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .session-item {
    min-width: 180px;
  }

  .session-delete {
    opacity: 1;
  }

  .chat-header {
    padding: 16px;
    height: auto;
    gap: 12px;
    flex-direction: column;
    align-items: flex-start;
  }

  .model-select {
    width: 100%;
  }

  .messages-area {
    padding: 18px;
  }

  .composer-wrap {
    padding: 14px;
  }
}

/* In-app toast + confirm modal. No browser alert/confirm. */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
}

.toast {
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(24, 24, 38, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  color: #f8fafc;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  backdrop-filter: blur(18px);
  font-size: 14px;
  line-height: 1.4;
}

.toast-success {
  border-color: rgba(34,197,94,0.32);
}

.toast-error {
  border-color: rgba(239,68,68,0.35);
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 3, 10, 0.66);
  backdrop-filter: blur(10px);
}

.confirm-card {
  width: min(430px, 100%);
  border-radius: 26px;
  padding: 26px;
  background: rgba(18, 18, 32, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 28px 90px rgba(0,0,0,0.58);
  color: #f8fafc;
}

.confirm-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  margin-bottom: 14px;
  background: rgba(239,68,68,0.15);
  color: #fecaca;
  font-weight: 900;
}

.confirm-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.confirm-card p {
  margin: 0;
  color: #a1a1aa;
  line-height: 1.5;
  font-size: 14px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.confirm-actions button {
  border: none;
  border-radius: 14px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 800;
}

.confirm-cancel {
  background: rgba(255,255,255,0.08);
  color: #e4e4e7;
}

.confirm-ok {
  background: linear-gradient(135deg, #7c3aed, #c026d3);
  color: #fff;
}

.confirm-ok.danger {
  background: linear-gradient(135deg, #dc2626, #f97316);
}

@media (max-width: 560px) {
  .login-card {
    padding: 26px;
    border-radius: 24px;
  }

  .login-card h1 {
    font-size: 29px;
  }

  .app-shell {
    height: 100dvh;
  }

  .sidebar {
    height: 180px;
    padding: 14px;
  }

  .app-logo {
    margin-bottom: 12px;
  }

  .new-chat {
    padding: 11px;
  }

  .session-label {
    margin: 14px 0 8px;
  }

  .session-item {
    min-width: 165px;
    padding: 10px;
  }

  .session-delete {
    opacity: 1;
  }

  .chat-header h2 {
    font-size: 16px;
  }

  .chat-header p {
    display: none;
  }

  .empty-state h3 {
    font-size: 24px;
  }

  .message {
    max-width: 94vw;
    font-size: 14px;
    padding: 14px 15px;
  }

  .composer {
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
  }

  .attach-btn {
    width: 42px !important;
    min-width: 42px;
  }

  .composer button#sendBtn {
    width: 74px;
  }

  .hint {
    font-size: 11px;
  }

  .attachment-chip {
    max-width: 100%;
  }

  .toast-container {
    left: 14px;
    right: 14px;
    top: 14px;
  }

  .confirm-card {
    border-radius: 22px;
    padding: 22px;
  }

  .confirm-actions {
    flex-direction: column-reverse;
  }

  .confirm-actions button {
    width: 100%;
  }
}

@media (max-width: 920px) {
  .sidebar {
    width: 275px;
  }

  .message {
    max-width: min(760px, 86vw);
  }
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
  }

  .sidebar {
    height: 178px;
    min-height: 178px;
  }

  .chat-main {
    min-height: 0;
  }

  .messages-area {
    min-height: 0;
  }

  .drop-zone {
    inset: 8px 14px 86px;
    border-radius: 20px;
  }

  .drop-zone-card {
    padding: 20px;
    max-width: calc(100vw - 52px);
  }
}

@media (max-width: 420px) {
  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 22px;
  }

  .login-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 18px;
  }

  .sidebar {
    height: 168px;
    min-height: 168px;
  }

  .app-logo span {
    max-width: 220px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .attachment-tray {
    max-height: 94px;
    overflow-y: auto;
  }

  .composer textarea {
    font-size: 16px;
  }
}
.code-wrap {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 12px;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.06);
  padding: 6px 10px;
  font-size: 12px;
  color: #a1a1aa;
}

.code-label {
  text-transform: lowercase;
}

.copy-btn {
  background: transparent;
  border: none;
  color: #a1a1aa;
  cursor: pointer;
  font-size: 14px;
}

.copy-btn:hover {
  color: #fff;
}

.code-wrap pre {
  margin: 0;
  padding: 14px;
  background: #050508;
}

/* Active file context for this chat */
.active-attachment-tray {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(124,58,237,0.10);
  border: 1px solid rgba(167,139,250,0.18);
}

.active-context-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.active-context-header button {
  border: none;
  background: rgba(255,255,255,0.08);
  color: #e9d5ff;
  border-radius: 10px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.active-context-header button:hover {
  background: rgba(239,68,68,0.20);
  color: #fecaca;
}

.active-context-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-section-title {
  width: 100%;
  color: #a78bfa;
  font-size: 12px;
  font-weight: 800;
  margin: 0 0 8px 2px;
}

.attachment-chip.active-file {
  background: rgba(34,197,94,0.12);
  border-color: rgba(34,197,94,0.22);
  color: #dcfce7;
}

.attachment-chip.active-file small {
  color: #86efac;
}

.toast-info {
  border-color: rgba(167,139,250,0.35);
}

@media (max-width: 560px) {
  .active-attachment-tray {
    max-height: 120px;
    overflow-y: auto;
  }

  .active-context-header {
    gap: 8px;
  }

  .active-context-list {
    max-height: 76px;
    overflow-y: auto;
  }
}
