/* ============================================================
   Aproject — Chat app UI kit (layout)
   Recreates the floating-sidebar shell, new-chat hero, composer,
   conversation thread and projects grid. Reuses DS tokens; the
   DS component primitives carry their own styling.
   ============================================================ */

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

.app-shell {
  position: relative; display: flex; height: 100vh; width: 100%; overflow: hidden;
  background: var(--background); color: var(--foreground);
  font-family: var(--font-sans); font-size: var(--text-base); line-height: var(--leading-snug);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- LOGIN ---------------- */
.login { position: absolute; inset: 0; display: grid; place-items: center; background: var(--background); padding: 24px; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-brand { margin-bottom: 22px; }
.login-model { font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); margin-bottom: 6px; letter-spacing: .02em; }
.login-h { font-family: var(--font-serif); font-size: 27px; font-weight: 500; margin: 0 0 8px; text-wrap: balance; }
.login-p { color: var(--muted-foreground); font-size: 13.5px; margin: 0 0 24px; line-height: 1.5; max-width: 320px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.login-hint { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }
.login-foot { margin-top: 26px; font-size: 12px; color: var(--muted-foreground); }
.login-foot a { color: var(--primary); text-decoration: none; font-weight: 550; }

/* ---------------- SIDEBAR ---------------- */
.sidebar {
  position: relative; display: flex; flex-direction: column; flex-shrink: 0;
  width: 268px; margin: 10px; background: var(--sidebar);
  border: 1px solid var(--sidebar-border); border-radius: 16px;
  box-shadow: var(--shadow-panel); color: var(--sidebar-foreground);
}
.sb-header { display: flex; align-items: center; gap: 9px; height: 56px; padding: 0 8px 0 14px; flex-shrink: 0; }
.sb-actions { margin-left: auto; display: flex; gap: 1px; }
.sb-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 8px; }
.sb-section { margin-top: 14px; }
.sb-section.first { margin-top: 4px; }
.sb-label { font-size: 11px; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; color: var(--sidebar-muted); padding: 6px 10px 4px; }

/* segmented product switcher */
.sb-seg { display: flex; gap: 3px; padding: 3px; background: var(--secondary); border-radius: 9px; }
.sb-seg button { flex: 1; height: 32px; border: none; background: transparent; border-radius: 7px; font-size: 12px; font-weight: 550; cursor: pointer; color: var(--muted-foreground); display: flex; align-items: center; justify-content: center; gap: 5px; transition: background .12s, color .12s; }
.sb-seg button.on { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.sb-newchat { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--sidebar-border); background: var(--card); color: var(--foreground); font-size: 13.5px; font-weight: 550; cursor: pointer; box-shadow: var(--shadow-xs); transition: background .12s; }
.sb-newchat:hover { background: var(--sidebar-item-hover); }
.sb-newchat svg { color: var(--primary); }
.sb-search { display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--sidebar-border); background: var(--card); color: var(--sidebar-muted); font-size: 13px; cursor: pointer; }
.sb-search:hover { border-color: var(--border-strong); }
.sb-search .sp { flex: 1; text-align: left; }

.sb-item { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: none; background: transparent; color: var(--sidebar-foreground); border-radius: 8px; font-size: 13.5px; font-weight: 450; text-align: left; cursor: pointer; transition: background .12s; }
.sb-item svg { color: var(--sidebar-muted); flex-shrink: 0; }
.sb-item:hover { background: var(--sidebar-item-hover); }
.sb-item.active { background: var(--sidebar-item-active); color: var(--foreground); font-weight: 550; }
.sb-item.active svg { color: var(--primary); }

.sb-divider { height: 1px; background: var(--sidebar-border); margin: 12px 10px; }
.sb-histhead { display: flex; align-items: center; gap: 5px; padding: 4px 8px; font-size: 11px; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; color: var(--sidebar-muted); }

.sb-chat { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: 6px 8px; border: none; background: transparent; border-radius: 8px; color: var(--sidebar-foreground); text-align: left; cursor: pointer; transition: background .12s; }
.sb-chat:hover { background: var(--sidebar-item-hover); }
.sb-chat.active { background: var(--sidebar-item-active); }
.sb-chat .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: transparent; }
.sb-chat .dot.on { background: var(--unread); box-shadow: 0 0 0 3px rgba(236,122,44,.16); }
.sb-chat .ct { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sb-chat .ct .t { font-size: 13px; font-weight: 450; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-chat.active .ct .t, .sb-chat .ct .t.u { font-weight: 600; color: var(--foreground); }
.sb-chat .ct .m { font-size: 11.5px; color: var(--sidebar-muted); }

.sb-footer { flex-shrink: 0; padding: 8px 10px 12px; border-top: 1px solid var(--sidebar-border); }
.sb-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: none; background: transparent; border-radius: 9px; cursor: pointer; text-align: left; transition: background .12s; }
.sb-user:hover { background: var(--sidebar-item-hover); }
.sb-user .meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sb-user .meta .nm { font-size: 13px; font-weight: 600; color: var(--foreground); }
.sb-user .meta .pl { font-size: 11.5px; color: var(--sidebar-muted); }
.sb-user svg { margin-left: auto; color: var(--sidebar-muted); }

/* ---------------- MAIN ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--background); }
.main-top { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 18px; flex-shrink: 0; }
.main-top .crumb { color: var(--muted-foreground); font-size: 13px; }
.main-top .sep { color: var(--border-strong); }
.main-top .title { font-size: 14px; font-weight: 600; }
.main-top .spacer { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ctx-pill { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; font-size: 12.5px; font-weight: 550; color: var(--secondary-foreground); cursor: pointer; }
.ctx-pill:hover { background: var(--secondary); }

/* new-chat hero */
.hero { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.hero-mark { margin-bottom: 18px; }
.hero-h { font-family: var(--font-serif); font-size: 30px; font-weight: 500; margin: 0 0 26px; text-align: center; text-wrap: balance; }

.composer { width: min(620px, 100%); border: 1px solid var(--border-strong); background: var(--card); border-radius: 16px; padding: 14px 16px; box-shadow: 0 2px 14px rgba(0,0,0,.05); transition: border-color .12s, box-shadow .12s; }
.composer:focus-within { border-color: var(--ring); box-shadow: var(--shadow-focus), 0 2px 14px rgba(0,0,0,.05); }
.composer textarea { width: 100%; border: none; outline: none; resize: none; background: transparent; font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--foreground); min-height: 26px; max-height: 160px; display: block; }
.composer textarea::placeholder { color: var(--muted-foreground); }
.cmp-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cmp-left, .cmp-right { display: flex; align-items: center; gap: 6px; }
.cmp-center { flex: 1; display: flex; justify-content: center; }
.cmp-sq { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--muted-foreground); cursor: pointer; transition: background .12s, color .12s; }
.cmp-sq:hover { background: var(--secondary); color: var(--foreground); }
.cmp-send { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: none; background: var(--primary); color: var(--primary-foreground); cursor: pointer; }
.cmp-send:hover { background: var(--primary-hover); }
.cmp-send:disabled { opacity: .45; cursor: default; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }

/* ---------------- CONVERSATION ---------------- */
.chat-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.chat-thread { max-width: 760px; margin: 0 auto; padding: 26px 24px 18px; display: flex; flex-direction: column; gap: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--terracotta-tint); padding: 12px 16px; border-radius: 14px 14px 4px 14px; max-width: 78%; font-size: 14.5px; line-height: 1.55; color: var(--foreground); }
.msg.assistant { display: flex; gap: 14px; }
.msg.assistant .av { flex-shrink: 0; }
.msg.assistant .body { flex: 1; min-width: 0; }

.reason { margin-bottom: 12px; }
.reason-h { display: inline-flex; align-items: center; gap: 7px; border: none; background: transparent; color: var(--muted-foreground); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; padding: 0; }
.reason-h svg.s { color: var(--primary); }

.tool { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; margin-bottom: 14px; }
.tool-h { display: flex; align-items: center; gap: 8px; padding: 10px 13px; font-size: 13px; }
.tool-h .q { color: var(--muted-foreground); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-h .done { display: inline-flex; align-items: center; gap: 5px; color: var(--success); font-weight: 600; font-size: 12.5px; }
.sources { border-top: 1px solid var(--border); }
.src { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 13px; border: none; border-top: 1px solid var(--border); background: transparent; text-align: left; cursor: pointer; font-size: 12.5px; }
.src:first-child { border-top: none; }
.src:hover { background: var(--secondary); }
.src .num { width: 18px; height: 18px; border-radius: 5px; background: var(--secondary); color: var(--muted-foreground); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.src .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--foreground); }
.src .d { color: var(--muted-foreground); font-family: var(--font-mono); font-size: 11px; }
.src svg { color: var(--muted-foreground); }

.prose { font-size: 14.5px; line-height: 1.62; color: var(--foreground); }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 4px; list-style: none; }
.prose li { position: relative; padding-left: 18px; margin-bottom: 6px; }
.prose li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); }
.prose strong { font-weight: 650; }
.cite { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px; margin: 0 1px; border-radius: 4px; background: var(--sidebar-accent-tint); color: var(--primary); font-size: 10.5px; font-weight: 700; vertical-align: 1px; cursor: pointer; }
.msg-actions { display: flex; gap: 4px; margin-top: 8px; }

.chat-composer { flex-shrink: 0; padding: 0 24px 18px; }
.chat-composer-inner { max-width: 760px; margin: 0 auto; }
.csuggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.chat-hint { text-align: center; font-size: 11.5px; color: var(--muted-foreground); margin-top: 10px; }

/* ---------------- PROJECTS ---------------- */
.proj-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 34px 40px 64px; }
.proj-inner { max-width: 940px; margin: 0 auto; }
.proj-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.proj-title { font-family: var(--font-serif); font-size: 30px; font-weight: 500; margin: 0; }
.proj-sub { color: var(--muted-foreground); font-size: 13.5px; margin: 5px 0 0; }
.proj-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.proj-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pc-row1 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pc-name { font-size: 15.5px; font-weight: 650; line-height: 1.3; margin-bottom: 5px; text-wrap: pretty; }
.pc-addr { font-size: 12.5px; color: var(--muted-foreground); margin-bottom: 2px; }
.pc-type { font-size: 12px; color: var(--muted-foreground); margin-bottom: 15px; }
.pc-prog { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.pc-prog .pct { font-size: 12.5px; font-weight: 650; width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.pc-stage { font-size: 12.5px; color: var(--secondary-foreground); margin-bottom: 15px; min-height: 17px; }
.pc-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-metric .k { font-size: 10.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted-foreground); }
.pc-metric .v { font-size: 12.5px; font-weight: 600; margin-top: 3px; }
.pc-foot { display: flex; align-items: center; gap: 14px; margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted-foreground); }
.pc-foot .mi { display: inline-flex; align-items: center; gap: 5px; }

@keyframes loaderb { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.loader { display: inline-flex; gap: 5px; padding: 4px 0; }
.loader i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-foreground); animation: loaderb 1.2s ease-in-out infinite; }
.loader i:nth-child(2) { animation-delay: .15s; }
.loader i:nth-child(3) { animation-delay: .3s; }
