/* ============================================================
   PARIS VIA — AI Assistant
   ============================================================ */

:root {
  --purple:        #7A3E93;
  --purple-600:    #6B3382;
  --purple-700:    #5A2A6E;
  --purple-200:    #D9BFE4;
  --purple-100:    #EEE2F3;
  --purple-050:    #F7F1FA;

  --ink:           #1E1822;
  --ink-2:         #4A4152;
  --ink-3:         #857C8E;
  --line:          #E7E1EA;
  --line-2:        #F0EBF3;

  --bg:            #FBFAFC;
  --surface:       #FFFFFF;
  --surface-2:     #F6F3F8;

  --danger:        #C0392B;
  --ok:            #2E7D57;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --shadow-1: 0 1px 2px rgba(30,24,34,.05), 0 1px 3px rgba(30,24,34,.04);
  --shadow-2: 0 4px 16px rgba(30,24,34,.07), 0 1px 3px rgba(30,24,34,.05);
  --shadow-3: 0 18px 50px rgba(60,30,75,.14), 0 2px 8px rgba(30,24,34,.06);

  --serif: Georgia, 'Times New Roman', 'Playfair Display', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 272px;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--purple); }
::selection { background: var(--purple-200); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--purple-200); background-clip: content-box; }

/* ============================================================
   Brand lockup
   ============================================================ */
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--purple); }
.brand .mark { width: 76px; height: 76px; }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.wordmark { text-align: center; line-height: 1; user-select: none; }
.wordmark .w1 {
  font-family: var(--serif);
  font-size: 38px;
  letter-spacing: .16em;
  text-indent: .16em;
  font-weight: 400;
  color: var(--purple);
  display: block;
}
.wordmark .w2 {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .5em;
  text-indent: .5em;
  color: var(--purple);
  opacity: .85;
  display: block;
  margin-top: 6px;
}

/* ============================================================
   LOGIN
   ============================================================ */
#view-login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 700px at 12% -10%, #F3E9F8 0%, rgba(243,233,248,0) 60%),
    radial-gradient(900px 600px at 100% 110%, #EFE6F5 0%, rgba(239,230,245,0) 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 44px 36px 34px;
  animation: rise .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.login-card .brand { margin-bottom: 30px; }
.login-sub {
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  margin: -18px 0 28px;
  letter-spacing: .02em;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 7px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.input::placeholder { color: #B9B2C0; }
.input:hover { border-color: var(--purple-200); }
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-100); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  letter-spacing: .01em;
  transition: transform .12s cubic-bezier(.16,1,.3,1), background .15s, box-shadow .15s, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.985); }
.btn-primary { width: 100%; background: var(--purple); color: #fff; box-shadow: 0 2px 10px rgba(122,62,147,.28); }
.btn-primary:hover { background: var(--purple-600); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--purple-200); }

.form-error {
  min-height: 20px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  margin: 10px 0 2px;
}
.login-foot {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line-2);
  text-align: center; font-size: 11.5px; color: var(--ink-3);
  letter-spacing: .08em; text-transform: uppercase;
}

/* ============================================================
   APP SHELL
   ============================================================ */
#view-app { display: none; height: 100dvh; }
#view-app.on { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  min-width: 0;
}
.sb-head {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sb-head .mini-mark { width: 26px; height: 26px; color: var(--purple); flex: none; }
.sb-head .mini-mark svg { width: 100%; height: 100%; display: block; }
.sb-head .t {
  font-family: var(--serif); font-size: 16px; letter-spacing: .14em;
  color: var(--purple); white-space: nowrap; overflow: hidden;
}

.sb-body { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sb-sect { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 10px 8px 6px; }

.new-chat {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px;
  border: 1px dashed var(--purple-200);
  border-radius: var(--r-md);
  color: var(--purple);
  font-weight: 600; font-size: 14px;
  background: var(--surface);
  transition: background .15s, border-color .15s;
}
.new-chat:hover { background: var(--purple-050); border-color: var(--purple); }
.new-chat svg { width: 16px; height: 16px; flex: none; }

.chat-list { display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px;
  transition: background .12s, color .12s;
  min-width: 0;
}
.chat-item .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .dot { width: 6px; height: 6px; border-radius: 99px; background: var(--purple-200); flex: none; }
.chat-item:hover { background: #EDE7F1; color: var(--ink); }
.chat-item.active { background: var(--purple); color: #fff; font-weight: 500; }
.chat-item.active .dot { background: rgba(255,255,255,.7); }
.chat-item .del {
  opacity: 0; width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: grid; place-items: center; color: inherit;
}
.chat-item:hover .del { opacity: .55; }
.chat-item .del:hover { opacity: 1; background: rgba(0,0,0,.08); }
.chat-item.active .del:hover { background: rgba(255,255,255,.18); }
.chat-item .del svg { width: 13px; height: 13px; }

.sb-foot { flex: none; border-top: 1px solid var(--line); padding: 10px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 99px; flex: none;
  display: grid; place-items: center;
  background: var(--purple); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
}
.user-row .nm { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; color: var(--ink-3);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: #E9E3EE; color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251,250,252,.88);
  backdrop-filter: saturate(1.4) blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.burger { display: none; }

/* Agent switcher */
.agent-pick { position: relative; }
.agent-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px 7px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  max-width: 62vw;
}
.agent-btn:hover { border-color: var(--purple-200); box-shadow: var(--shadow-1); }
.agent-btn[aria-expanded="true"] { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-100); }
.agent-em {
  width: 28px; height: 28px; border-radius: 99px; flex: none;
  display: grid; place-items: center; font-size: 14px;
  background: var(--purple-050); border: 1px solid var(--purple-100);
}
.agent-btn .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-btn .chev { width: 15px; height: 15px; color: var(--ink-3); flex: none; transition: transform .18s; }
.agent-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

.menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 320px; max-width: min(400px, 92vw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: 6px; z-index: 60;
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .16s, transform .16s cubic-bezier(.16,1,.3,1);
  max-height: min(70vh, 520px); overflow-y: auto;
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu-item {
  display: flex; align-items: flex-start; gap: 11px;
  width: 100%; text-align: left;
  padding: 10px 11px; border-radius: var(--r-md);
  transition: background .12s;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.sel { background: var(--purple-050); }
.menu-item .agent-em { margin-top: 1px; }
.menu-item .mi { flex: 1; min-width: 0; }
.menu-item .mi b { display: block; font-size: 14px; font-weight: 600; }
.menu-item .mi span { display: block; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; margin-top: 1px; }
.menu-item .tick { width: 16px; height: 16px; color: var(--purple); flex: none; margin-top: 3px; opacity: 0; }
.menu-item.sel .tick { opacity: 1; }

.spacer { flex: 1; }
.pill {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--purple); background: var(--purple-050);
  border: 1px solid var(--purple-100); border-radius: 99px;
  padding: 4px 10px; white-space: nowrap;
}

/* ---------- Messages ---------- */
.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 780px; margin: 0 auto; padding: 28px 20px 12px; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 13px; animation: fade .32s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.msg .ava {
  width: 30px; height: 30px; border-radius: 99px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  margin-top: 1px;
}
.msg.user .ava { background: var(--ink); color: #fff; }
.msg.bot .ava { background: var(--purple-050); border: 1px solid var(--purple-100); color: var(--purple); }
.msg .body { flex: 1; min-width: 0; }
.msg .who { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }
.msg .content { font-size: 15.2px; line-height: 1.68; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .content > *:first-child { margin-top: 0; }
.msg .content > *:last-child { margin-bottom: 0; }
.msg .content p { margin: 0 0 .75em; }
.msg .content ul, .msg .content ol { margin: 0 0 .75em; padding-left: 1.4em; }
.msg .content li { margin: .22em 0; }
.msg .content h1, .msg .content h2, .msg .content h3 { font-family: var(--serif); font-weight: 600; margin: 1.1em 0 .5em; line-height: 1.3; }
.msg .content h1 { font-size: 1.4em; } .msg .content h2 { font-size: 1.22em; } .msg .content h3 { font-size: 1.08em; }
.msg .content code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; }
.msg .content pre { background: #221C27; color: #EDE7F1; border-radius: var(--r-md); padding: 14px 16px; overflow-x: auto; margin: 0 0 .8em; }
.msg .content pre code { background: none; border: none; padding: 0; color: inherit; font-size: 13px; line-height: 1.6; }
.msg .content blockquote { margin: 0 0 .8em; padding: 2px 0 2px 14px; border-left: 3px solid var(--purple-200); color: var(--ink-2); }
.msg .content table { border-collapse: collapse; width: 100%; margin: 0 0 .8em; font-size: 14px; display: block; overflow-x: auto; }
.msg .content th, .msg .content td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.msg .content th { background: var(--surface-2); font-weight: 600; }
.msg .content hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.msg .content a { color: var(--purple); text-underline-offset: 2px; }

.msg .files { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }

.typing { display: inline-flex; gap: 4px; align-items: center; height: 22px; }
.typing i { width: 6px; height: 6px; border-radius: 99px; background: var(--purple-200); animation: bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .16s; } .typing i:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%,60%,100% { opacity:.35; transform: translateY(0); } 30% { opacity:1; transform: translateY(-4px); } }

.caret { display: inline-block; width: 2px; height: 1.05em; background: var(--purple); vertical-align: -2px; margin-left: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Empty state ---------- */
.empty { max-width: 780px; margin: 0 auto; padding: min(9vh, 80px) 20px 20px; text-align: center; animation: fade .4s ease both; }
.empty .mark { width: 62px; height: 62px; margin: 0 auto 20px; color: var(--purple); opacity: .95; }
.empty .mark svg { width: 100%; height: 100%; }
.empty h2 { font-family: var(--serif); font-weight: 400; font-size: 27px; margin: 0 0 8px; letter-spacing: .01em; }
.empty p { color: var(--ink-3); margin: 0 auto 28px; max-width: 460px; font-size: 14.5px; }
.sugg { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; text-align: left; }
.sugg button {
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: 14px; color: var(--ink-2);
  transition: border-color .15s, box-shadow .15s, transform .15s, color .15s;
}
.sugg button:hover { border-color: var(--purple-200); box-shadow: var(--shadow-2); transform: translateY(-1px); color: var(--ink); }

/* ---------- Composer ---------- */
.composer-wrap { flex: none; padding: 8px 20px 18px; background: linear-gradient(to bottom, rgba(251,250,252,0), var(--bg) 34%); }
.composer { max-width: 780px; margin: 0 auto; }

.attach-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 8px 6px 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; font-size: 12.5px; color: var(--ink-2);
  max-width: 240px; box-shadow: var(--shadow-1);
}
.chip svg { width: 13px; height: 13px; color: var(--purple); flex: none; }
.chip .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .x { width: 17px; height: 17px; border-radius: 99px; display: grid; place-items: center; color: var(--ink-3); flex: none; }
.chip .x:hover { background: var(--line); color: var(--ink); }
.chip .x svg { width: 10px; height: 10px; color: inherit; }

.box {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 7px 7px 7px 8px;
  box-shadow: var(--shadow-2);
  transition: border-color .15s, box-shadow .15s;
}
.box:focus-within { border-color: var(--purple-200); box-shadow: 0 0 0 4px var(--purple-050), var(--shadow-2); }
.box.drag { border-color: var(--purple); border-style: dashed; background: var(--purple-050); }

#input {
  flex: 1; min-width: 0;
  border: none; outline: none; resize: none; background: none;
  padding: 9px 4px; max-height: 200px; line-height: 1.55;
  font-size: 15.2px;
}
#input::placeholder { color: #B4ACBC; }

.tool {
  width: 36px; height: 36px; border-radius: 99px; flex: none;
  display: grid; place-items: center; color: var(--ink-3);
  transition: background .14s, color .14s, transform .14s;
}
.tool:hover { background: var(--surface-2); color: var(--purple); }
.tool svg { width: 19px; height: 19px; }
.tool.rec { background: #FDECEA; color: var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.35); } 50% { box-shadow: 0 0 0 7px rgba(192,57,43,0); } }

#send {
  width: 36px; height: 36px; border-radius: 99px; flex: none;
  display: grid; place-items: center;
  background: var(--purple); color: #fff;
  transition: background .14s, transform .14s, opacity .14s;
}
#send:hover { background: var(--purple-600); }
#send:disabled { background: var(--line); color: var(--ink-3); cursor: default; }
#send:not(:disabled):active { transform: scale(.92); }
#send svg { width: 18px; height: 18px; }
#send.stop { background: var(--ink); }

.hint { text-align: center; font-size: 11.5px; color: var(--ink-3); margin-top: 9px; letter-spacing: .01em; }
.hint kbd { font-family: var(--sans); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 4px; background: var(--surface); }

.rec-live { color: var(--danger); font-weight: 600; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px;
  font-size: 13.5px; box-shadow: var(--shadow-3); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
#scrim {
  position: fixed; inset: 0; background: rgba(30,24,34,.4); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(1px);
}
#scrim.on { opacity: 1; pointer-events: auto; }

@media (max-width: 860px) {
  #view-app.on { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 84vw; max-width: 320px;
    z-index: 50; transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.16,1,.3,1);
    box-shadow: var(--shadow-3);
  }
  .sidebar.on { transform: none; }
  .burger { display: grid; }
  .thread { padding: 20px 15px 8px; gap: 20px; }
  .composer-wrap { padding: 6px 12px 14px; }
  .agent-btn { max-width: 52vw; }
  .agent-btn .nm { font-size: 13.5px; }
  .menu { min-width: min(340px, 90vw); }
  .empty { padding-top: 40px; }
  .sugg { grid-template-columns: 1fr; }
  .hint { display: none; }
  .msg .content { font-size: 15px; }
}
@media (max-width: 420px) {
  .login-card { padding: 34px 22px 26px; }
  .brand .mark { width: 64px; height: 64px; }
  .wordmark .w1 { font-size: 32px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
