* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
       color: #1f2328; background: #fff; height: 100vh; }
.hidden { display: none !important; }
.err { color: #d33; font-size: 13px; min-height: 18px; }

.overlay { position: fixed; inset: 0; background: #f6f7f9;
           display: flex; align-items: center; justify-content: center; z-index: 10; }
.login-box { background: #fff; padding: 32px; border-radius: 12px; width: 320px;
             box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center; }
.login-box h2 { margin: 0 0 20px; }
.login-box input { width: 100%; padding: 10px; margin-bottom: 12px;
                   border: 1px solid #d0d7de; border-radius: 8px; font-size: 15px; }
.login-box button { width: 100%; padding: 10px; border: 0; border-radius: 8px;
                    background: #1f6feb; color: #fff; font-size: 15px; cursor: pointer; }

#app { display: flex; height: 100vh; }
#sidebar { width: 240px; border-right: 1px solid #e4e7eb; padding: 16px;
           overflow-y: auto; flex-shrink: 0; }
#new-btn { width: 100%; padding: 10px; border: 1px dashed #1f6feb; background: #fff;
           color: #1f6feb; border-radius: 8px; cursor: pointer; margin-bottom: 16px; }
#projects { list-style: none; margin: 0; padding: 0; }
#projects li { padding: 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
               margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#projects li:hover { background: #f0f3f6; }
#projects li.active { background: #ddeeff; }
#projects li .badge { font-size: 11px; color: #57606a; margin-left: 6px; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#header { padding: 14px 20px; border-bottom: 1px solid #e4e7eb; font-weight: 600; }
#chat { flex: 1; overflow-y: auto; padding: 20px; }
.msg { max-width: 760px; margin: 0 auto 16px; }
.msg .bubble { padding: 12px 16px; border-radius: 12px; white-space: pre-wrap;
               word-break: break-word; line-height: 1.6; }
.msg.user .bubble { background: #1f6feb; color: #fff; margin-left: auto; max-width: 70%; width: fit-content; }
.msg.assistant .bubble { background: #f0f3f6; }
.msg.assistant .bubble.thinking { color: #57606a; font-style: italic;
  animation: prd-pulse 1.4s ease-in-out infinite; }
@keyframes prd-pulse { 0%, 100% { opacity: .45; } 50% { opacity: .9; } }
.msg.error .bubble { background: #fff0f0; color: #b91c1c; }
.options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.options button { padding: 8px 14px; border: 1px solid #1f6feb; background: #fff;
                  color: #1f6feb; border-radius: 18px; cursor: pointer; font-size: 14px; }
.options button .desc { color: #57606a; font-size: 12px; margin-left: 4px; }
.done-actions { margin-top: 12px; }
.done-actions button { padding: 8px 16px; border: 0; border-radius: 8px;
                       background: #1f883d; color: #fff; cursor: pointer; }

#composer { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid #e4e7eb; }
#input { flex: 1; resize: none; height: 56px; padding: 10px; border: 1px solid #d0d7de;
         border-radius: 8px; font-size: 15px; font-family: inherit; }
#send-btn { padding: 0 24px; border: 0; border-radius: 8px; background: #1f6feb;
            color: #fff; cursor: pointer; }
#send-btn:disabled, #input:disabled { opacity: .5; cursor: not-allowed; }

#prd-panel { width: 460px; border-left: 1px solid #e4e7eb; display: flex;
             flex-direction: column; flex-shrink: 0; }
#prd-panel header { display: flex; align-items: center; gap: 12px; padding: 14px 20px;
                    border-bottom: 1px solid #e4e7eb; }
#prd-panel header span { font-weight: 600; flex: 1; }
#prd-panel header a { color: #1f6feb; font-size: 14px; text-decoration: none; }
#close-prd { border: 0; background: none; font-size: 20px; cursor: pointer; color: #57606a; }
#prd-body { overflow-y: auto; padding: 20px; }
.markdown h1, .markdown h2 { border-bottom: 1px solid #eaecef; padding-bottom: .3em; }
.markdown table { border-collapse: collapse; }
.markdown td, .markdown th { border: 1px solid #d0d7de; padding: 6px 12px; }
.markdown code { background: #f0f3f6; padding: 2px 5px; border-radius: 4px; }
.markdown pre { background: #f0f3f6; padding: 12px; border-radius: 8px; overflow-x: auto; }

/* 附件上传 */
#attach-btn { padding: 0 12px; border: 1px solid #d0d7de; background: #fff; border-radius: 8px;
              cursor: pointer; font-size: 18px; flex-shrink: 0; }
#attach-btn:disabled { opacity: .5; cursor: not-allowed; }
#attachments { max-width: 760px; margin: 0 auto; padding: 8px 20px 0;
               display: flex; flex-wrap: wrap; gap: 8px; }
#attachments:empty { display: none; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; background: #f0f3f6;
            border: 1px solid #d0d7de; border-radius: 8px; padding: 4px 8px;
            font-size: 13px; max-width: 220px; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; display: block; }
.att-del { border: 0; background: none; cursor: pointer; color: #57606a; font-size: 13px; padding: 0 2px; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg.user .msg-attachments .att-thumb { width: 64px; height: 64px; }
.att-file { background: rgba(255,255,255,.25); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
#upload-hint { max-width: 760px; margin: 4px auto 0; padding: 0 20px 10px;
               font-size: 12px; color: #8b949e; line-height: 1.5; }
#upload-hint strong { color: #57606a; font-weight: 600; }

/* ============ 管理后台 ============ */
#admin-header { display: flex; align-items: center; gap: 16px; padding: 14px 24px;
                border-bottom: 1px solid #e4e7eb; }
#admin-header .admin-title { font-weight: 600; font-size: 16px; }
#admin-header .overview { color: #57606a; font-size: 14px; }
#admin-main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.admin-card { background: #fff; border: 1px solid #e4e7eb; border-radius: 12px;
              padding: 20px; margin-bottom: 20px; }
.admin-card h3 { margin: 0 0 16px; font-size: 15px; }

.add-user-form { display: flex; gap: 10px; flex-wrap: wrap; }
.add-user-form input { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid #d0d7de;
                       border-radius: 8px; font-size: 14px; }
.add-user-form button { padding: 9px 18px; border: 0; border-radius: 8px;
                        background: #1f6feb; color: #fff; cursor: pointer; font-size: 14px; }
.token-box { margin-top: 14px; padding: 12px 14px; background: #fff8e6; border: 1px solid #f0d58c;
             border-radius: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.token-box .token-tip { color: #8a6d1a; font-size: 13px; }
.token-val { background: #fff; border: 1px solid #e4d08a; border-radius: 6px; padding: 4px 10px;
             font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
             word-break: break-all; }
.copy-btn { padding: 5px 12px; border: 1px solid #1f6feb; background: #fff; color: #1f6feb;
            border-radius: 6px; cursor: pointer; font-size: 13px; }

.table-wrap { overflow-x: auto; }
#users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#users-table th, #users-table td { padding: 10px 12px; border-bottom: 1px solid #eaecef;
                                   text-align: left; white-space: nowrap; }
#users-table th { color: #57606a; font-weight: 600; font-size: 13px; }
#users-table tbody tr:hover { background: #f6f8fa; }
.token-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
              background: #f0f3f6; border-radius: 6px; padding: 3px 8px; cursor: pointer;
              max-width: 180px; overflow: hidden; text-overflow: ellipsis; display: inline-block;
              vertical-align: middle; }
.token-cell:hover { background: #e3e9ef; }
.status-badge { font-size: 12px; padding: 2px 10px; border-radius: 12px; }
.status-active { background: #dafbe1; color: #1a7f37; }
.status-disabled { background: #ffebe9; color: #cf222e; }
.op-cell { display: flex; gap: 6px; }
.op-btn { padding: 5px 10px; border: 1px solid #d0d7de; background: #fff; border-radius: 6px;
          cursor: pointer; font-size: 13px; color: #1f2328; }
.op-btn:hover { background: #f0f3f6; }
.op-danger { color: #cf222e; border-color: #f3c2c2; }
.op-danger:hover { background: #ffebe9; }

/* 抽屉：看某用户的项目 + 对话 */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0,0,0,.32); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(880px, 92vw);
                background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12);
                display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px;
               border-bottom: 1px solid #e4e7eb; }
.drawer-title { font-weight: 600; flex: 1; }
.drawer-close { border: 0; background: none; font-size: 22px; cursor: pointer; color: #57606a; }
.drawer-body { flex: 1; display: flex; min-height: 0; }
.drawer-col { display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.drawer-col h4 { margin: 0 0 12px; font-size: 14px; color: #57606a; }
.drawer-col:first-child { width: 260px; border-right: 1px solid #e4e7eb; flex-shrink: 0; }
.drawer-msgs-col { flex: 1; min-width: 0; }
.drawer-projects { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.drawer-proj { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
               margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-proj:hover { background: #f0f3f6; }
.drawer-proj.active { background: #ddeeff; }
.drawer-proj .badge { font-size: 11px; color: #57606a; }
.drawer-messages { overflow-y: auto; flex: 1; }
.drawer-messages .msg { max-width: 100%; margin: 0 0 14px; }
.drawer-empty { color: #8b949e; font-size: 13px; padding: 4px 2px; }
