:root {
  --bg-1: #0e1b2b;
  --bg-2: #1b3a4b;
  --accent: #ff8a3d;
  --accent-2: #33c3a5;
  --text: #eef2f6;
  --muted: #9db2c7;
  --card: rgba(15, 27, 43, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(4, 8, 20, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% 10%, #1d4c5a, transparent 60%),
    radial-gradient(900px 900px at 90% 0%, #2a2b48, transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  min-height: calc(100vh - 120px);
}

.chat-sidebar {
  background: #111315;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 520px;
  position: sticky;
  top: 16px;
}

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

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 6px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: none;
}

.chat-item.active {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.chat-link {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 14px;
  flex: 1;
}

.chat-link:visited {
  color: #cdd5df;
}

.chat-link:hover {
  color: #ffffff;
}

.chat-delete {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #9aa4b2;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-delete:hover {
  color: #f0f4f8;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.chat-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chat-card {
  min-height: 520px;
}

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

header.app-header h1 {
  font-size: 28px;
  margin: 0;
  letter-spacing: 0.4px;
}

header.app-header .subtitle {
  color: var(--muted);
  margin-top: 8px;
}

.button {
  background: linear-gradient(135deg, var(--accent), #ffb062);
  color: #1b1b1b;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(255, 138, 61, 0.35);
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.button.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 15px;
}

.input:focus {
  outline: 2px solid rgba(255, 138, 61, 0.35);
}

.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.auth-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.auth-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.error {
  color: #ffb4a2;
  background: rgba(255, 100, 80, 0.15);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 100, 80, 0.3);
  margin-bottom: 16px;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

.message {
  padding: 14px 16px;
  border-radius: 14px;
  line-height: 1.5;
}

.message.user {
  background: rgba(51, 195, 165, 0.2);
  border: 1px solid rgba(51, 195, 165, 0.35);
  align-self: flex-end;
  display: flex;
  gap: 10px;
  align-items: center;
}

.message.assistant {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.message-text {
  flex: 1;
}

.edit-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

.edit-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.edit-input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 14px;
}

.edit-actions {
  display: flex;
  gap: 8px;
}

.edit-save,
.edit-cancel {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

.edit-save:hover,
.edit-cancel:hover {
  background: rgba(255, 255, 255, 0.18);
}

.message.assistant a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 138, 61, 0.4);
}

.message.assistant a:hover {
  color: #ffd3b0;
}

.message.assistant ul,
.message.assistant ol {
  margin: 10px 0 0 20px;
  padding: 0;
}

.message.assistant li {
  margin-bottom: 6px;
}

.message.assistant h3,
.message.assistant h4 {
  margin: 12px 0 6px;
  font-size: 16px;
}

.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

.message.assistant th,
.message.assistant td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.message.assistant th {
  background: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}

.comp-grid {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.comp-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
}

.comp-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.comp-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.comp-link {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(51, 195, 165, 0.2);
  border: 1px solid rgba(51, 195, 165, 0.35);
  color: var(--text);
}

.chat-input {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  align-items: flex-end;
}

.thinking {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.thinking.show {
  display: inline-flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chat-input .input {
  flex: 1;
}

.chat-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.4;
}

footer.note {
  color: var(--muted);
  margin-top: 16px;
  font-size: 13px;
}


@media (max-width: 520px) {
  main {
    padding: 28px 16px 60px;
  }

  header.app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    min-height: auto;
    position: static;
  }
}

@media (max-width: 720px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }
}

/* ── NPS Survey ──────────────────────────────────────────── */
.nps-survey {
  margin: 4px 0;
}
.nps-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nps-block p {
  margin: 0;
  color: var(--text);
}
.nps-scale-hint {
  font-size: 12px;
  color: var(--muted);
}
.nps-score-row,
.nps-sat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.nps-option {
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.nps-option:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}
.nps-option.selected {
  background: var(--accent-2);
  color: #0e1b2b;
  border-color: var(--accent-2);
  font-weight: 600;
}
.nps-option:disabled {
  opacity: 0.45;
  cursor: default;
}
.nps-comment-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
}
.nps-comment-input::placeholder {
  color: var(--muted);
}
.nps-comment-input:focus {
  border-color: var(--accent-2);
}
.nps-comment-input:disabled {
  opacity: 0.45;
  cursor: default;
}
.nps-submit-btn {
  align-self: flex-start;
  padding: 9px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  transition: opacity 0.12s;
}
.nps-submit-btn:hover:not(:disabled) {
  opacity: 0.85;
}
.nps-submit-btn:disabled {
  background: rgba(255, 255, 255, 0.15);
  color: var(--muted);
  cursor: not-allowed;
}
.nps-survey.nps-done {
  opacity: 0.5;
  pointer-events: none;
}
.chat-textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
