:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f5f5f7;
  --line: #e7e7eb;
  --text: #1f1f21;
  --muted: #76767f;
  --sidebar: #f7f7f8;
  --sidebar-hover: #eeeeF2;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 0;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
}

.page-frame {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.page-frame--chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: none;
  padding: 0;
}

.content-panel {
  min-height: 0;
}

.content-panel--chat {
  display: flex;
  flex: 1;
  min-height: 0;
}

.content-panel--chat > [ng-view] {
  display: flex;
  flex: 1;
  min-height: 0;
}

.card-surface {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 8px 14px;
  font-size: 0.88rem;
}

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

.auth-shell {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-layout {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.auth-panel {
  height: 100%;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #ffffff;
}

.auth-panel--soft {
  background:
    radial-gradient(circle at top right, rgba(17, 17, 17, 0.035), transparent 28%),
    linear-gradient(180deg, #fcfcfd 0%, #f7f7f8 100%);
}

.auth-card {
  width: 100%;
}

.auth-display {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(1.9rem, 3.2vw, 3rem);
  line-height: 1.04;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.auth-copy {
  max-width: 31rem;
  font-size: 1rem;
  line-height: 1.7;
}

.auth-card h2 {
  margin: 0 0 12px;
  font-size: 2rem;
  font-weight: 600;
}

.auth-meta {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.auth-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 0.92rem;
}

.auth-meta-icon {
  color: var(--muted);
  font-size: 1rem;
}

.muted-copy {
  color: var(--muted);
}

.auth-form-error {
  margin: -4px 0 16px;
  color: #b42318;
  font-size: 0.9rem;
}

.password-strength {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fafafa;
}

.password-strength-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}

.password-strength-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.password-strength-badge--weak {
  background: #fee4e2;
  color: #b42318;
}

.password-strength-badge--medium {
  background: #fef0c7;
  color: #b54708;
}

.password-strength-badge--strong {
  background: #dcfae6;
  color: #067647;
}

.password-checklist {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.84rem;
}

.password-checklist__item--done {
  color: var(--text);
}

.btn-primary {
  border-color: #111111;
  background-color: #111111;
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: #222222;
  background-color: #222222;
  color: #ffffff;
}

.auth-submit {
  min-height: 52px;
  border-radius: 16px;
}

.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--text);
  padding: 0.85rem 1rem;
  box-shadow: none;
}

.form-control::placeholder {
  color: #a0a0a8;
}

.form-control:focus,
.form-select:focus {
  border-color: #d9d9df;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 0 0 0.18rem rgba(148, 163, 184, 0.1);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #f04438;
  box-shadow: none;
}

.auth-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.chat-overlay {
  display: none;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  background: #fafafa;
  border-right: 1px solid var(--line);
  padding: 16px 12px 14px;
}

.sidebar-top {
  display: block;
}

.sidebar-head {
  display: flex;
  align-items: center;
  padding: 6px 8px 2px;
}

.sidebar-logo-text {
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
  justify-content: flex-start;
}

.sidebar-label {
  margin: 0;
  padding: 0 10px;
  color: #8b8b95;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.sidebar-search-icon {
  color: var(--muted);
  font-size: 0.9rem;
}

.sidebar-search-input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 10px 0;
  font-size: 0.88rem;
}

.sidebar-search-input::placeholder {
  color: #a0a0a8;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  padding: 6px 8px 6px 12px;
}

.history-item:hover,
.history-item--active {
  background: #f3f4f6;
}

.history-item-link {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 4px 0;
  text-align: left;
}

.history-item-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.history-item-delete:hover {
  background: #ebecef;
  color: #b42318;
}

.history-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 400;
}

.sidebar-empty {
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 6px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid #e3e4e8;
}

.sidebar-user-name {
  font-size: 0.9rem;
  font-weight: 400;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-delete-account-btn {
  border: 0;
  border-radius: 10px;
  background: #fff1f2;
  color: #b42318;
  padding: 8px 10px;
  font-size: 0.8rem;
  line-height: 1;
}

.sidebar-delete-account-btn:hover {
  background: #ffe4e8;
}

.sidebar-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.sidebar-logout-btn:hover {
  background: #f3f4f6;
  color: var(--text);
}

.chat-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
  overflow: hidden;
}

.chat-main-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid #f1f1f3;
}

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

.chat-main-toggle,
.chat-main-compose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  padding: 0;
}

.chat-main--empty {
  display: block;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 24px 168px;
}

.chat-hero,
.message-stack,
.composer-shell {
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
}

.chat-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-top: 18vh;
  text-align: center;
}

.chat-hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.message-stack {
  display: grid;
  gap: 28px;
}

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

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.message-card {
  width: 100%;
  color: var(--text);
}

.message-row--user .message-card {
  width: auto;
  max-width: 460px;
  border-radius: 24px;
  background: #f6f7f9;
  padding: 14px 22px;
}

.message-copy {
  white-space: pre-wrap;
  line-height: 1.72;
  font-size: 1.02rem;
}

.message-card--thinking {
  color: var(--muted);
}

.thinking-copy {
  font-size: 1rem;
  line-height: 1.7;
}

.composer-wrap {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 272px;
  padding: 20px 24px 26px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 58%, rgba(255, 255, 255, 0));
}

.composer-shell {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: min(100%, 760px);
  min-height: 98px;
  padding: 18px 16px 18px 22px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: #ffffff;
}

.composer-input {
  flex: 1;
  min-height: 60px;
  max-height: 60px;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  padding: 6px 0 0;
  font-size: 1.05rem;
  line-height: 1.45;
}

.composer-input::placeholder {
  color: #91919a;
}

.composer-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 0;
  border-radius: 50%;
  align-self: flex-end;
  background: #8b8b8f;
  color: #ffffff;
  padding: 0;
  font-size: 1.05rem;
}

.composer-send:disabled {
  opacity: 0.75;
}

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

  .chat-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(84vw, 312px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    background: #fafafa;
  }

  .chat-sidebar--open {
    transform: translateX(0);
  }

  .chat-overlay--visible {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(17, 17, 17, 0.14);
  }

  .chat-scroll {
    padding-top: 12px;
  }

  .composer-wrap {
    left: 0;
    right: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 16px 16px 0;
  }

  .page-frame {
    padding: 0;
  }

  .auth-shell {
    padding: 16px;
  }

  .auth-panel {
    padding: 24px;
    border-radius: 24px;
  }

  .auth-display {
    max-width: none;
    font-size: 2.35rem;
  }

  .chat-scroll {
    padding: 20px 14px 144px;
  }

  .chat-hero h1 {
    font-size: 2rem;
  }

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

  .composer-shell {
    padding: 10px 10px 10px 14px;
  }
}
