/* ARK Attach V6 — only attachment UI and code-empty; no global shell sizing */
#arkAttachSourcesV6[hidden],#arkLinkShelf[hidden]{display:none!important}
#arkAttachSourcesV6{position:fixed;z-index:2147483601;width:min(440px,calc(100vw - 24px));max-height:min(690px,calc(100dvh - 24px));overflow:auto;overscroll-behavior:contain;padding:16px;box-sizing:border-box;background:var(--surface,#18181b);color:var(--ink,#f4f1f1);border:1px solid var(--line,#343035);border-radius:17px;box-shadow:0 22px 65px #000b;font:13px/1.5 'Be Vietnam Pro',system-ui,sans-serif;scrollbar-width:thin;scrollbar-color:var(--accent,#e11d2e) transparent}
#arkAttachSourcesV6 *{box-sizing:border-box}
#arkAttachSourcesV6 button,#arkAttachSourcesV6 input,#arkAttachSourcesV6 textarea{font:inherit}
#arkAttachSourcesV6 .ap-head{display:flex;align-items:center;gap:12px;margin-bottom:12px}
#arkAttachSourcesV6 .ap-title{font-size:15px;font-weight:800;flex:1;min-width:0}
#arkAttachSourcesV6 .ap-x{width:34px;height:34px;display:grid;place-items:center;border:1px solid var(--line,#353139);border-radius:9px;background:var(--raise,#232327);color:var(--muted,#a3999a);cursor:pointer;font-size:19px;flex:none}
#arkAttachSourcesV6 .ap-x:hover{color:var(--ink,#fff);border-color:var(--accent,#e11d2e)}
#arkAttachSourcesV6 .ap-ops{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
#arkAttachSourcesV6 .ap-op{display:flex;align-items:center;gap:10px;min-height:65px;text-align:left;min-width:0;padding:10px;background:var(--field,#0b0b0c);color:var(--ink,#fff);border:1px solid var(--line,#343035);border-radius:12px;cursor:pointer}
#arkAttachSourcesV6 .ap-op:hover{border-color:var(--accent,#e11d2e);background:var(--raise,#242327)}
#arkAttachSourcesV6 .ap-ico{width:32px;height:32px;min-width:32px;display:grid;place-items:center;border-radius:9px;background:var(--raise,#232327);color:var(--accent,#e11d2e)}
#arkAttachSourcesV6 svg{width:18px;height:18px;stroke:currentColor;stroke-width:1.9;stroke-linejoin:round;stroke-linecap:round;fill:none}
#arkAttachSourcesV6 .ap-op b{display:block;font-size:12px}
#arkAttachSourcesV6 .ap-op small{display:block;color:var(--muted,#a3999a);font-size:10px;margin-top:2px}
#arkAttachSourcesV6 .ap-section{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:16px 0 9px}
#arkAttachSourcesV6 .ap-section b{font-size:12px;font-weight:750}
#arkAttachSourcesV6 .ap-section span{font-size:11px;color:var(--muted,#a3999a)}
#arkAttachSourcesV6 .ap-linkbox{display:flex;gap:8px;align-items:stretch}
#arkAttachSourcesV6 #arkApUrls{resize:vertical;flex:1;min-width:0;min-height:64px;max-height:150px;padding:10px;border-radius:10px;color:var(--ink,#fff);background:var(--field,#0b0b0c);border:1px solid var(--line,#343035);font-size:12px}
#arkAttachSourcesV6 #arkApAddLinks{align-self:stretch;min-width:100px;padding:0 12px;white-space:nowrap;border-radius:10px;border:1px solid var(--accent,#e11d2e);background:var(--accent,#e11d2e);color:#fff;font-weight:650;cursor:pointer}
#arkAttachSourcesV6 .ap-list{display:grid;gap:7px;max-height:165px;overflow:auto;scrollbar-width:thin}
#arkAttachSourcesV6 .ap-item{display:flex;align-items:center;gap:9px;min-height:40px;padding:7px 9px;background:var(--field,#0b0b0c);border:1px solid var(--line,#343035);border-radius:10px;min-width:0}
#arkAttachSourcesV6 .ap-item .ap-name{min-width:0;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px}
#arkAttachSourcesV6 .ap-remove{display:grid;place-items:center;flex:none;min-width:26px;min-height:26px;padding:0 5px;background:transparent;color:var(--muted,#aaa);border:1px solid transparent;border-radius:7px;cursor:pointer;font-size:16px}
#arkAttachSourcesV6 .ap-remove:hover{color:var(--bad,#ff6b6b);border-color:var(--bad,#ff6b6b)}
#arkAttachSourcesV6 .ap-muted{color:var(--muted,#a3999a);font-size:11px;padding:5px 0}
#arkAttachSourcesV6 .ap-provider{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:9px;border-radius:10px;background:transparent;color:var(--ink,#fff);border:1px solid transparent;text-align:left;cursor:pointer}
#arkAttachSourcesV6 .ap-provider:hover{background:var(--raise,#242327);border-color:var(--line,#343035)}
#arkAttachSourcesV6 .ap-provider .ap-provider-name{flex:1;min-width:0;font-weight:600;font-size:12px}
#arkAttachSourcesV6 .ap-provider .ap-provider-status{color:var(--muted,#a3999a);font-size:10px;max-width:110px;text-align:right}
#arkAttachSourcesV6 .ap-foot{margin:10px 0 0;padding-top:10px;border-top:1px solid var(--line,#343035);color:var(--muted,#a3999a);font-size:11px}
/* Native attachment queue remains the single source of truth */
#attList{display:grid!important;grid-template-columns:1fr;gap:7px;max-height:245px;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--accent,#e11d2e) transparent}
#attList .ark-att-file{display:flex;align-items:center;gap:8px;width:100%;min-width:0;min-height:40px;padding:5px 7px 5px 11px;border:1px solid var(--line,#343035);border-radius:10px;background:var(--raise,#232327)}
#attList .ark-att-file>span{min-width:0;flex:1;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#attList .ark-att-file>button{flex:none;min-width:28px;min-height:28px;background:transparent;border:1px solid var(--line,#343035);border-radius:7px;padding:0 5px;color:var(--muted,#aaa);cursor:pointer;font-size:17px}
#attList .ark-att-file>button:hover{color:var(--bad,#ff6b6b);border-color:var(--bad,#ff6b6b)}
#arkLinkShelf{margin-top:10px;padding:10px;border-radius:12px;border:1px solid var(--line,#343035);background:var(--surface,#18181b);min-width:0}
#arkLinkShelf .ark-link-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px;font-size:12px}
#arkLinkShelf .ark-link-list{display:grid;gap:6px;max-height:195px;overflow:auto}
#arkLinkShelf .ark-link-row{display:flex;align-items:center;gap:6px;min-width:0;border:1px solid var(--line,#343035);border-radius:8px;padding:6px 8px;background:var(--field,#0b0b0c)}
#arkLinkShelf .ark-link-row a{min-width:0;flex:1;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ink,#f4f1f1)}
#arkLinkShelf .ark-link-row button{width:27px;height:27px;flex:none;border:0;border-radius:7px;background:transparent;color:var(--muted,#aaa);cursor:pointer;font-size:16px}
#arkLinkShelf .ark-link-row button:hover{color:var(--bad,#ff6b6b);background:var(--raise,#232327)}
#arkLinkShelf #arkLinkClear{border:0;background:transparent;color:var(--muted,#aaa);cursor:pointer;font-size:11px}
#arkLinkShelf #arkLinkClear:hover{color:var(--accent,#e11d2e)}
/* Improve Code empty state only: do NOT touch .shell, .side, .work sizing */
#codePane #codeEmpty:not([hidden]){box-sizing:border-box;min-height:clamp(350px,54vh,600px);height:auto!important;display:flex!important;align-items:center;justify-content:center;padding:20px!important;border:1px dashed var(--line,#353137);border-radius:17px;background:var(--surface,#18181b);background:color-mix(in srgb,var(--surface,#18181b) 28%,var(--bg,#0b0b0c))}
#codePane #codeEmpty .ark-code-welcome{width:min(760px,100%);margin:auto;text-align:center;display:grid;gap:12px;justify-items:center}
#codePane #codeEmpty .ark-code-mark{width:48px;height:48px;border-radius:14px;display:grid;place-items:center;border:1px solid var(--line,#333);color:var(--accent,#e11d2e);background:var(--raise,#232327)}
#codePane #codeEmpty .ark-code-mark svg{width:25px;height:25px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#codePane #codeEmpty .ark-code-welcome h3{margin:0!important;font-size:19px;color:var(--ink,#fff)}
#codePane #codeEmpty .ark-code-welcome p{margin:0!important;color:var(--muted,#a3999a);font-size:12px}
#codePane #codeEmpty .ark-code-examples{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;width:100%;margin-top:12px}
#codePane #codeEmpty .ark-code-example{box-sizing:border-box;min-width:0;min-height:102px;display:flex;flex-direction:column;align-items:flex-start;justify-content:space-between;gap:8px;text-align:left;border:1px solid var(--line,#343035);border-radius:12px;padding:13px;background:var(--surface,#18181b);color:var(--ink,#fff);font:inherit;cursor:pointer}
#codePane #codeEmpty .ark-code-example:hover{border-color:var(--accent,#e11d2e);background:var(--raise,#232327)}
#codePane #codeEmpty .ark-code-example b{font-size:12px}
#codePane #codeEmpty .ark-code-example small{font-size:11px;color:var(--muted,#a3999a)}
@media(max-width:720px){#arkAttachSourcesV6{padding:12px}#arkAttachSourcesV6 .ap-ops{grid-template-columns:1fr}#arkAttachSourcesV6 .ap-op{min-height:52px}#codePane #codeEmpty .ark-code-examples{grid-template-columns:1fr}#codePane #codeEmpty .ark-code-example{min-height:60px}}

/* ARK_EMPTY_LINK_V9: gọn, không hiển thị hai URL giả */
#arkAttachSourcesV6 .ap-linkbox {
  display: block !important;
  width: 100% !important;
}
#arkAttachSourcesV6 #arkApAddLinks { display: none !important; }
#arkAttachSourcesV6 #arkApUrls {
  display: block !important;
  width: 100% !important;
  height: 42px;
  min-height: 42px !important;
  max-height: 142px !important;
  padding: 10px 12px !important;
  box-sizing: border-box !important;
  resize: none !important;
  overflow-x: hidden !important;
  line-height: 20px !important;
  scrollbar-width: thin;
  scrollbar-color: var(--accent, #e11d2e) transparent;
}
#arkAttachSourcesV6 #arkApUrls::-webkit-scrollbar { width: 6px; }
#arkAttachSourcesV6 #arkApUrls::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
#arkAttachSourcesV6 #arkApUrls::-webkit-scrollbar-thumb {
  background: var(--accent, #e11d2e); border-radius: 99px;
}

/* ARK_CLOSE_CENTER_V10 */
/* Nut X tren dau menu: bo glyph/SVG co baseline va ve 2 net o tam tuyet doi. */
#arkAttachSourcesV6 button#arkApCloseV6 {
  position: relative !important;
  display: block !important;
  flex: 0 0 34px !important;
  box-sizing: border-box !important;
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-align: center !important;
  vertical-align: middle !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
#arkAttachSourcesV6 button#arkApCloseV6 > svg,
#arkAttachSourcesV6 button#arkApCloseV6 > span {
  display: none !important;
}
#arkAttachSourcesV6 button#arkApCloseV6::before {
  content: none !important;
  display: none !important;
}
#arkAttachSourcesV6 button#arkApCloseV6::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background:
    linear-gradient(45deg, transparent 44%, currentColor 44%, currentColor 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, currentColor 44%, currentColor 56%, transparent 56%) !important;
  opacity: 1 !important;
  transform: translate(-50%, -50%) !important;
  pointer-events: none !important;
}


/* ARK_INTEGRATED_V14 — only the attachment-picker. Never resize shell/work. */
#arkAttachSourcesV6.ark-ap-side-by-side{
  position:fixed;box-sizing:border-box;min-width:0;max-width:calc(100vw - 24px);
  overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;
  box-shadow:0 16px 48px rgba(0,0,0,.5);
}
#arkAttachSourcesV6.ark-ap-inline{
  position:relative;box-sizing:border-box;display:block;min-width:0;
  max-width:100%;box-shadow:none;overflow-y:auto;
}
#arkAttachSourcesV6[hidden]{display:none!important}
#arkAttachSourcesV6 .ap-op{min-width:0}
#arkAttachSourcesV6 .ap-op :is(b,small){overflow-wrap:anywhere}
@media(max-width:480px){#arkAttachSourcesV6 .ap-ops{grid-template-columns:1fr}}

/* ARK_ATTACH_HEADER_SAFE_V15: chỉ áp dụng cho menu đính kèm. */
#arkAttachSourcesV6.ark-ap-side-by-side {
  position: fixed;
  box-sizing: border-box;
  min-width: 0;
  max-width: calc(100vw - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#arkAttachSourcesV6.ark-ap-inline {
  position: relative;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}
#arkAttachSourcesV6[hidden] { display: none !important; }

/* ARK_ATTACH_FULL_NO_SCROLL_V24: overrides V13/V14/V15/V16 scroll constraints. */
#arkAttachSourcesV6.ark-ap-side-by-side,
#arkAttachSourcesV6.ark-ap-inline {
  height: auto !important;
  max-height: calc(100dvh - 24px) !important;
  overflow: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: auto !important;
  scrollbar-width: none !important;
}
#arkAttachSourcesV6 .ap-list,
#arkAttachSourcesV6 #arkApFilesV6,
#arkAttachSourcesV6 #arkApLinksV6,
#arkAttachSourcesV6 #arkApCloudV6 {
  height: auto !important;
  max-height: 195px !important;
  overflow: auto !important;
  scrollbar-width: none !important;
}
#arkAttachSourcesV6.ark-ap-inline { position: relative !important; }
#arkAttachSourcesV6.ark-ap-side-by-side { position: fixed !important; }
/* V16's old outer viewport must never become a competing scroll container. */
#arkAttachViewportV16 { display: none !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 { padding: 10px 13px !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 .ap-head { margin-bottom: 7px !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 .ap-op { min-height: 51px !important; padding: 7px 9px !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 .ap-section { margin: 10px 0 5px !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 .ap-muted { padding: 2px 0 !important; }
#arkAttachSourcesV6.ark-ap-compact-v24 .ap-foot { margin-top: 6px !important; padding-top: 6px !important; }
#arkAttachSourcesV6[hidden] { display: none !important; }
