html, body { margin:0; padding:0; width:440px; min-height:390px; font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:#111827; color:#e5e7eb; }
.wrap { padding:12px; box-sizing:border-box; }
.title { display:flex; align-items:center; gap:7px; font-weight:700; font-size:15px; margin-bottom:10px; user-select:text; }
.popup-title-icon { border-radius:4px; }
label { display:block; font-size:12px; margin:7px 0 3px; color:#cbd5e1; user-select:text; }
input, select { width:100%; box-sizing:border-box; border:1px solid #374151; border-radius:8px; background:#020617; color:#e5e7eb; padding:7px 8px; outline:none; }
input:focus, select:focus { border-color:#60a5fa; }
.row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.buttons { display:flex; gap:7px; margin-top:10px; flex-wrap:wrap; }
.buttons.sub { margin-top:7px; }
button { border:1px solid #4b5563; border-radius:8px; background:#1f2937; color:#f9fafb; padding:7px 10px; cursor:pointer; font-size:12px; }
button:hover { background:#374151; }
#openPanelBtn { background:#2563eb; border-color:#3b82f6; font-weight:700; }
#openPanelBtn:hover { background:#1d4ed8; }
.hint { margin-top:10px; font-size:12px; color:#9ca3af; line-height:1.4; user-select:text; }
.toast { display:none; position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); z-index:2147483647; max-width:min(560px, calc(100vw - 28px)); max-height:min(50vh, 420px); overflow:auto; padding:14px 42px 14px 14px; border-radius:12px; background:#064e3b; color:#d1fae5; white-space:pre-wrap; user-select:text; box-shadow:0 18px 60px rgba(0,0,0,.55); border:1px solid rgba(16,185,129,.65); cursor:pointer; }
.toast.on { display:block; }
.toast.err { background:#7f1d1d; color:#fee2e2; cursor:default; }
.toast .toast-x { position:absolute; right:10px; top:8px; width:24px; height:24px; border:1px solid rgba(255,255,255,.45); border-radius:999px; background:rgba(0,0,0,.18); color:inherit; cursor:pointer; font-weight:900; line-height:20px; }
.toast .toast-body { user-select:text; cursor:text; }

.tab-client-row { margin-top:7px; }
.tab-info { margin-top:4px; font-size:11px; color:#94a3b8; line-height:1.35; user-select:text; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.label-row{display:flex;align-items:center;gap:8px;min-width:0;margin-top:5px;}
.label-row>label:first-child{margin:0;flex:1;min-width:0;}
.route-use-label{display:inline-flex!important;align-items:center;gap:4px;margin:0!important;white-space:nowrap;color:#e5e7eb;font-size:11px;}
.route-use-label input{width:auto;margin:0;}
.popup-tab-badge{display:inline-flex;align-items:center;white-space:nowrap;min-width:0;max-width:190px;overflow:hidden;text-overflow:ellipsis;font-size:11px;color:#bfdbfe;cursor:pointer;}
#clientIdHistory { font-size:12px; }
#authToken { white-space:nowrap; overflow:hidden; text-overflow:clip; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }


/* AIWK EXT4 v033 popup window control */
#closeAllBtn { background:#7f1d1d; border-color:#ef4444; font-weight:700; }
#closeAllBtn:hover { background:#991b1b; }
.win-controls { border:1px dashed #64748b; border-radius:10px; padding:7px; background:rgba(15,23,42,.72); }
.win-controls[hidden] { display:none !important; }
.win-controls button { min-width:54px; }
#iconAllBtn { background:#581c87; border-color:#a855f7; }
body.aiwk-connected .title { color:#bbf7d0; }

.history-line{display:flex;gap:6px;align-items:center;}
.history-line select{flex:1;min-width:0;}
#deleteClientHistoryBtn{width:auto;padding:7px 9px;background:#2a1515;border-color:#6b2a2a;color:#ffd8d8;}
#deleteClientHistoryBtn:hover{background:#472020;}


/* AIWK EXT4 v044 home selftest/domain module/tab settings */
.domain-module-box{margin-top:10px;border:1px solid #334155;border-radius:12px;background:rgba(15,23,42,.82);padding:8px;}
.domain-module-title{font-weight:700;font-size:12px;color:#bfdbfe;margin-bottom:5px;user-select:text;}
.domain-info{font-size:11px;line-height:1.35;color:#cbd5e1;white-space:normal;word-break:break-all;user-select:text;}
.domain-module-list{margin-top:7px;display:flex;flex-direction:column;gap:6px;font-size:11px;}
.domain-module-item{border:1px solid #475569;border-radius:10px;background:#020617;padding:7px;}
.domain-module-head{display:flex;align-items:center;justify-content:space-between;gap:6px;font-weight:700;color:#e0f2fe;}
.domain-module-meta{margin-top:3px;color:#94a3b8;word-break:break-all;user-select:text;}
.domain-module-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:6px;}
.domain-module-actions label{display:inline-flex;align-items:center;gap:4px;margin:0;color:#e5e7eb;}
.domain-module-actions input[type=checkbox]{width:auto;}
.domain-module-actions select{width:auto;min-width:82px;padding:5px 6px;}
.domain-history-line{margin-top:7px;}
#cloneDomainTabBtn,#deleteDomainHistoryBtn,#saveTabDomainBtn,#deleteTabDomainBtn,#scanDomainBtn{width:auto;padding:7px 8px;}
#deleteDomainHistoryBtn,#deleteTabDomainBtn{background:#2a1515;border-color:#6b2a2a;color:#ffd8d8;}


/* AIWK EXT4 v045 · debug guide / disabled domain modules */
.debug-guide-box{margin-top:10px;border:1px solid #334155;border-radius:12px;background:rgba(2,6,23,.74);padding:8px;}
.debug-guide-box summary{cursor:pointer;font-size:12px;font-weight:800;color:#fef3c7;user-select:text;}
.debug-guide-line{font-size:11px;color:#cbd5e1;line-height:1.45;margin-top:5px;user-select:text;}
.debug-hub-text{width:100%;min-height:74px;box-sizing:border-box;margin-top:7px;border:1px solid #334155;border-radius:8px;background:#020617;color:#d1fae5;font-size:11px;line-height:1.35;padding:7px;resize:vertical;}
.role-guide{color:#fef3c7;}
.domain-module-item.aiwk-domain-module-disabled{opacity:.46;filter:grayscale(.45);border-style:dashed;}
.domain-module-state{font-size:10px;color:#fde68a;margin-top:4px;user-select:text;}
button[disabled], input[disabled], select[disabled]{opacity:.45;cursor:not-allowed;}


/* AIWK EXT4 v046 · WSS/BUS/NR connection controls */
.comm-control-box{margin-top:9px;border:1px solid #334155;border-radius:12px;background:rgba(15,23,42,.86);padding:8px;transition:opacity .15s,filter .15s;}
.comm-control-box.is-disabled{opacity:.46;filter:grayscale(.55);}
.comm-control-title{font-size:12px;font-weight:800;color:#bfdbfe;margin-bottom:5px;user-select:text;}
.comm-status-summary{font-size:11px;color:#cbd5e1;margin-bottom:6px;white-space:normal;word-break:break-all;user-select:text;}
.comm-row{display:grid;grid-template-columns:36px 64px 1fr 1fr minmax(96px,auto);gap:5px;align-items:center;margin-top:5px;}
.comm-name{font-weight:900;font-size:12px;color:#e5e7eb;user-select:text;}
.comm-badge{display:inline-flex;align-items:center;justify-content:center;border-radius:999px;border:1px solid #475569;padding:3px 6px;font-size:11px;font-weight:800;white-space:nowrap;}
.comm-badge.ok{background:#064e3b;border-color:#10b981;color:#d1fae5;}
.comm-badge.warn{background:#78350f;border-color:#f59e0b;color:#fef3c7;}
.comm-badge.bad{background:#3f1d1d;border-color:#ef4444;color:#fee2e2;}
.comm-badge.off{background:#1f2937;border-color:#4b5563;color:#9ca3af;}
.comm-row button{padding:6px 7px;min-width:0;}
.comm-keep{display:inline-flex;align-items:center;gap:4px;margin:0;font-size:11px;color:#e5e7eb;white-space:nowrap;}
.comm-keep input{width:auto;}
.comm-retry-sec{width:42px !important;min-width:42px;padding:2px 4px !important;margin:0 !important;text-align:right;font-size:11px;}
.comm-control-hint{font-size:10px;color:#94a3b8;line-height:1.35;margin-top:6px;user-select:text;}
.delay-settings-box{margin-top:9px;border:1px solid #475569;border-radius:12px;background:rgba(15,23,42,.82);padding:8px;user-select:text;}
.delay-settings-box summary{cursor:pointer;font-size:12px;font-weight:800;color:#bfdbfe;user-select:text;}
.delay-settings-info{margin:6px 0;color:#93c5fd;font-size:11px;word-break:break-all;user-select:text;}
.delay-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;}
.delay-grid label{display:flex;align-items:center;gap:4px;margin:0;color:#e5e7eb;font-size:11px;white-space:nowrap;}
.delay-grid input{width:54px;min-width:54px;padding:3px 5px;margin:0;text-align:right;}
.delay-actions{margin-top:7px;}

/* AIWK EXT4 v047 · primary auth buttons under token */
.primary-auth-actions{border:1px solid #1d4ed8;border-radius:10px;padding:7px;background:rgba(30,64,175,.18);}
.primary-auth-actions button{min-width:70px;font-weight:800;}
.primary-auth-actions #saveBtn{background:#14532d;border-color:#22c55e;color:#dcfce7;}
.primary-auth-actions #closeAllBtn{margin-left:auto;}
.utility-actions{border:1px dashed #475569;border-radius:10px;padding:7px;background:rgba(2,6,23,.42);}


/* AIWK EXT4 v059 · profile list + always-on chat */
.client-profile-list{max-height:170px;margin-top:6px;max-height:92px;overflow:auto;border:1px solid #334155;border-radius:8px;background:#020617;padding:4px;display:flex;flex-direction:column;gap:4px;}
.client-profile-list:empty{display:none;}
.client-profile-item{display:grid;grid-template-columns:1fr 24px;gap:5px;align-items:center;border:1px solid #1f2937;border-radius:7px;background:#0f172a;padding:4px 5px;font-size:11px;color:#dbeafe;}
.client-profile-main{cursor:pointer;user-select:text;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.client-profile-main:hover{color:#fef3c7;}
.client-profile-del{background:#7f1d1d!important;border-color:#ef4444!important;color:#fee2e2!important;border-radius:6px!important;padding:3px 0!important;min-width:0!important;font-weight:900;}
.comm-link{color:#93c5fd;text-decoration:underline;cursor:pointer;}
.aiwk-quick-chat-box{margin-top:9px;border:1px solid #1f4f46;border-radius:12px;background:rgba(6,78,59,.18);padding:8px;}
.aiwk-quick-chat-title{font-size:12px;font-weight:900;color:#bbf7d0;margin-bottom:5px;user-select:text;}
.aiwk-chat-to,.aiwk-chat-message{width:100%;box-sizing:border-box;border:1px solid #334155;border-radius:8px;background:#020617;color:#e5e7eb;padding:7px;font-size:12px;}
.aiwk-chat-message{min-height:42px;resize:vertical;line-height:1.35;}
.aiwk-chat-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px;}
.aiwk-chat-actions button{width:auto;min-width:58px;padding:6px 8px;}
.aiwk-chat-hint{font-size:10px;color:#a7f3d0;line-height:1.35;margin-top:5px;user-select:text;}
#clientId.aiwk-input-error{border-color:#ef4444!important;box-shadow:0 0 0 2px rgba(239,68,68,.25);}

.aiwk-mini-mark{display:inline-block;margin-left:6px;padding:2px 6px;border-radius:999px;font-size:11px;font-weight:700;background:#e2e8f0;color:#334155}
.aiwk-mini-mark.ok{background:#dcfce7;color:#166534}.aiwk-mini-mark.warn{background:#fef9c3;color:#854d0e}.aiwk-mini-mark.bad{background:#fee2e2;color:#991b1b}
.client-profile-item.is-hidden-bad{display:none}

.aiwk-inline-notice{margin:6px 0 8px;padding:8px 9px;border-radius:9px;border:1px solid #334155;background:#0f172a;color:#dbeafe;font-size:12px;line-height:1.35;white-space:pre-wrap;user-select:text;}
.aiwk-inline-notice[hidden]{display:none!important;}
.aiwk-inline-notice.err{background:#3f1d1d;border-color:#ef4444;color:#fee2e2;}
.aiwk-inline-notice.info{background:#172554;border-color:#3b82f6;color:#dbeafe;}
.aiwk-input-error{border-color:#ef4444!important;box-shadow:0 0 0 2px rgba(239,68,68,.25)!important;}

/* v067-stage1.4-version-sync ping -t style */
.aiwk-ping-loop-row{display:flex;align-items:center;gap:6px;margin-top:6px;padding:6px;border:1px solid rgba(127,127,127,.35);border-radius:8px;background:rgba(127,127,127,.08);font-size:12px;}
.aiwk-ping-loop-check{display:flex;align-items:center;gap:4px;white-space:nowrap;}
.aiwk-ping-loop-sec{width:58px;min-width:58px;padding:3px 5px;}
.aiwk-ping-loop-status{margin-left:auto;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.aiwk-ping-loop-status.run{color:#16a34a;font-weight:700;}
.aiwk-ping-loop-status.err{color:#dc2626;font-weight:700;}
.aiwk-ping-loop-status.off{color:#777;}
.aiwk-ping-loop-status.info{color:#2563eb;}

/* v068-stage1.5 UI/state clarity */
.title { position:relative; padding-right:34px; }
.popup-close-x{ position:absolute; right:6px; top:4px; width:24px; height:24px; border:1px solid rgba(255,255,255,.25); border-radius:6px; background:rgba(255,255,255,.08); color:inherit; cursor:pointer; user-select:text; }
.popup-close-x:hover{ background:rgba(255,80,80,.25); border-color:rgba(255,80,80,.6); }
.comm-status-summary{ user-select:text; white-space:pre-wrap; }
.comm-badge{ user-select:text; min-width:56px; text-align:center; font-weight:700; }
.comm-badge.ok::before{ content:"✅ "; }
.comm-badge.warn::before{ content:"⚠️ "; }
.comm-badge.bad::before{ content:"❌ "; }
.comm-badge.off::before{ content:"▫️ "; }
.aiwk-chat-inbox{ min-height:48px; max-height:120px; overflow:auto; border:1px solid rgba(128,128,128,.45); border-radius:6px; padding:6px; margin:3px 0 6px 0; background:rgba(0,0,0,.16); white-space:pre-wrap; user-select:text; font-size:12px; line-height:1.35; }
.aiwk-chat-inbox .rx-line{ border-bottom:1px dashed rgba(128,128,128,.25); padding:2px 0; }
.aiwk-chat-inbox .rx-line:last-child{ border-bottom:0; }
.aiwk-ping-loop-status.run::before{ content:"🔁 "; }
.aiwk-ping-loop-status.off::before{ content:"⏹️ "; }
.aiwk-ping-loop-status.err::before{ content:"❌ "; }
.aiwk-ping-loop-status.info::before{ content:"ℹ️ "; }

/* v091 · 접속창 공통 client/status 표시 */
.popup-client-badge{display:inline-flex;align-items:center;justify-content:center;min-width:34px;margin-left:4px;padding:2px 8px;border-radius:999px;border:1px solid rgba(147,197,253,.85);background:rgba(30,64,175,.85);color:#eff6ff;font-size:12px;font-weight:900;letter-spacing:.02em;user-select:text;}
.popup-conn-badge{display:inline-flex;align-items:center;gap:4px;margin-left:3px;padding:2px 7px;border-radius:999px;border:1px solid #64748b;background:rgba(15,23,42,.78);font-size:11px;font-weight:800;white-space:nowrap;user-select:text;}
.popup-conn-badge.online{border-color:#22c55e;color:#bbf7d0;background:rgba(22,101,52,.28);}
.popup-conn-badge.offline{border-color:#ef4444;color:#fecaca;background:rgba(127,29,29,.26);}
.popup-conn-badge.reconnecting{border-color:#eab308;color:#fef08a;background:rgba(113,63,18,.3);}
.popup-conn-badge.replaced{border-color:#a78bfa;color:#ddd6fe;background:rgba(76,29,149,.3);}

/* v096 · tab_id right badge + WSS/BUS/NR triple status */
.label-row{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:7px;}
.label-row label{margin:0;color:#cbd5e1;}
.popup-tab-badge{margin-left:auto;display:inline-flex;align-items:center;justify-content:center;border:1px solid #22d3ee;border-radius:999px;background:rgba(8,47,73,.88);color:#cffafe;font-size:11px;font-weight:900;padding:3px 8px;white-space:nowrap;user-select:text;box-shadow:0 0 0 1px rgba(34,211,238,.15),0 0 14px rgba(34,211,238,.18);}
.popup-conn-badge{min-width:54px;justify-content:center;letter-spacing:-.08em;}


/* v102 · tab_id fixed visibility + resizable profile list */
.title { position:sticky; top:0; z-index:40; background:#111827; padding:6px 0 8px; border-bottom:1px solid rgba(148,163,184,.28); }
.label-row { position:sticky; top:38px; z-index:39; background:#111827; padding:4px 0; border-bottom:1px solid rgba(148,163,184,.18); }
.popup-tab-badge { cursor:pointer; user-select:text; font-weight:900; border-color:#38bdf8; color:#e0f2fe; background:rgba(14,116,144,.45); }
.popup-tab-badge:hover { outline:2px solid rgba(56,189,248,.55); }
.client-profile-list { resize:vertical; overflow:auto; min-height:64px; max-height:360px; }
@media (prefers-color-scheme: light) { .title, .label-row { background:#f8fafc; } .popup-tab-badge { background:#e0f2fe; color:#075985; } }
