:root {
  --bg: #262624;
  --sidebar: #1f1e1d;
  --surface: #30302e;
  --surface-2: #3a3a37;
  --hover: #2c2c2a;
  --active: #3a3936;
  --border: #3f3e3a;
  --text: #f5f4ef;
  --muted: #a6a39a;
  --faint: #75736c;
  --accent: #d97757;
  --accent-ink: #ffffff;
  --danger: #e5675c;
  --serif: "Tiempos Text", "Iowan Old Style", "Palatino Linotype", Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.brand-big { font: 400 34px/1.1 var(--serif); text-align: center; margin-bottom: 18px; }
.spark { color: var(--accent); }
.login label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.login input { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; color: var(--text); font: inherit; font-size: 15px; outline: none; }
.login input:focus { border-color: #6b6a64; }
.login button { margin-top: 6px; background: var(--text); color: #1f1e1d; border-radius: 10px; padding: 11px; font-weight: 600; }
.login button:disabled { opacity: .6; }
.login-err { min-height: 20px; color: var(--danger); font-size: 13px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar { width: 288px; flex: none; background: var(--sidebar); border-right: 1px solid #2b2a28; display: flex; flex-direction: column; padding: 10px 8px 8px; transition: margin-left .2s ease; }
.app.collapsed .sidebar { margin-left: -288px; }
.sb-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 10px; }
.brand { font: 400 20px/1 var(--serif); letter-spacing: -.01em; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.search { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; padding: 0 10px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: #262523; color: var(--faint); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: inherit; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
.sb-nav { display: flex; flex-direction: column; gap: 1px; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: #dcdad3; }
.sb-item:hover { background: var(--hover); }
.sb-item.active { background: var(--active); }
.sb-section { margin: 20px 10px 6px; font-size: 12px; color: var(--faint); }
.recents { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #3a3936 transparent; }
.recents li { position: relative; }
.recents a { display: block; padding: 6px 34px 6px 10px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #dcdad3; }
.recents a:hover, .recents li:hover a { background: var(--hover); }
.recents a.active { background: var(--active); }
.recents .proj-tag { color: var(--faint); font-size: 12px; margin-left: 6px; }
.del { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--faint); opacity: 0; }
.del svg { width: 15px; height: 15px; }
.recents li:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); background: #3a2826; }
.recents .empty { padding: 6px 10px; color: var(--faint); }
.sb-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid #2b2a28; margin-top: 8px; padding: 10px 6px 2px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #c9c6bb; color: #1f1e1d; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.who small { color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
#sbOpen { display: none; }
.app.collapsed #sbOpen { display: grid; }
.crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb a:hover { color: var(--text); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- composer ---------- */
.composer { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 14px 14px 10px 16px; box-shadow: 0 4px 20px rgba(0,0,0,.18); transition: border-color .15s; }
.composer:focus-within { border-color: #57564f; }
.composer textarea { width: 100%; resize: none; background: none; border: 0; outline: none; color: var(--text); font: 15.5px/1.5 var(--sans); max-height: 40vh; min-height: 24px; padding: 0; }
.composer textarea::placeholder { color: var(--faint); }
.composer-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.composer-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.composer-right { display: flex; align-items: center; gap: 12px; }
.model { color: var(--muted); font-size: 13px; }
.send { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.send:disabled { background: #6e4a3c; color: #c9b3a9; cursor: default; }
.send.stop { background: var(--text); color: #1f1e1d; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 13px; max-width: 220px; }
.chip select { background: none; border: 0; color: inherit; font: inherit; outline: none; max-width: 180px; cursor: pointer; }
.chip select option { background: var(--surface); color: var(--text); }

/* ---------- home ---------- */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 16px 12vh; }
.home-inner { width: 100%; max-width: 672px; }
.greet { font: 400 clamp(28px, 4.2vw, 40px)/1.15 var(--serif); text-align: center; margin: 0 0 28px; letter-spacing: -.01em; display: flex; align-items: center; justify-content: center; gap: 12px; }
.greet .spark { font-size: 1.05em; }
.notice { margin-top: 14px; text-align: center; color: var(--faint); font-size: 12.5px; }

/* ---------- chat ---------- */
.thread { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a3936 transparent; }
.thread-inner { max-width: 768px; margin: 0 auto; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 22px; }
.msg-user { align-self: flex-end; max-width: 85%; background: #141413; border-radius: 16px; padding: 10px 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg-ai { font: 16.5px/1.65 var(--serif); color: #ecebe5; word-wrap: break-word; }
.msg-ai > :first-child { margin-top: 0; }
.msg-ai > :last-child { margin-bottom: 0; }
.msg-ai p { margin: 0 0 .85em; }
.msg-ai h1, .msg-ai h2, .msg-ai h3, .msg-ai h4 { font-family: var(--sans); font-weight: 600; line-height: 1.3; margin: 1.3em 0 .5em; }
.msg-ai h1 { font-size: 1.35em; } .msg-ai h2 { font-size: 1.2em; } .msg-ai h3, .msg-ai h4 { font-size: 1.05em; }
.msg-ai ul, .msg-ai ol { margin: 0 0 .85em; padding-left: 1.5em; }
.msg-ai li { margin: .25em 0; }
.msg-ai a { color: #e59a7c; text-decoration: underline; text-underline-offset: 2px; }
.msg-ai code { font: .86em var(--mono); background: #1d1d1b; border: 1px solid #34332f; border-radius: 5px; padding: .1em .35em; }
.msg-ai pre { background: #1d1d1b; border: 1px solid #34332f; border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0 0 1em; }
.msg-ai pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.55; }
.msg-ai blockquote { margin: 0 0 .85em; padding-left: 14px; border-left: 3px solid #4a4944; color: var(--muted); }
.msg-ai hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.msg-ai table { border-collapse: collapse; margin: 0 0 1em; font: 14px/1.45 var(--sans); display: block; overflow-x: auto; }
.msg-ai th, .msg-ai td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.msg-ai th { background: #2d2d2a; }
.msg-err { color: var(--danger); font-size: 14px; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.thinking .spark { display: inline-block; font-size: 22px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.caret::after { content: ""; display: inline-block; width: .5em; height: 1em; background: var(--accent); vertical-align: -.15em; margin-left: 2px; border-radius: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-foot { flex: none; padding: 0 16px 18px; }
.chat-foot .composer { max-width: 768px; margin: 0 auto; display: block; }
.disclaimer { text-align: center; color: var(--faint); font-size: 11.5px; margin-top: 8px; }

/* ---------- projects ---------- */
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 820px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-title { font: 400 30px/1.2 var(--serif); margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; background: var(--text); color: #1f1e1d; font-weight: 600; font-size: 13.5px; }
.btn svg { width: 16px; height: 16px; }
.btn.ghost { background: none; color: var(--muted); border: 1px solid var(--border); font-weight: 500; }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.btn.danger:hover { color: var(--danger); border-color: #5a3330; background: #2e2220; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #2a2a28; transition: border-color .15s, background .15s; }
.card:hover { border-color: #55544e; background: #2e2e2b; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; padding-right: 26px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { margin-top: auto; color: var(--faint); font-size: 12px; }
.card .del { top: 14px; transform: none; }
.card:hover .del { opacity: 1; }
.empty-state { border: 1px dashed var(--border); border-radius: 14px; padding: 36px 16px; text-align: center; color: var(--muted); }
.proj-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.proj-layout .composer { margin-bottom: 22px; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.list li { position: relative; border-bottom: 1px solid var(--border); }
.list a { display: flex; flex-direction: column; padding: 12px 40px 12px 4px; }
.list a:hover { background: #2a2a28; }
.list small { color: var(--faint); font-size: 12px; }
.list li:hover .del { opacity: 1; }
.panel { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: #2a2a28; }
.panel h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.panel textarea, .field { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; color: var(--text); font: 13.5px/1.5 var(--sans); padding: 9px 10px; outline: none; resize: vertical; }
.panel textarea:focus, .field:focus { border-color: #6b6a64; }
.panel .hint { color: var(--faint); font-size: 12px; margin: 6px 0 10px; }
.title-input { background: none; border: 1px solid transparent; border-radius: 8px; color: var(--text); font: 400 30px/1.2 var(--serif); padding: 2px 6px; margin-left: -7px; width: 100%; outline: none; }
.title-input:hover { border-color: var(--border); }
.title-input:focus { border-color: #6b6a64; }

/* ---------- dialog ---------- */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
dialog p { margin: 0 0 18px; color: var(--muted); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .btn.red { background: var(--danger); color: #fff; }
dialog label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); padding: 9px 16px; border-radius: 10px; font-size: 13.5px; z-index: 50; }

/* ---------- mobil ---------- */
@media (max-width: 820px) {
  .proj-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(288px, 86vw); margin-left: 0; transform: translateX(0); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .app.collapsed .sidebar { margin-left: 0; transform: translateX(-105%); box-shadow: none; }
  .app:not(.collapsed) .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
  .del { opacity: .7; }
  .msg-ai { font-size: 16px; }
  .home { padding-bottom: 6vh; }
}

/* ---------- fișiere ---------- */
.attach { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.attachments:empty { display: none; }
.att { position: relative; display: flex; align-items: center; gap: 8px; height: 52px; max-width: 220px; padding: 6px 10px 6px 6px; border: 1px solid var(--border); border-radius: 10px; background: #2a2a28; }
.att.img { padding: 0; width: 52px; overflow: hidden; }
.att.img img { width: 100%; height: 100%; object-fit: cover; }
.att .x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: #1f1e1d; display: grid; place-items: center; opacity: 0; transition: opacity .1s; }
.att .x svg { width: 12px; height: 12px; stroke-width: 2.2; }
.att:hover .x, .att .x:focus-visible { opacity: 1; }
.att.busy::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(31,30,29,.55) linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent) 0 0/200% 100%; animation: shimmer 1.2s linear infinite; }
.att.err { border-color: var(--danger); }
@keyframes shimmer { to { background-position: -200% 0; } }
.ficon { width: 38px; height: 38px; flex: none; border-radius: 8px; display: grid; place-items: center; font: 700 10px/1 var(--sans); letter-spacing: .03em; color: #fff; background: #6b6a64; }
.ficon.pdf { background: #c94a3f; } .ficon.doc { background: #2f6fd1; } .ficon.xls { background: #1f8a4c; }
.ficon.ppt { background: #d0632f; } .ficon.img { background: #8a5cc9; } .ficon.txt { background: #5d6b7a; }
.fmeta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.fmeta b { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta small { color: var(--faint); font-size: 11.5px; }
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.msg-files.user { align-self: flex-end; justify-content: flex-end; max-width: 85%; margin-bottom: -14px; }
.msg-ai .msg-files { margin-top: 14px; font-family: var(--sans); }
.fcard { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; padding: 8px 12px 8px 8px; border: 1px solid var(--border); border-radius: 12px; background: #2a2a28; color: var(--text); text-decoration: none !important; }
.fcard:hover { border-color: #57564f; background: #2e2e2b; }
.fcard .dl { margin-left: auto; color: var(--muted); }
.fimg { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #1d1d1b; }
.fimg img { display: block; max-width: min(100%, 420px); max-height: 360px; object-fit: contain; }
.msg-files.user .fimg img { max-width: 220px; max-height: 220px; }
.status { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 14px var(--sans); margin-top: 6px; }
.status .spark { display: inline-block; color: var(--accent); animation: spin 2.4s linear infinite; }
.dropzone { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(20,20,19,.75); border: 2px dashed var(--accent); pointer-events: none; font: 400 26px var(--serif); }
