:root{--bg:#f4f1ea;--ink:#1f2937;--muted:#6b7280;--line:rgba(31,41,55,.12);--card:#fffaf2}*{box-sizing:border-box}html,body{height:100%;margin:0}body{font-family:Inter,system-ui,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--ink)}.hidden{display:none!important}.app{height:100vh;display:flex;flex-direction:column}header{padding:14px 18px 10px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.55);backdrop-filter:blur(12px)}.titlebar{display:flex;justify-content:space-between;align-items:center;gap:16px}h1{margin:0;font-size:22px;letter-spacing:-.02em}.toolbar{display:flex;gap:8px;flex-wrap:wrap}button{border:0;border-radius:12px;padding:9px 12px;font-weight:700;cursor:pointer;background:#374151;color:white}button.ghost{background:rgba(255,255,255,.75);color:#374151;border:1px solid var(--line)}button:disabled{opacity:.55;cursor:not-allowed}.board{flex:1;min-height:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px;padding:14px 18px 18px}.col{--col-bg:#e8edf8;--col-bg-active:#f7f9fe;background:var(--col-bg);border:1px solid rgba(31,41,55,.11);border-radius:18px;min-height:0;height:100%;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 10px 30px rgba(31,41,55,.06)}.col.processing{background:var(--col-bg-active);box-shadow:0 14px 40px rgba(59,130,246,.14)}.col:nth-child(1){--col-bg:#b7c7e6;--col-bg-active:#f7f9ff}.col:nth-child(2){--col-bg:#adddc6;--col-bg-active:#f7fcfa}.col:nth-child(3){--col-bg:#d8c08c;--col-bg-active:#fffaf0}.col:nth-child(4){--col-bg:#c9ade0;--col-bg-active:#fbf7ff}.col:nth-child(5){--col-bg:#e2acac;--col-bg-active:#fff8f8}.col-head{display:flex;align-items:flex-start;justify-content:space-between;padding:13px 14px 10px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.3);cursor:grab}.col-head:active{cursor:grabbing}.col.dragging{opacity:.55;transform:scale(.985);box-shadow:0 18px 50px rgba(15,23,42,.18)}.topic-title{display:flex;align-items:center;gap:7px}.col h2{margin:0;font-size:24px;letter-spacing:-.03em}.edit-topic{background:rgba(255,255,255,.55);color:#374151;border:1px solid rgba(31,41,55,.12);padding:3px 7px;border-radius:8px;font-size:13px}.topic-edit-form{display:flex;gap:6px;align-items:center}.topic-edit-form input{width:150px;border:1px solid rgba(31,41,55,.18);border-radius:9px;padding:6px 8px;background:rgba(255,255,255,.75)}.topic-edit-form button{padding:6px 8px;border-radius:9px}.col-actions{display:flex;align-items:center;gap:6px}.badge{font-size:11px;border-radius:999px;padding:4px 8px;background:rgba(31,41,55,.09);color:#374151;cursor:pointer;user-select:none}.badge:hover{background:rgba(31,41,55,.16)}.close-column{padding:2px 7px;border-radius:999px;background:rgba(31,41,55,.10);color:#374151;border:1px solid rgba(31,41,55,.08);font-size:14px;line-height:1.2}.close-column:hover{background:rgba(220,38,38,.16);color:#991b1b}.state-line{margin-top:4px;display:flex;align-items:center;gap:7px;color:#475569;font-size:12px}.state-dot{width:9px;height:9px;border-radius:50%;background:#64748b}.processing .state-dot{background:#3b82f6;box-shadow:0 0 0 5px rgba(59,130,246,.12);animation:pulse-dot 1.1s ease-in-out infinite}.processing .state-text{font-weight:800;color:#1d4ed8;animation:pulse-text 1.1s ease-in-out infinite}@keyframes pulse-text{0%,100%{opacity:.55;transform:translateX(0)}50%{opacity:1;text-shadow:0 0 12px rgba(59,130,246,.45);transform:translateX(1px)}}@keyframes pulse-dot{0%,100%{transform:scale(.85);box-shadow:0 0 0 4px rgba(59,130,246,.10)}50%{transform:scale(1.25);box-shadow:0 0 0 9px rgba(59,130,246,.18)}}.column-tools{display:flex;gap:6px;padding:9px 12px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.18)}.column-tools button{padding:6px 7px;border-radius:10px;background:rgba(255,255,255,.62);color:#1f2937;border:1px solid rgba(31,41,55,.08);font-size:15px}.meta{padding:8px 14px;color:var(--muted);font-size:11px;border-bottom:1px solid var(--line);line-height:1.45}.messages{padding:12px;display:flex;flex-direction:column;gap:10px;overflow:auto;flex:1;min-height:0}.msg{border:1px solid rgba(31,41,55,.12);border-radius:14px;padding:9px 10px;background:rgba(255,255,255,.56)}.msg.user{border-color:rgba(37,99,235,.24);background:rgba(255,255,255,.72)}.msg.assistant{border-color:rgba(31,41,55,.13);background:rgba(255,255,255,.5)}.msg.pending{border-style:dashed;opacity:.8}.msg .role{text-transform:uppercase;font-size:10px;letter-spacing:.08em;color:#64748b;margin-bottom:5px}.msg .text{white-space:pre-wrap;font-size:13px;line-height:1.38}.msg-image{display:block;max-width:100%;max-height:360px;margin-top:8px;border-radius:12px;border:1px solid rgba(31,41,55,.14);object-fit:contain;background:rgba(255,255,255,.55)}.attachments-preview{padding:9px 12px 0;border-top:1px solid var(--line);display:flex;gap:8px;flex-wrap:wrap;background:rgba(255,255,255,.22)}.attachment-chip{position:relative;width:76px;height:76px;border-radius:12px;overflow:hidden;border:1px solid rgba(31,41,55,.18);background:white}.attachment-chip img{width:100%;height:100%;object-fit:cover}.attachment-chip button{position:absolute;right:4px;top:4px;padding:1px 6px;border-radius:999px;background:rgba(15,23,42,.76);color:white}form{padding:11px 12px 8px;border-top:1px solid var(--line);display:flex;gap:8px;align-items:flex-end;background:rgba(255,255,255,.22)}textarea{flex:1;min-height:42px;max-height:38vh;border-radius:13px;border:1px solid rgba(31,41,55,.18);background:rgba(255,255,255,.72);color:var(--ink);padding:10px;resize:none;overflow:hidden;line-height:1.35}.send-status{min-height:19px;padding:0 12px 9px;font-size:12px;color:#64748b}.login{height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#f6efe5,#e8edf8)}.login-card{width:min(360px,calc(100vw - 32px));background:rgba(255,255,255,.75);border:1px solid var(--line);border-radius:22px;padding:24px;box-shadow:0 18px 60px rgba(31,41,55,.12);display:flex;flex-direction:column;gap:12px}.login-card p{margin:0;color:var(--muted)}.login-card input{padding:12px;border-radius:12px;border:1px solid var(--line);font-size:16px}#login-error{min-height:18px;color:#b91c1c;font-size:13px}.modal{position:fixed;inset:0;background:rgba(15,23,42,.28);display:grid;place-items:center;padding:24px}.modal-card{width:min(720px,100%);max-height:78vh;overflow:auto;background:#fffaf2;border-radius:22px;padding:22px;box-shadow:0 24px 80px rgba(15,23,42,.22);position:relative}.modal-close{position:absolute;right:14px;top:12px;background:transparent;color:#374151;font-size:24px;padding:4px 9px}.file-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}.file-list li{padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:rgba(255,255,255,.7)}.topic-list{display:flex;flex-direction:column;gap:8px;margin-top:12px}.topic-choice{width:100%;text-align:left;display:grid;gap:3px;background:rgba(255,255,255,.72);color:#1f2937;border:1px solid var(--line);border-radius:14px;padding:10px 12px}.topic-choice:hover{background:#fff}.topic-choice.active{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.12)}.topic-choice.disabled{opacity:.48;cursor:not-allowed;background:rgba(255,255,255,.45)}.topic-choice span{font-size:14px}.topic-choice small{color:#64748b}@media(max-width:1300px){.board{grid-template-columns:repeat(2,minmax(280px,1fr))}.col{min-height:70vh}}@media(max-width:720px){.board{grid-template-columns:1fr}.titlebar{align-items:flex-start;flex-direction:column}.col{min-height:78vh}}
/* UI refinements: thinking state, media lightbox, column color picker */
.col.processing{background:#e5e7eb!important;box-shadow:0 14px 40px rgba(15,23,42,.12)}
.processing .state-dot{background:#6b7280;box-shadow:0 0 0 5px rgba(107,114,128,.13)}
.processing .state-text{color:#374151;text-shadow:none}
.edit-topic,.pick-color{background:rgba(255,255,255,.55);color:#374151;border:1px solid rgba(31,41,55,.12);padding:3px 7px;border-radius:8px;font-size:13px;line-height:1.2}.pick-color{font-size:12px}.column-color-input{position:absolute;inline-size:1px;block-size:1px;opacity:0;pointer-events:none}.msg-media{display:block;max-width:100%;margin-top:8px;border-radius:12px;border:1px solid rgba(31,41,55,.14);background:rgba(255,255,255,.55);cursor:zoom-in}.msg-image,.msg-video{max-height:360px;object-fit:contain}.msg-audio-card{padding:10px 12px;color:#1f2937;font-weight:700}.media-viewer{position:fixed;inset:0;z-index:1000;background:rgba(2,6,23,.92);display:grid;place-items:center;padding:28px}.media-viewer.hidden{display:none!important}.media-viewer-close{position:fixed;top:14px;right:18px;background:rgba(255,255,255,.12);color:white;border:1px solid rgba(255,255,255,.2);border-radius:999px;font-size:28px;line-height:1;padding:6px 13px}.media-viewer-content{max-width:min(96vw,1400px);max-height:92vh;display:grid;place-items:center;color:white}.media-viewer-content img,.media-viewer-content video{max-width:96vw;max-height:88vh;border-radius:14px;box-shadow:0 24px 80px rgba(0,0,0,.45);background:#05070d}.media-viewer-content audio{width:min(720px,90vw)}.media-viewer-caption{position:fixed;left:24px;right:74px;bottom:18px;color:rgba(255,255,255,.78);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Prevent horizontal scrolling in conversation columns */
.board,.col,.messages,.msg,.msg .text{min-width:0;max-width:100%;overflow-x:hidden}.msg .text,.msg .text a{overflow-wrap:anywhere;word-break:break-word}.messages{scrollbar-gutter:stable}

/* Correct overflow handling: only the message column scrolls, never each bubble */
.board{overflow-x:hidden}.col{min-width:0;overflow:hidden}.messages{min-width:0;overflow-y:auto;overflow-x:hidden}.msg{min-width:0;max-width:100%;overflow:visible}.msg .text{max-width:100%;overflow:visible;overflow-wrap:anywhere;word-break:normal}.msg .text a{overflow-wrap:anywhere;word-break:break-word}

/* Align the Change/close controls with the title-row icons */
.col-actions{align-self:flex-start;margin-top:8px}

/* Title row baseline/bottom alignment */
.col-head{align-items:flex-start}.topic-title{align-items:flex-end}.col-actions{align-self:flex-start;margin-top:0}.col h2{line-height:1}.edit-topic,.pick-color,.badge,.close-column{display:inline-flex;align-items:center;justify-content:center;min-height:30px}
.group-choice{width:100%;text-align:left;display:grid;gap:3px;background:rgba(255,255,255,.72);color:#1f2937;border:1px solid var(--line);border-radius:14px;padding:10px 12px}.group-choice:hover{background:#fff}.group-choice span{font-size:14px}.group-choice small{color:#64748b}.picker-back{padding:6px 9px;border-radius:10px;margin-right:8px}
.topic-group{margin-top:2px;font-size:12px;font-weight:700;color:#475569;letter-spacing:.01em;line-height:1.25;opacity:.82}
.new-topic-form{margin:10px 0 12px;padding:10px;border:1px dashed var(--line);border-radius:14px;background:rgba(255,255,255,.45);display:flex;gap:8px;align-items:center}.new-topic-form input{flex:1;border:1px solid var(--line);border-radius:11px;padding:10px;background:rgba(255,255,255,.8);font-size:14px}.new-topic-form button{white-space:nowrap}
.topic-dropzone{margin:14px 0;padding:24px;border:2px dashed rgba(31,41,55,.22);border-radius:18px;background:rgba(255,255,255,.55);display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center;text-align:center;transition:.16s ease}.topic-dropzone.dragover{border-color:#2563eb;background:rgba(37,99,235,.08);transform:scale(1.01)}.topic-dropzone.busy{opacity:.68}.drop-icon{font-size:34px}.browse-files{display:inline-flex;align-items:center;justify-content:center;border-radius:12px;padding:9px 12px;font-weight:800;cursor:pointer;background:#374151;color:#fff}.browse-files input{display:none}.upload-status{min-height:20px;font-size:13px;color:#475569;margin:8px 0}.muted{color:var(--muted)}
.file-list li{display:flex;align-items:center;gap:8px}.file-status{display:inline-flex;align-items:center;gap:4px;flex:0 0 auto;padding:3px 7px;border-radius:999px;border:1px solid rgba(31,41,55,.12);background:rgba(255,255,255,.78);font-size:12px;cursor:help}.file-status small{font-size:10px;color:#475569;font-weight:700}.file-status-uploading{background:#eff6ff}.file-status-vectorizing{background:#f5f3ff}.file-status-ready{background:#ecfdf5}.file-status-stored{background:#f8fafc}.file-list li.uploading{opacity:.82;border-style:dashed}
.file-name{font-size:12px;font-weight:400;color:#334155;line-height:1.25;overflow-wrap:anywhere}.file-list li{font-size:12px}
.human-list{display:flex;flex-direction:column;gap:8px;margin:12px 0}.human-choice{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:14px;background:rgba(255,255,255,.72);cursor:pointer}.human-choice input{width:18px;height:18px}.human-choice span{display:flex;flex-direction:column;gap:2px}.human-choice b{font-size:14px}.human-choice small{font-size:12px;color:#64748b}.modal-actions{display:flex;justify-content:flex-end;margin-top:12px}.invite-status{min-height:20px;margin-top:10px;font-size:13px;color:#475569}
.human-choice.disabled{opacity:.45;cursor:not-allowed;background:rgba(255,255,255,.42)}.human-choice.disabled input{cursor:not-allowed}

.blank-state { min-height: 55vh; display: grid; place-items: center; }
.blank-state.hidden { display: none; }
.blank-state button { font-size: 1.4rem; padding: 1.2rem 2rem; border-radius: 999px; border: 0; background: #1a73e8; color: white; cursor: pointer; box-shadow: 0 8px 24px rgba(26,115,232,.25); }
.blank-state button:hover { background: #1557b0; }
.hidden { display: none !important; }
