body { margin:0; font-family:var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif); background:var(--background,#faf9f7); color:var(--foreground,#1c1917); }

.page-wrap { max-width:1400px; margin:0 auto; padding:16px 20px; }

/* Header */
.page-header { margin-bottom:12px; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; }
.page-header h1 { font-size:20px; font-weight:700; margin:0; }
.page-header p { font-size:12px; color:var(--muted-fg,#78716c); margin:2px 0 0; }
.header-badges { display:flex; gap:6px; align-items:center; }
.header-badge { padding:3px 10px; font-size:11px; font-weight:600; border-radius:12px; background:#f0efec; color:#78716c; }
.session-badge { padding:3px 10px; font-size:10px; font-weight:500; border-radius:12px; background:#dbeafe; color:#3b82f6; font-family:'Consolas',monospace; }

.tag-list { display:flex; flex-wrap:wrap; gap:4px; margin-top:6px; }
.tag-list .tag { display:inline-block; padding:2px 9px; font-size:10px; background:var(--muted,#f0efec); border-radius:10px; color:var(--muted-fg); }
.tag-list .tag.occ { background:#fef3c7; color:#92400e; }
.tag-list .tag.wthr { background:#dbeafe; color:#1e40af; }
.tag-list .tag.func { background:#d1fae5; color:#065f46; }
.tag-list .tag.style { background:#fce7f3; color:#9d174d; }
.tag-list .tag.fit { background:#ede9fe; color:#5b21b6; }

/* ═══════ 2-Column Layout ═══════ */
.split-layout { display:grid; grid-template-columns:1fr 380px; gap:12px; height:calc(100vh - 150px); min-height:450px; }

/* Left: Chat */
.chat-panel { display:flex; flex-direction:column; background:var(--card,#fff); border:1px solid var(--border,#e7e5e2); border-radius:12px; overflow:hidden; }

.chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:10px; }
.chat-messages::-webkit-scrollbar { width:3px; }
.chat-messages::-webkit-scrollbar-thumb { background:rgba(0,0,0,.08); border-radius:4px; }

.msg { max-width:88%; padding:9px 13px; border-radius:12px; font-size:13px; line-height:1.5; word-break:break-word; }
.msg.user { align-self:flex-end; background:var(--primary,#1c1917); color:#fff; border-bottom-right-radius:4px; }
.msg.ai { align-self:flex-start; background:var(--muted,#f0efec); color:var(--foreground); border-bottom-left-radius:4px; }
.msg.ai .meta { margin-top:5px; font-size:10px; color:var(--muted-fg,#78716c); display:flex; gap:6px; }
.msg.system { align-self:center; font-size:11px; color:var(--muted-fg); font-style:italic; background:none; padding:4px 0; }
.msg.error { align-self:center; font-size:11px; color:#dc2626; background:rgba(220,38,38,.05); padding:6px 12px; }

/* Quick actions */
.quick-actions { padding:6px 12px; display:flex; gap:5px; flex-wrap:wrap; border-top:1px solid var(--border); background:var(--card); }
.quick-btn { padding:4px 10px; font-size:11px; border:1px solid var(--border); border-radius:14px; background:var(--background); cursor:pointer; color:var(--foreground); transition:all .15s; }
.quick-btn:hover { background:var(--muted); border-color:var(--muted-fg); }

/* Input */
.chat-input { border-top:1px solid var(--border); padding:10px 12px; display:flex; gap:6px; background:var(--card); }
.chat-input input { flex:1; padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:13px; outline:none; background:var(--background); transition:border-color .2s; }
.chat-input input:focus { border-color:var(--primary); }
.chat-input button { padding:9px 16px; background:var(--primary,#1c1917); color:#fff; border:none; border-radius:8px; font-size:12px; font-weight:600; cursor:pointer; transition:opacity .2s; white-space:nowrap; }
.chat-input button:hover { opacity:.85; }
.chat-input button:disabled { opacity:.5; cursor:not-allowed; }
.btn-clear { background:#dc2626 !important; }
.btn-clear:hover { background:#b91c1c !important; }
.btn-new { background:#2563eb !important; }
.btn-new:hover { background:#1d4ed8 !important; }

/* Thinking */
.thinking { display:flex; gap:4px; padding:8px 13px; }
.thinking span { width:5px; height:5px; border-radius:50%; background:var(--muted-fg); animation:bounce 1.4s ease-in-out infinite; }
.thinking span:nth-child(2) { animation-delay:.2s; }
.thinking span:nth-child(3) { animation-delay:.4s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-7px)} }

/* Markdown */
.msg.ai a { color:var(--primary); text-decoration:underline; }
.msg.ai strong { font-weight:600; }
.msg.ai code { background:var(--muted); padding:1px 4px; border-radius:3px; font-size:11.5px; }
.msg.ai p { margin: 0 0 8px 0; }
.msg.ai p:last-child { margin: 0; }
.msg.ai ul, .msg.ai ol { margin: 0 0 8px 0; padding-left: 20px; }
.msg.ai li { margin-bottom: 2px; }

/* Markdown Tables */
.msg.ai table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 12px; }
.msg.ai th, .msg.ai td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg.ai th { background-color: rgba(0,0,0,.03); font-weight: 600; }
.msg.ai tbody tr:nth-child(even) { background-color: rgba(0,0,0,.01); }

/* ═══════ Right: Pipeline ═══════ */
.pipeline-panel { display:flex; flex-direction:column; background:var(--card,#fff); border:1px solid var(--border,#e7e5e2); border-radius:12px; overflow:hidden; }

.pipeline-header { padding:10px 14px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.pipeline-header h3 { font-size:13px; font-weight:700; margin:0; }
.pipeline-header .path-badge { font-size:10px; padding:2px 8px; background:var(--muted); border-radius:10px; color:var(--muted-fg); font-weight:500; }
.history-count { font-size:10px; padding:2px 8px; background:#dbeafe; border-radius:10px; color:#3b82f6; font-weight:500; }
.timing-badge { font-size:10px; padding:2px 8px; background:#d1fae5; border-radius:10px; color:#065f46; font-weight:600; font-family:'Consolas',monospace; }
.trace-badge { font-size:10px; padding:2px 8px; background:#fce7f3; border-radius:10px; color:#9d174d; font-weight:500; font-family:'Consolas',monospace; cursor:pointer; }
.trace-badge:hover { background:#fbcfe8; }

.pipeline-steps { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:0; }
.pipeline-steps::-webkit-scrollbar { width:3px; }
.pipeline-steps::-webkit-scrollbar-thumb { background:rgba(0,0,0,.08); border-radius:4px; }

.pipeline-empty { display:flex; align-items:center; justify-content:center; flex:1; color:var(--muted-fg); font-size:12px; font-style:italic; }

/* Pipeline Step Card */
.p-step { position:relative; padding:10px 12px 10px 28px; margin:0; }
.p-step:not(:last-child) { border-left:2px solid var(--border); margin-left:7px; padding-bottom:14px; }
.p-step:last-child { border-left:2px solid transparent; margin-left:7px; }

.p-step::before { content:''; position:absolute; left:-1px; top:13px; width:10px; height:10px; border-radius:50%; border:2px solid var(--border); background:var(--card); z-index:1; margin-left:-4px; }
.p-step.s-user::before { background:#6366f1; border-color:#6366f1; }
.p-step.s-planner::before { background:#f59e0b; border-color:#f59e0b; }
.p-step.s-tool_result::before { background:#10b981; border-color:#10b981; }
.p-step.s-responder::before { background:#3b82f6; border-color:#3b82f6; }

.p-step .step-label { font-size:11px; font-weight:700; margin-bottom:3px; }
.p-step.s-user .step-label { color:#6366f1; }
.p-step.s-planner .step-label { color:#f59e0b; }
.p-step.s-tool_result .step-label { color:#10b981; }
.p-step.s-responder .step-label { color:#3b82f6; }

.p-step .step-content { font-size:11.5px; line-height:1.45; color:var(--foreground); white-space:pre-wrap; word-break:break-word; }
.p-step .step-content.truncated { max-height:120px; overflow:hidden; position:relative; }
.p-step .step-content.truncated::after { content:'...'; position:absolute; bottom:0; right:0; padding:0 4px; background:var(--card); color:var(--muted-fg); font-weight:600; }

/* Tool call args */
.tool-args { margin-top:5px; padding:6px 8px; background:rgba(0,0,0,.03); border-radius:6px; font-size:11px; font-family:'Consolas','Monaco',monospace; }
.tool-args .arg-row { display:flex; gap:4px; margin:1px 0; }
.tool-args .arg-key { color:#9333ea; font-weight:600; min-width:110px; }
.tool-args .arg-val { color:var(--foreground); }

/* Pipeline separator */
.pipeline-sep { display:flex; align-items:center; gap:8px; padding:8px 0; margin:4px 0; }
.pipeline-sep::before, .pipeline-sep::after { content:''; flex:1; height:1px; background:var(--border); }
.pipeline-sep span { font-size:10px; color:var(--muted-fg); white-space:nowrap; }

@keyframes slideIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.p-step.new { animation:slideIn .3s ease-out; }

/* Raw JSON toggle */
.raw-json-toggle { margin-top:6px; }
.raw-json-toggle summary { cursor:pointer; font-size:10px; font-weight:600; color:var(--muted-fg,#78716c); user-select:none; padding:2px 0; }
.raw-json-toggle summary:hover { color:var(--foreground); }
.raw-json-toggle pre { margin:4px 0 0; padding:8px; background:rgba(0,0,0,.04); border-radius:6px; font-size:10px; line-height:1.4; font-family:'Consolas','Monaco',monospace; overflow-x:auto; max-height:400px; overflow-y:auto; white-space:pre-wrap; word-break:break-all; color:var(--foreground); border:1px solid var(--border,#e7e5e2); }
.raw-json-toggle pre::-webkit-scrollbar { width:3px; height:3px; }
.raw-json-toggle pre::-webkit-scrollbar-thumb { background:rgba(0,0,0,.1); border-radius:4px; }

/* ═══════ Product Cards ═══════ */
.products-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:8px; margin-top:8px; max-width:88%; }
.product-card { background:var(--card,#fff); border:1px solid var(--border,#e7e5e2); border-radius:10px; overflow:hidden; transition:all .2s; cursor:pointer; text-decoration:none; color:inherit; display:flex; flex-direction:column; }
.product-card:hover { border-color:var(--primary,#1c1917); box-shadow:0 4px 12px rgba(0,0,0,.08); transform:translateY(-2px); }
.product-card .pc-img { width:100%; aspect-ratio:1; object-fit:cover; background:#f5f5f4; }
.product-card .pc-body { padding:8px 10px; flex:1; display:flex; flex-direction:column; gap:3px; }
.product-card .pc-name { font-size:11px; font-weight:600; line-height:1.35; display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; color:var(--foreground); }
.product-card .pc-price-row { display:flex; align-items:center; gap:5px; flex-wrap:wrap; margin-top:auto; }
.product-card .pc-price { font-size:12px; font-weight:700; color:#dc2626; }
.product-card .pc-orig { font-size:10px; color:#a8a29e; text-decoration:line-through; }
.product-card .pc-disc { font-size:9px; font-weight:700; color:#fff; background:#dc2626; padding:1px 5px; border-radius:8px; }
.product-card .pc-meta { font-size:10px; color:var(--muted-fg,#78716c); display:flex; gap:4px; flex-wrap:wrap; }
.product-card .pc-meta span { background:var(--muted,#f0efec); padding:1px 6px; border-radius:8px; }
.product-card .pc-sku { font-size:9px; color:#a8a29e; font-family:'Consolas',monospace; }

/* ═══════ Product Detail Popup (C-Stylist) ═══════ */
.pd-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:9998; opacity:0; pointer-events:none; transition:opacity .25s; }
.pd-overlay.active { opacity:1; pointer-events:auto; }
.pd-popup { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%) scale(.92); z-index:9999; background:#fff; border-radius:12px; max-width:520px; width:92vw; max-height:85vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.25); opacity:0; pointer-events:none; transition:all .3s cubic-bezier(.4,0,.2,1); }
.pd-popup.active { opacity:1; pointer-events:auto; transform:translate(-50%,-50%) scale(1); }
.pd-popup::-webkit-scrollbar { width:4px; }
.pd-popup::-webkit-scrollbar-thumb { background:rgba(0,0,0,.1); border-radius:4px; }
.pd-header { display:flex; justify-content:space-between; align-items:center; padding:16px 20px; border-bottom:1px solid #e8e8e8; }
.pd-header h3 { margin:0; font-size:14px; font-weight:700; letter-spacing:0.5px; color:#1a1a1a; }
.pd-close { width:28px; height:28px; border:none; background:none; font-size:18px; cursor:pointer; color:#999; border-radius:50%; transition:all .2s; }
.pd-close:hover { background:#f0f0f0; color:#333; }
.pd-body { padding:20px; }
.pd-main { display:flex; gap:20px; }
.pd-img-col { flex:0 0 180px; }
.pd-img-main { width:180px; height:240px; border-radius:8px; object-fit:cover; background:#f5f5f5; border:1px solid #eee; }
.pd-info-col { flex:1; min-width:0; }
.pd-name { font-size:16px; font-weight:600; color:#1a1a1a; margin:0 0 4px; line-height:1.4; }
.pd-sku { font-size:12px; color:#999; font-family:'Consolas',monospace; margin-bottom:14px; display:flex; align-items:center; gap:6px; }
.pd-sku-copy { border:none; background:none; cursor:pointer; font-size:13px; color:#999; padding:2px; }
.pd-sku-copy:hover { color:#333; }
.pd-price-block { margin-bottom:16px; display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.pd-orig-price { font-size:14px; color:#999; text-decoration:line-through; }
.pd-discount { font-size:13px; font-weight:700; color:#c8102e; }
.pd-final-price { font-size:20px; font-weight:700; color:#c8102e; }
.pd-detail-link { font-size:12px; color:#3b82f6; text-decoration:none; font-weight:500; margin-left:auto; }
.pd-detail-link:hover { text-decoration:underline; }
.pd-section { margin-bottom:14px; }
.pd-section-label { font-size:12px; font-weight:600; color:#666; margin-bottom:8px; }
.pd-colors { display:flex; gap:8px; flex-wrap:wrap; }
.pd-color-thumb { width:44px; height:44px; border-radius:6px; object-fit:cover; border:2px solid #e8e8e8; cursor:pointer; transition:all .2s; background:#f5f5f5; }
.pd-color-thumb.selected, .pd-color-thumb:hover { border-color:#1a1a1a; box-shadow:0 0 0 1px #1a1a1a; }
.pd-color-name { font-size:11px; color:#666; margin-top:4px; }
.pd-sizes { display:flex; gap:6px; flex-wrap:wrap; }
.pd-size-btn { min-width:40px; height:36px; border:1px solid #ddd; border-radius:4px; background:#fff; font-size:13px; font-weight:500; cursor:pointer; color:#333; transition:all .2s; padding:0 10px; }
.pd-size-btn:hover { border-color:#1a1a1a; }
.pd-size-btn.selected { background:#1a1a1a; color:#fff; border-color:#1a1a1a; }
.pd-size-btn.out { opacity:.35; cursor:not-allowed; text-decoration:line-through; }
.pd-add-cart { width:100%; padding:14px; background:#e8e8e8; color:#666; border:none; border-radius:6px; font-size:13px; font-weight:700; letter-spacing:1px; cursor:pointer; transition:all .2s; margin-top:6px; }
.pd-add-cart.ready { background:#1a1a1a; color:#fff; }
.pd-add-cart.ready:hover { background:#c8102e; }
.pd-loading { text-align:center; padding:40px; color:#999; font-size:13px; }
.pd-loading .spin { display:inline-block; width:24px; height:24px; border:3px solid #eee; border-top-color:#999; border-radius:50%; animation:spin .8s linear infinite; margin-bottom:8px; }
@keyframes spin { to { transform:rotate(360deg); } }