/* ===== Stratix Systems AI — Light Design Tokens ===== */
:root {
  --bg-void: #ffffff;
  --bg-panel: #f6f7f9;
  --bg-panel-raised: #ffffff;
  --bg-input: #f6f7f9;
  --bg-sidebar: #fafbfc;
  --border-line: #e5e7eb;
  --border-line-soft: #edeef1;

  --accent-electric: #d98b1f;
  --accent-electric-strong: #b8720f;
  --accent-electric-tint: #fdf1de;
  --accent-cyan: #17a190;
  --accent-cyan-tint: #e6f7f4;

  --text-primary: #14171c;
  --text-dim: #5b6270;
  --text-faint: #9aa1ac;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text-primary);
  overflow: hidden;
  position: relative;
}

.grid-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(217, 139, 31, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 139, 31, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 70%);
}

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-line);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.sidebar-top { padding: 18px 16px 6px; }
.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-electric), var(--accent-electric-strong));
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(217, 139, 31, 0.25);
  flex-shrink: 0;
}
.brand-mark svg { width: 17px; height: 17px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.05em;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
}
.brand-name b { font-weight: 700; color: var(--accent-electric-strong); }
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-top: 2px;
}

.new-chat-btn {
  margin: 16px 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-line);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.new-chat-btn svg { width: 15px; height: 15px; color: var(--accent-electric-strong); }
.new-chat-btn:hover { border-color: var(--accent-electric); background: var(--accent-electric-tint); }

.history-label {
  padding: 14px 20px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-line); border-radius: 8px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.history-item:hover { background: var(--bg-panel); color: var(--text-primary); }
.history-item.active {
  background: var(--accent-electric-tint);
  color: var(--text-primary);
  border-color: #f0dcb6;
}
.history-item .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-cyan); flex-shrink: 0; opacity: 0.8;
}

.history-empty {
  padding: 14px 10px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.5;
}

.sidebar-bottom {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border-line-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lang-switch {
  display: flex;
  gap: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  padding: 3px;
}
.lang-btn {
  flex: 1;
  padding: 6px 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn:hover { color: var(--text-dim); }
.lang-btn.active {
  background: var(--bg-panel-raised);
  color: var(--accent-electric-strong);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px rgba(23, 161, 144, 0.5);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-line);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.sidebar-toggle svg { width: 18px; height: 18px; }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 28, 0.35);
  z-index: 14;
}

/* ===== Main app ===== */
.app {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.header {
  position: relative;
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-line);
  background: var(--bg-void);
  overflow: hidden;
}
.header-spacer-mobile { display: none; }
.header-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.scanline {
  position: absolute;
  bottom: 0;
  left: -30%;
  width: 30%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-electric), transparent);
  animation: scan 5s linear infinite;
  opacity: 0.6;
}
@keyframes scan {
  0% { left: -30%; }
  100% { left: 100%; }
}

/* ===== Chat area ===== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar { width: 8px; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border-line); border-radius: 8px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }

.welcome {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: 32px 16px;
}
.welcome-mark {
  width: 52px; height: 52px;
  margin: 0 auto 20px;
  display: grid; place-items: center;
  color: var(--accent-electric-strong);
  border: 1px solid var(--border-line);
  border-radius: 14px;
  background: var(--accent-electric-tint);
}
.welcome-mark svg { width: 26px; height: 26px; }
.welcome h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.welcome p {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.6;
  margin-bottom: 26px;
}
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggestion-chip {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-line);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.suggestion-chip:hover {
  border-color: var(--accent-electric);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(217, 139, 31, 0.1);
}

/* ===== Messages ===== */
.message {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  animation: rise 0.25s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-tag {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.message.user .msg-tag {
  background: var(--bg-panel);
  color: var(--text-dim);
  border: 1px solid var(--border-line);
}
.message.assistant .msg-tag {
  background: var(--accent-cyan-tint);
  color: var(--accent-cyan);
  border: 1px solid #bfe9e2;
}
.msg-body {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-line);
  border-left: 2px solid var(--border-line);
  border-radius: 4px 10px 10px 4px;
  padding: 13px 18px;
  line-height: 1.6;
  font-size: 14.5px;
  box-shadow: 0 1px 2px rgba(20,23,28,0.03);
}
.message.user .msg-body { border-left-color: var(--accent-electric); }
.message.assistant .msg-body { border-left-color: var(--accent-cyan); }
.msg-body code { font-family: var(--font-mono); font-size: 13px; background: var(--bg-panel); padding: 1px 5px; border-radius: 4px; }
.msg-body pre {
  background: #14171c;
  color: #e9ebee;
  border: 1px solid var(--border-line-soft);
  padding: 13px 15px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 10px 0;
}
.msg-body pre code { background: none; color: inherit; padding: 0; }
.msg-body h1, .msg-body h2, .msg-body h3 {
  font-family: var(--font-display);
  margin: 12px 0 6px;
  color: var(--text-primary);
}
.msg-body h1 { font-size: 19px; }
.msg-body h2 { font-size: 16.5px; }
.msg-body h3 { font-size: 14.5px; }
.msg-body strong { color: var(--text-primary); font-weight: 600; }
.msg-body ul { margin: 6px 0 6px 20px; }
.msg-body li { margin: 4px 0; }
.msg-body hr { border: none; border-top: 1px solid var(--border-line); margin: 12px 0; }

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13.5px;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border-line);
  padding: 6px 10px;
  text-align: left;
}
.msg-body th {
  background: var(--bg-panel);
  font-weight: 600;
  color: var(--text-primary);
}

.message.typing .msg-body {
  display: flex; align-items: center; gap: 5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-cyan);
  animation: blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* ===== Attachment chip (file preview above uploaded) ===== */
.attachment-preview {
  display: none;
  max-width: 720px;
  margin: 0 auto 8px;
  align-items: center;
  gap: 8px;
  background: var(--accent-electric-tint);
  border: 1px solid #f0dcb6;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--accent-electric-strong);
}
.attachment-preview:not([hidden]) { display: flex; }
.attachment-preview svg { width: 16px; height: 16px; flex-shrink: 0; }
.attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove {
  background: none; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; color: var(--accent-electric-strong);
  padding: 0 2px;
}

/* ===== Input bar ===== */
.input-bar {
  padding: 16px 24px 22px;
  border-top: 1px solid var(--border-line);
  background: var(--bg-void);
}
.input-shell {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-line);
  border-radius: 14px;
  padding: 8px 8px 8px 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-shell:focus-within {
  border-color: var(--accent-electric);
  box-shadow: 0 0 0 3px rgba(217, 139, 31, 0.08);
}

.attach-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.attach-btn:hover { background: var(--bg-panel); color: var(--accent-electric-strong); }
.attach-btn svg { width: 18px; height: 18px; }

textarea#userInput {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 9px 0;
  max-height: 160px;
}
textarea#userInput:focus { outline: none; }
textarea#userInput::placeholder { color: var(--text-faint); }
button#sendBtn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-electric), var(--accent-electric-strong));
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 2px 10px rgba(217, 139, 31, 0.3);
}
button#sendBtn svg { width: 17px; height: 17px; }
button#sendBtn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(217, 139, 31, 0.4); }
button#sendBtn:active { transform: translateY(0); }
button#sendBtn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; transform: none; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .sidebar-scrim.show { display: block; }
  .header-spacer-mobile { display: inline-block; width: 34px; flex-shrink: 0; }
  .header { padding: 13px 16px; gap: 10px; }
  .chat-container { padding: 22px 14px; }
  .input-bar { padding: 12px 14px 16px; }
  .message { gap: 9px; }
  .msg-tag { width: 26px; height: 26px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot, .scanline, .message { animation: none; }
}