/* =====================================================================
   JOSH AI — DeepSeek-style professional design system
   Clean white canvas · signature blue #4D6BFE · pill buttons · flat
   Token-driven · accessible · responsive
   ===================================================================== */

/* ---------- design tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --surface-3: #e9e9ea;
  --border: #e5e5e5;
  --border-strong: #d4d4d8;
  --text: #1a1a1a;
  --text-2: #595959;
  --text-3: #999999;
  --accent: #4d6bfe;
  --accent-dark: #3a5af9;
  --accent-soft: #eef1fe;
  --accent-ring: rgba(77, 107, 254, 0.18);
  --ok: #059669;
  --warn: #d97706;
  --err: #e11d48;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 4px 20px -6px rgba(0, 0, 0, 0.08);
  --shadow-blue: 0 8px 28px -10px rgba(77, 107, 254, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html { color-scheme: light; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); }

/* ---------- accessibility ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
.scroll-area { scrollbar-gutter: stable; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* DeepSeek-style accent card: clean white, blue border, no heavy shadow */
.uxcard {
  background: var(--surface);
  border: 1px solid rgba(77, 107, 254, 0.35);
  border-radius: var(--radius-lg);
  color: var(--text);
  box-shadow: var(--shadow-2);
}
.uxcard-sky   { border-color: rgba(77, 107, 254, 0.25); box-shadow: 0 8px 28px -10px rgba(77, 107, 254, 0.3); }
.uxcard-mint  { border-color: rgba(77, 107, 254, 0.45); box-shadow: var(--shadow-blue); }
.uxcard-amber { border-color: rgba(245, 158, 11, 0.35); box-shadow: 0 8px 28px -10px rgba(245, 158, 11, 0.3); }

/* ---------- buttons (pill — DeepSeek style) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font); font-weight: 500; font-size: 0.875rem; line-height: 1.2;
  min-height: 38px; padding: 0.5rem 1.1rem; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .12s, box-shadow .12s, background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); box-shadow: var(--shadow-blue); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--text-3); background: var(--surface-2); }
.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: #fff1f2; color: var(--err); border-color: #fecdd3; }
.btn-danger:hover:not(:disabled) { background: #ffe4e6; }
.btn-invert { background: var(--accent-soft); color: var(--accent); border-color: rgba(77, 107, 254, 0.3); }
.btn-invert:hover:not(:disabled) { background: var(--accent); color: #fff; }
.btn-sm { min-height: 30px; padding: 0.3rem 0.8rem; font-size: 0.75rem; }
.btn-lg { min-height: 46px; padding: 0.7rem 1.6rem; font-size: 0.9375rem; }
.btn-icon { min-height: 34px; width: 34px; padding: 0; }

/* ---------- inputs ---------- */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-family: var(--font); font-size: 0.875rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder { color: var(--text-3); }
.input-error { border-color: #fda4af !important; box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12) !important; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

/* ---------- chips & pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.7rem; font-weight: 500;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
}
.chip-emerald { border-color: #a7f3d0; background: #ecfdf5; color: var(--ok); }
.chip-amber   { border-color: #fde68a; background: #fffbeb; color: var(--warn); }
.chip-indigo  { border-color: rgba(77, 107, 254, 0.3); background: var(--accent-soft); color: var(--accent); }
.chip-rose    { border-color: #fecdd3; background: #fff1f2; color: var(--err); }
.badge-pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.68rem; font-weight: 600; }

/* ---------- logo ---------- */
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 10px;
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-blue);
}

/* ---------- tables ---------- */
table.tbl { width: 100%; font-size: 0.825rem; border-collapse: collapse; }
table.tbl thead th {
  text-align: left; color: var(--text-2); font-weight: 600; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl tbody td { padding: 0.65rem 0.75rem; border-bottom: 1px solid #f0f0f1; vertical-align: middle; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: var(--bg-soft); }

/* ---------- markdown / messages ---------- */
.markdown-body { line-height: 1.7; font-size: 0.9rem; color: #2a2a2a; }
.markdown-body p { margin: 0.45rem 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.25rem; margin: 0.45rem 0; }
.markdown-body ul { list-style: disc; } .markdown-body ol { list-style: decimal; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-weight: 600; margin: 0.8rem 0 0.4rem; color: var(--text); }
.markdown-body h1 { font-size: 1.15rem; } .markdown-body h2 { font-size: 1.05rem; } .markdown-body h3 { font-size: 0.95rem; }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding-left: 0.75rem; color: var(--text-2); margin: 0.45rem 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body table { border-collapse: collapse; margin: 0.5rem 0; font-size: 0.8rem; }
.markdown-body td, .markdown-body th { border: 1px solid var(--border); padding: 0.3rem 0.6rem; }
.markdown-body :not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.35rem; color: var(--text); font-size: 0.85em; }

pre, code { font-family: var(--font-mono); }
pre { position: relative; background: #f6f7f9; color: #2a2a2a; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem; padding-top: 2.4rem; overflow-x: auto; margin: 0.5rem 0; }
code { font-size: 0.82em; }
.copy-btn {
  position: absolute; top: 0.45rem; right: 0.5rem;
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.68rem; font-weight: 500; padding: 0.2rem 0.55rem;
  cursor: pointer; transition: color .15s, background .15s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- typing / streaming ---------- */
.typing-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 999px; background: var(--accent); animation: blink 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; } .typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .15; } 50% { opacity: 1; } }
.stream-caret::after { content: '▍'; color: var(--accent); animation: caret 1s steps(1) infinite; margin-left: 1px; }
@keyframes caret { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ---------- skeleton loaders ---------- */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-2); border-radius: 6px;
}
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: overlayIn .18s ease both;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.3);
  padding: 1.5rem; animation: modalIn .22s var(--ease) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.5rem; }
.modal p { font-size: 0.85rem; color: var(--text-2); line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }

/* ---------- terminal ---------- */
.term {
  background: #0b1120; border: 1px solid #1e293b;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-2);
}
.term-bar {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  background: #111827; border-bottom: 1px solid #1f2937;
  font-family: var(--font-mono); font-size: 0.7rem; color: #94a3b8;
}
.term-dot { width: 10px; height: 10px; border-radius: 999px; }
.term-body { font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.55; padding: 0.9rem; overflow-y: auto; max-height: 22rem; white-space: pre-wrap; word-break: break-all; color: #e2e8f0; }
.term-out { color: #4ade80; } .term-err { color: #f87171; } .term-exit { color: #64748b; }

/* ---------- landing ---------- */
.hero-grid {
  background-image:
    linear-gradient(rgba(77, 107, 254, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 107, 254, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
}
.text-gradient {
  background: linear-gradient(120deg, #1e3af0 0%, #4d6bfe 45%, #8b5cf6 80%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- nav drawer (responsive) ---------- */
.hamburger {
  position: fixed; top: 1rem; left: 1rem; z-index: 55;
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-2); cursor: pointer; color: var(--text);
}
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  aside.app-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    transform: translateX(-105%); transition: transform .25s var(--ease);
  }
  aside.app-sidebar.open { transform: translateX(0); box-shadow: 24px 0 64px -24px rgba(0,0,0,0.35); }
}

/* ---------- chat scroll affordance ---------- */
.scroll-latest {
  position: absolute; bottom: 6.5rem; right: 1.5rem; z-index: 20;
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 0.4rem 0.85rem;
  font-size: 0.75rem; font-weight: 500; color: var(--text-2);
  box-shadow: var(--shadow-2); cursor: pointer;
  transition: opacity .2s, transform .2s;
}
.scroll-latest:hover { color: var(--accent); border-color: var(--accent); }
.scroll-latest.hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }

/* ---------- animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.toast { animation: toastIn .25s ease both; }