* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #fbf8f2;
  --surface-3: #f2ecdf;
  --border: #e5dcc8;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #111827;
  --accent: #b88b39;
  --accent-soft: #f7edd6;
  --shadow: 0 12px 28px rgba(17, 24, 39, 0.07);
  --danger: #dc2626;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font-family: inherit;
}

a {
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  height: 100vh;
  background: linear-gradient(180deg, #fffdf8 0%, #f8f3e8 100%);
  border-right: 1px solid var(--border);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.brand-card {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow);
}

.brand-logo,
.welcome-logo {
  width: 60px;
  height: 60px;
  min-width: 60px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #efdca8;
  background: linear-gradient(135deg, #111827, #374151);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.brand-logo img,
.welcome-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--primary);
}

.company-name {
  margin: 6px 0 0;
  font-size: 14px;
  color: #374151;
  font-weight: 700;
}

.brand-tagline {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.leadership-box {
  margin-top: 12px;
  background: var(--surface-3);
  border: 1px solid #eadfca;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #4b5563;
}

.new-chat-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.history-header {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar {
  width: 8px;
}

.history-list::-webkit-scrollbar-thumb {
  background: #d8ccb5;
  border-radius: 999px;
}

.history-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
}

.history-card.active {
  background: #fff8e8;
  border-color: #dcc58d;
}

.history-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 2px 0 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.history-tools {
  display: flex;
  gap: 8px;
}

.mini-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn.danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff7f7;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.user-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
}

.user-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.logout-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--primary);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
}

/* Main */
.main-panel {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(240, 225, 188, 0.35), transparent 28%),
    linear-gradient(180deg, #fcfbf8 0%, #f5f3ed 100%);
}

.topbar {
  background: rgba(255,252,246,0.9);
  border-bottom: 1px solid var(--border);
  padding: 20px 26px;
}

.topbar h2 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.prompt-row {
  padding: 14px 26px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-chip {
  border: 1px solid #eadfca;
  background: rgba(255,255,255,0.92);
  color: #5d4b2e;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.prompt-chip:hover {
  background: var(--accent-soft);
}

.chat-scroll-area {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 26px;
}

.chat-scroll-area::-webkit-scrollbar {
  width: 10px;
}

.chat-scroll-area::-webkit-scrollbar-thumb {
  background: #d8ccb5;
  border-radius: 999px;
}

.chat-messages {
  max-width: 960px;
  margin: 0 auto;
}

.welcome-box {
  text-align: center;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 40px 28px;
  box-shadow: var(--shadow);
  margin-top: 36px;
}

.welcome-logo {
  width: 76px;
  height: 76px;
  min-width: 76px;
  margin: 0 auto 16px;
  font-size: 30px;
}

.welcome-box h2 {
  margin: 0;
  font-size: 38px;
}

.welcome-company {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 800;
  color: #374151;
}

.welcome-tagline {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}

.subtext {
  max-width: 760px;
  margin: 18px auto 0;
  font-size: 15px;
  line-height: 1.8;
  color: #4b5563;
}

.welcome-meta {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.welcome-meta span {
  background: #fbf5e8;
  border: 1px solid #eadfc8;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #5f4b25;
}

/* Messages */
.message-row {
  margin: 18px 0;
}

.message-row.user {
  display: flex;
  justify-content: flex-end;
}

.message-row.assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.message-bubble {
  max-width: 78%;
  padding: 16px 18px;
  border-radius: 20px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 15px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.05);
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  border-bottom-right-radius: 8px;
}

.message-row.assistant .message-bubble {
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 8px;
}

.message-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.message-actions button {
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Input */
.input-wrap {
  background: rgba(255,252,246,0.92);
  border-top: 1px solid var(--border);
  padding: 16px 26px;
}

.input-box {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid #eadfc8;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
}

.icon-btn.active {
  background: #fff4d9;
  border-color: #d8b461;
}

.input-box textarea {
  resize: none;
  min-height: 58px;
  max-height: 180px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 16px;
  font-size: 15px;
  outline: none;
}

.input-box textarea:focus {
  border-color: #d7b46d;
  box-shadow: 0 0 0 4px rgba(215, 180, 109, 0.15);
}

.input-box #sendBtn {
  height: 58px;
  min-width: 110px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  padding: 0 20px;
}

.voice-status {
  max-width: 960px;
  margin: 8px auto 0;
  min-height: 18px;
  font-size: 12px;
  font-weight: 700;
  color: #7c5b17;
}

/* Typing */
.typing {
  display: flex;
  gap: 6px;
  align-items: center;
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b28b3d;
  display: inline-block;
  animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #faf8f2 0%, #f2ede2 100%);
  padding: 20px;
}

.auth-card {
  width: min(460px, 95vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 34px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-brand {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, #111827, #374151);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  border: 2px solid #efdfb6;
}

.auth-card h1 {
  margin: 0;
  font-size: 26px;
  color: var(--primary);
}

.auth-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.auth-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

.auth-form input:focus {
  border-color: #d7b46d;
  box-shadow: 0 0 0 4px rgba(215, 180, 109, 0.15);
}

.auth-form button {
  border: 0;
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.auth-link {
  display: inline-block;
  margin-top: 16px;
  color: #8b6a26;
  font-weight: 700;
}

.auth-message {
  min-height: 22px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--danger);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    display: none;
  }

  .main-panel {
    height: 100vh;
  }

  .message-bubble {
    max-width: 92%;
  }

  .welcome-box {
    padding: 30px 20px;
  }

  .welcome-box h2 {
    font-size: 30px;
  }

  .input-box {
    grid-template-columns: auto 1fr auto;
  }

  .input-box #sendBtn {
    grid-column: 1 / -1;
    width: 100%;
  }
}