:root {
  --bg: #02050b;
  --panel: #07101f;
  --panel-strong: #0b1628;
  --line: rgba(126, 181, 255, 0.2);
  --line-strong: rgba(126, 181, 255, 0.34);
  --text: #f2f7ff;
  --muted: #aebbd0;
  --faint: #74829a;
  --blue: #1688ff;
  --cyan: #2ee7ff;
  --danger: #ff6f8f;
  --success: #75f0bd;
  --shadow: rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(circle at 12% 0%, rgba(22, 136, 255, 0.2), transparent 30%),
    radial-gradient(circle at 86% 8%, rgba(46, 231, 255, 0.1), transparent 28%),
    linear-gradient(180deg, #02050b 0%, #07101f 48%, #02050b 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
}

.boot-logo {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  box-shadow: 0 24px 72px rgba(22, 136, 255, 0.24);
}

.app-shell {
  min-height: 100vh;
}

.auth-shell,
.gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.auth-card,
.gate-card {
  width: min(460px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  padding: 28px;
  background: linear-gradient(180deg, rgba(10, 21, 40, 0.9), rgba(4, 8, 18, 0.94));
  box-shadow: 0 28px 80px var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-lockup img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.auth-card h1,
.gate-card h1 {
  margin: 0 0 10px;
  font-size: clamp(2.1rem, 8vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-card p,
.gate-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.field label {
  color: #d8e7ff;
  font-weight: 800;
  font-size: 0.92rem;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid rgba(126, 181, 255, 0.28);
  border-radius: 16px;
  background: rgba(2, 5, 11, 0.58);
  color: var(--text);
  outline: none;
}

.field input {
  height: 52px;
  padding: 0 15px;
}

.password-field {
  position: relative;
}

.password-field .password-input {
  padding-right: 82px;
}

.password-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 8px;
  min-width: 62px;
  border: 1px solid rgba(126, 181, 255, 0.24);
  border-radius: 999px;
  background: rgba(126, 181, 255, 0.08);
  color: #b8dfff;
  font-size: 0.78rem;
  font-weight: 900;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--text);
  border-color: rgba(46, 231, 255, 0.46);
}

.captcha-box {
  min-height: 70px;
  margin: 14px 0 4px;
  display: flex;
  align-items: center;
}

.captcha-message {
  min-height: 18px;
  margin: -2px 0 10px;
  color: #ffb4b4;
  font-size: 0.85rem;
  line-height: 1.35;
}

.field textarea {
  min-height: 104px;
  resize: vertical;
  padding: 13px 15px;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.chat-input textarea:focus {
  border-color: rgba(46, 231, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(46, 231, 255, 0.08);
}

.primary-btn,
.secondary-btn,
.icon-btn,
.tab-btn,
.link-btn,
.danger-btn {
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 900;
}

.primary-btn {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 20px 52px rgba(22, 136, 255, 0.24);
}

.secondary-btn,
.link-btn,
.danger-btn {
  background: rgba(7, 16, 31, 0.78);
  border: 1px solid rgba(126, 181, 255, 0.25);
}

.danger-btn {
  color: #ffd8e1;
  border-color: rgba(255, 111, 143, 0.35);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-row .secondary-btn,
.button-row .link-btn,
.button-row .danger-btn {
  flex: 1;
}

.notice {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.notice.error {
  color: #ffd8e1;
}

.notice.success {
  color: #d6ffed;
}

.nova-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid rgba(126, 181, 255, 0.12);
  background: rgba(2, 5, 11, 0.76);
  backdrop-filter: blur(18px);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: var(--muted);
}

.tab-btn.active {
  background: rgba(22, 136, 255, 0.14);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  color: var(--faint);
  font-size: 0.86rem;
  line-height: 1.5;
}

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  height: 74px;
  border-bottom: 1px solid rgba(126, 181, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--faint);
  font-size: 0.88rem;
}

.content {
  min-width: 0;
  min-height: 0;
  padding: 22px 28px 28px;
}

.chat-view {
  height: calc(100vh - 124px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
}

.messages {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 2px 10px;
  scroll-behavior: smooth;
}

.message {
  max-width: min(760px, 88%);
  border: 1px solid rgba(126, 181, 255, 0.18);
  border-radius: 20px;
  padding: 13px 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: rgba(22, 136, 255, 0.18);
  border-color: rgba(46, 231, 255, 0.22);
}

.message.assistant {
  align-self: flex-start;
  background: rgba(7, 16, 31, 0.82);
}

.message.meta {
  max-width: 560px;
  color: var(--muted);
}

.typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  min-width: 58px;
  border-radius: 999px;
  border: 1px solid rgba(126, 181, 255, 0.18);
  background: rgba(7, 16, 31, 0.82);
  padding: 0 14px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c9eaff;
  opacity: 0.45;
  animation: pulse 1s infinite ease-in-out;
}

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

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

@keyframes pulse {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.chat-input {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(4, 8, 18, 0.92);
  padding: 12px;
  box-shadow: 0 18px 58px rgba(0, 0, 0, 0.22);
}

.chat-input textarea {
  width: 100%;
  min-height: 54px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(2, 5, 11, 0.42);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  line-height: 1.45;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.left-actions,
.right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-btn {
  min-width: 44px;
  background: rgba(7, 16, 31, 0.78);
  border: 1px solid rgba(126, 181, 255, 0.22);
}

.icon-btn.active {
  color: #dff9ff;
  border-color: rgba(46, 231, 255, 0.48);
  background: rgba(46, 231, 255, 0.12);
}

.voice-btn {
  display: inline-grid;
  place-items: center;
}

.voice-btn.recording {
  border-color: rgba(255, 157, 177, 0.42);
  background: rgba(255, 157, 177, 0.14);
}

.web-mic-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 20px;
}

.web-mic-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 8px;
  height: 12px;
  border: 2px solid #e2edff;
  border-radius: 999px;
}

.web-mic-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 13px;
  width: 2px;
  height: 5px;
  border-radius: 999px;
  background: #e2edff;
}

.web-mic-icon span {
  position: absolute;
  left: 3px;
  bottom: 0;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: #e2edff;
}

.voice-stop-icon {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #ffd7df;
}

.voice-loading-dot {
  color: #e2edff;
  font-weight: 900;
}

.voice-listening-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(126, 181, 255, 0.24);
  border-radius: 20px;
  background: rgba(126, 181, 255, 0.08);
  padding: 11px 14px;
}

.voice-listening-card strong,
.voice-listening-card span {
  display: block;
}

.voice-listening-card strong {
  color: #e9fbff;
  font-size: 0.88rem;
}

.voice-listening-card span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.voice-meter-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  min-width: 62px;
}

.voice-meter-bars span {
  width: 5px;
  min-height: 8px;
  border-radius: 999px;
  background: #7de7ff;
  transition: height 90ms ease;
}

.attachment-pill {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-grid {
  display: grid;
  gap: 14px;
  max-width: 920px;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(7, 16, 31, 0.78);
  padding: 18px;
}

.panel-card h2,
.panel-card h3 {
  margin: 0 0 8px;
  letter-spacing: 0;
}

.panel-card p,
.panel-card li {
  color: var(--muted);
  line-height: 1.55;
}

.brief-section {
  display: grid;
  gap: 12px;
}

.brief-section ul {
  margin: 0;
  padding-left: 20px;
}

.memory-list {
  display: grid;
  gap: 10px;
}

.memory-item {
  border: 1px solid rgba(126, 181, 255, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: rgba(2, 5, 11, 0.34);
}

.memory-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.memory-item p {
  margin: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.small-label {
  color: var(--faint);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.external-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.usage-meter {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.usage-meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 850;
}

.usage-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.usage-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(143, 180, 255, 0.94), rgba(110, 231, 183, 0.88));
}

.usage-progress-meta {
  margin: 0;
  color: var(--faint);
  font-size: 0.88rem;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .nova-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid rgba(126, 181, 255, 0.12);
    padding: 14px;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab-btn {
    justify-content: center;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    height: auto;
    padding: 16px;
  }

  .content {
    padding: 14px;
  }

  .chat-view {
    height: calc(100vh - 172px);
  }

  .message {
    max-width: 94%;
  }
}

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

  .tabs {
    gap: 6px;
  }

  .tab-btn {
    min-height: 40px;
    font-size: 0.82rem;
  }

  .button-row .secondary-btn,
  .button-row .link-btn,
  .button-row .danger-btn {
    flex-basis: 100%;
  }
}
