:root {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

.app-root {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: #0d1520;
}

::-webkit-scrollbar-thumb {
  background: #27384c;
  border-radius: 999px;
  border: 2px solid #0d1520;
}

.tool-btn {
  border-radius: 10px;
  border: 1px solid #2a3e53;
  background: linear-gradient(145deg, #162738, #1c3043);
  color: #e7edf7;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.1;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-btn {
  border: 1px solid #2a3e53;
  border-radius: 10px;
  background: #152334;
  color: #dcebf7;
  text-decoration: none;
  font-size: 12px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.header-btn:hover {
  filter: brightness(1.08);
}

.user-chip {
  border: 1px solid #36546b;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #d9f0ff;
  background: #1a3346;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nexpt-logo {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid #2c526e;
  background: linear-gradient(145deg, #103a46, #1e5c67);
  box-shadow: 0 0 0 1px rgba(136, 210, 255, 0.12) inset;
  font-size: 13px;
  font-weight: 700;
  color: #dff6ff;
  line-height: 1;
}

.tool-btn.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-btn.icon-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn.icon-btn:disabled {
  opacity: 0.45;
  filter: none;
  cursor: not-allowed;
}

.prompt-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#prompt {
  overflow-y: hidden !important;
}

.prompt-mic {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.tool-btn:hover,
.assistant-speak:hover,
.artifact-tab:hover {
  filter: brightness(1.09);
}

.tool-btn.active {
  border-color: #2bb19a;
  background: linear-gradient(145deg, #13392f, #19493d);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid #325066;
  background: #173243;
  color: #d7edf9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn:hover {
  filter: brightness(1.1);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.artifact-tab {
  border-radius: 10px;
  border: 1px solid #2a3e53;
  background: #162334;
  color: #e7edf7;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.artifact-tab.active {
  border-color: #39a5de;
  background: linear-gradient(145deg, #1a3854, #214d67);
  color: #f2fbff;
}

.assistant-speak {
  border-radius: 8px;
  border: 1px solid #324960;
  background: #1a2a3b;
  color: #d8e9f7;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}

.history-item {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #27384c;
  background: #13202f;
  color: #8ea0b8;
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 0.15s ease;
}

.history-item.active {
  border-color: #3b5f7d;
  background: #1b2d40;
  color: #e7edf7;
}

.voice-live {
  color: #57d58a !important;
  border-color: #3fb27d !important;
}

.voice-error {
  color: #ff6e85 !important;
  border-color: #d85f74 !important;
}

.message.user .avatar {
  background: linear-gradient(145deg, #14575b, #1f6f74);
}

.message.user .bubble {
  border-color: #315761;
  background: #10313b;
}

.artifact-inline {
  margin-top: 10px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #315a73;
}

.artifact-inline button {
  width: 100%;
  border: 0;
  background: linear-gradient(120deg, #163b5f, #1c5a6b);
  color: #e7edf7;
  padding: 9px 11px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.artifact-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 14, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 40;
}

.artifact-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(52vw, 760px);
  max-width: 100%;
  height: 100dvh;
  border-left: 1px solid #2a3e53;
  background: #0f1724;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr;
}

.artifact-grabber {
  display: none;
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #2a3e53;
  padding: 10px 12px;
  background: rgba(15, 23, 36, 0.92);
  backdrop-filter: blur(6px);
}

.artifact-title {
  font-size: 14px;
  font-weight: 600;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.artifact-version-wrap {
  position: relative;
}

.artifact-version-btn {
  border-radius: 10px;
  border: 1px solid #2a3e53;
  background: #152334;
  color: #dcebf7;
  padding: 7px 10px;
  font-size: 12px;
  min-width: 86px;
  cursor: pointer;
}

.artifact-version-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 110px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #2a3e53;
  border-radius: 10px;
  background: #101a27;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  padding: 6px;
  z-index: 80;
}

.artifact-version-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dcebf7;
  padding: 7px 8px;
  font-size: 12px;
  cursor: pointer;
}

.artifact-version-item:hover {
  background: #1b2b3e;
}

.artifact-version-item.active {
  border-color: #3e6b8a;
  background: #1a3144;
}

.artifact-close {
  background: #1b2b3e;
}

.artifact-drawer-content {
  min-height: 0;
  height: 100%;
  position: relative;
}

#artifactFrame,
#artifactCode {
  display: block;
}

body.artifact-open .artifact-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.artifact-open .artifact-drawer {
  transform: translateX(0);
}

body.artifact-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-actions {
    width: 100%;
    justify-content: flex-start;
  }

  #prompt {
    padding-right: 52px !important;
  }

  .prompt-mic {
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
  }

  .tool-btn.icon-btn.prompt-mic {
    width: 35px;
    height: 35px;
    border-radius: 10px;
  }

  .tool-btn.icon-btn.prompt-mic svg {
    width: 18px;
    height: 18px;
  }

  .send-btn {
    width: 44px;
    height: 44px;
  }

  .send-btn svg {
    width: 16px;
    height: 16px;
  }

  .artifact-backdrop {
    background: rgba(2, 8, 14, 0.45);
    backdrop-filter: none;
  }

  .artifact-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100dvw;
    max-width: 100dvw;
    height: 100dvh;
    border-left: 0;
    border-top: 1px solid #2a3e53;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -20px 45px rgba(0, 0, 0, 0.35);
    grid-template-rows: auto auto 1fr;
  }

  .artifact-grabber {
    display: block;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: #395269;
    margin: 8px auto 0;
  }

  body.artifact-open .artifact-drawer {
    transform: translateY(0);
  }

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

  .artifact-title {
    font-size: 15px;
    max-width: 34%;
  }

  .artifact-actions {
    gap: 6px;
  }

  .artifact-version-btn {
    min-height: 38px;
    min-width: 78px;
    min-height: 38px;
    font-size: 12px;
    padding: 7px 8px;
  }

  .artifact-version-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-height: min(42dvh, 320px);
    border-radius: 12px;
  }

  .artifact-version-item {
    font-size: 13px;
    padding: 10px;
  }

  .artifact-tab {
    min-height: 38px;
    min-width: 64px;
    padding: 8px 10px;
    font-size: 13px;
  }

  #artifactCode {
    padding: 14px;
    font-size: 13px;
    line-height: 1.5;
  }
}

@media (min-width: 1440px) {
  .tool-btn,
  .artifact-tab {
    font-size: 14px;
    padding: 8px 12px;
  }

  .tool-btn.icon-btn {
    width: 44px;
    height: 44px;
    padding: 0;
  }

  .tool-btn.icon-btn svg {
    width: 22px;
    height: 22px;
  }

  .nexpt-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 15px;
  }

  .history-item {
    font-size: 15px;
    padding: 10px 12px;
  }

  .assistant-speak {
    font-size: 13px;
    padding: 3px 10px;
  }

  .artifact-inline button {
    font-size: 15px;
    padding: 10px 12px;
  }
}
