:root {
  --bg: #fffaf7;
  --panel: #ffffff;
  --side: #fff1f5;
  --ink: #3b3340;
  --muted: #8a7f8f;
  --line: #f0dfe6;
  --pink: #f2a7c3;
  --pink-strong: #d9568a;
  --mint: #dff3ea;
  --mint-ink: #2f6b55;
  --yellow: #fff1bf;
  --human: #fdeaf1;
  --bot: #ffffff;
  --error: #b3261e;
  --shadow: 0 1px 3px rgba(80, 40, 60, .08), 0 4px 16px rgba(80, 40, 60, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a1f;
    --panel: #262228;
    --side: #221e24;
    --ink: #f1eaf2;
    --muted: #a99fac;
    --line: #3a3340;
    --pink: #c56f93;
    --pink-strong: #f08fb7;
    --mint: #1f3b31;
    --mint-ink: #9fdcc4;
    --yellow: #3d3520;
    --human: #3a2630;
    --bot: #2b262e;
    --error: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--pink-strong); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.primary {
  background: var(--pink-strong);
  color: #fff;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.05); }
.primary:disabled { opacity: .55; cursor: default; }
.link { color: var(--pink-strong); padding: 4px 6px; border-radius: 6px; text-align: left; }
.link:hover { background: var(--human); }
.icon { font-size: 20px; padding: 6px 8px; border-radius: 8px; line-height: 1; }
.icon:hover { background: var(--human); }
.wide { width: 100%; }
.error { color: var(--error); margin: 6px 0 0; min-height: 1em; font-size: 14px; }
.hint { color: var(--muted); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo { width: 26px; height: 26px; }

/* autentificare */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 22px; margin: 18px 0 12px; }
.auth-card label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
.auth-card input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
.auth-card input:focus, textarea:focus { outline: 2px solid var(--pink); outline-offset: 1px; }
.auth-card .primary { width: 100%; margin-top: 8px; padding: 10px; }

/* aplicația */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100vh; height: 100dvh; overflow: hidden; }
.app > * { min-height: 0; }
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 4px 2px; }
.list { display: flex; flex-direction: column; gap: 2px; }
.item {
  display: block; text-align: left; padding: 8px 10px; border-radius: 10px; width: 100%;
  color: var(--ink); text-decoration: none;
}
.item:hover { background: var(--panel); }
.item.active { background: var(--panel); box-shadow: var(--shadow); }
.item .t { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pink-strong); margin-right: 6px; animation: pulse 1.2s infinite; }
.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); }
.empty-list { color: var(--muted); font-size: 13px; padding: 4px 10px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.title { font-size: 17px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 6px; align-items: center; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg {
  max-width: min(820px, 100%);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bot);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.msg.human { background: var(--human); align-self: flex-end; border-color: transparent; }
.msg.bot { align-self: flex-start; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .meta strong { color: var(--ink); font-size: 13px; }
.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p { margin: 6px 0; }
.body h2, .body h3, .body h4, .body h5, .body h6 { margin: 14px 0 6px; line-height: 1.3; }
.body h2 { font-size: 18px; }
.body h3 { font-size: 16px; }
.body h4, .body h5, .body h6 { font-size: 15px; }
.body ul, .body ol { margin: 6px 0; padding-left: 22px; }
.body li { margin: 2px 0; }
.body code { background: var(--yellow); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.body pre { background: var(--side); padding: 10px; border-radius: 10px; overflow-x: auto; }
.body pre code { background: none; padding: 0; }
.body blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--pink); color: var(--muted); }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.table { overflow-x: auto; margin: 8px 0; }
.body table { border-collapse: collapse; font-size: 14px; }
.body th, .body td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.body th { background: var(--side); }

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: flex-start; }
.files img { max-width: 220px; max-height: 180px; border-radius: 10px; display: block; border: 1px solid var(--line); }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--mint); color: var(--mint-ink); font-size: 13px; text-decoration: none;
}

.working .steps { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.dots { display: inline-flex; gap: 4px; margin: 4px 0; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--pink); animation: pulse 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

.welcome { max-width: 680px; margin: 6vh auto 0; text-align: center; }
.welcome h2 { font-size: 24px; margin-bottom: 4px; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 20px; text-align: left; }
.suggestion {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); text-align: left;
}
.suggestion:hover { border-color: var(--pink); }
.pc-note { background: var(--mint); color: var(--mint-ink); border-radius: var(--radius); padding: 10px 14px; max-width: 820px; }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 18px 12px; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
textarea {
  flex: 1; resize: none; max-height: 40vh; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
}
.compose-row .primary { height: 44px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--mint); color: var(--mint-ink); font-size: 13px; max-width: 280px;
}
.chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { color: inherit; padding: 0 6px; font-size: 16px; }

.drop {
  position: fixed; inset: 0; background: rgba(217, 86, 138, .18); display: grid; place-items: center; z-index: 50;
  pointer-events: none;
}
.drop div { background: var(--panel); padding: 18px 28px; border-radius: var(--radius); border: 2px dashed var(--pink-strong); font-weight: 600; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
  width: min(560px, calc(100% - 32px)); padding: 20px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(30, 20, 30, .35); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
dialog input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  color: var(--ink); margin: 4px 0 10px;
}
dialog label { display: block; color: var(--muted); font-size: 14px; }
.user-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.notes { max-height: 60vh; overflow-y: auto; }

.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(30, 20, 30, .35); z-index: 19; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 20;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .sidebar.open { transform: none; }
  .messages { padding: 12px; }
  .topbar, .composer { padding-left: 12px; padding-right: 12px; }
  .msg { max-width: 100%; }
  .top-actions .link { padding: 4px; }
}
